From: Chuck Lever <cel@netapp.com>
To: git@vger.kernel.org
Subject: [PATCH 10/22] teach update-index.c about cache cursors
Date: Mon, 12 Sep 2005 10:56:05 -0400 [thread overview]
Message-ID: <20050912145605.28120.174.stgit@dexter.citi.umich.edu> (raw)
In-Reply-To: <20050912145543.28120.7086.stgit@dexter.citi.umich.edu>
Signed-off-by: Chuck Lever <cel@netapp.com>
---
update-index.c | 62 +++++++++++++++++++++++++-------------------------------
1 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/update-index.c b/update-index.c
--- a/update-index.c
+++ b/update-index.c
@@ -13,7 +13,7 @@
* files be revision controlled.
*/
static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0, info_only = 0;
-static int force_remove;
+static int force_remove, has_errors = 0;
/* Three functions to allow overloaded pointer return; see linux/err.h */
static inline void *ERR_PTR(long error)
@@ -190,41 +190,35 @@ static struct cache_entry *refresh_entry
return updated;
}
-static int refresh_cache(void)
+static int refresh_one(struct cache_cursor *cc, struct cache_entry *ce)
{
- int i;
- int has_errors = 0;
+ struct cache_entry *new;
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce, *new;
- ce = active_cache[i];
- if (ce_stage(ce)) {
- printf("%s: needs merge\n", ce->name);
- has_errors = 1;
- while ((i < active_nr) &&
- ! strcmp(active_cache[i]->name, ce->name))
- i++;
- i--;
- continue;
- }
+ if (ce_stage(ce)) {
+ printf("%s: needs merge\n", ce->name);
+ has_errors = 1;
+ next_name(cc, ce);
+ return 0;
+ }
- new = refresh_entry(ce);
- if (IS_ERR(new)) {
- if (not_new && PTR_ERR(new) == -ENOENT)
- continue;
- if (quiet)
- continue;
- printf("%s: needs update\n", ce->name);
- has_errors = 1;
- continue;
- }
- active_cache_changed = 1;
- /* You can NOT just free active_cache[i] here, since it
- * might not be necessarily malloc()ed but can also come
- * from mmap(). */
- active_cache[i] = new;
+ new = refresh_entry(ce);
+ if (IS_ERR(new)) {
+ if (not_new && PTR_ERR(new) == -ENOENT)
+ return 0;
+ if (quiet)
+ return 0;
+ printf("%s: needs update\n", ce->name);
+ has_errors = 1;
+ next_cc(cc);
+ return 0;
}
- return has_errors;
+
+ /* You can NOT just free active_cache[i] here, since it
+ * might not be necessarily malloc()ed but can also come
+ * from mmap(). */
+ set_ce_at_cursor(cc, new);
+ next_cc(cc);
+ return 0;
}
/*
@@ -323,7 +317,7 @@ static struct cache_file cache_file;
int main(int argc, char **argv)
{
- int i, newfd, entries, has_errors = 0;
+ int i, newfd, entries;
int allow_options = 1;
const char *prefix = setup_git_directory();
@@ -360,7 +354,7 @@ int main(int argc, char **argv)
continue;
}
if (!strcmp(path, "--refresh")) {
- has_errors |= refresh_cache();
+ walk_cache(refresh_one);
continue;
}
if (!strcmp(path, "--cacheinfo")) {
next prev parent reply other threads:[~2005-09-12 14:59 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-12 14:55 [PATCH 00/22] cache cursors: an introduction Chuck Lever
2005-09-12 14:55 ` [PATCH 01/22] introduce facility to walk through the active cache Chuck Lever
2005-09-12 14:55 ` [PATCH 02/22] use cache iterator in checkout-index.c Chuck Lever
2005-09-12 14:55 ` [PATCH 03/22] teach diff.c about cache iterators Chuck Lever
2005-09-12 14:55 ` [PATCH 04/22] teach diff-index.c " Chuck Lever
2005-09-12 14:55 ` [PATCH 05/22] teach diff-files.c " Chuck Lever
2005-09-12 14:55 ` [PATCH 06/22] teach diff-stages.c " Chuck Lever
2005-09-12 14:55 ` [PATCH 07/22] teach fsck-objects.c to use " Chuck Lever
2005-09-12 14:56 ` [PATCH 08/22] teach ls-files.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 09/22] teach read-tree.c " Chuck Lever
2005-09-12 14:56 ` Chuck Lever [this message]
2005-09-12 14:56 ` [PATCH 11/22] teach write-tree.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 12/22] simplify write_cache() calling sequence Chuck Lever
2005-09-12 14:56 ` [PATCH 13/22] move purge_cache() to read-cache.c Chuck Lever
2005-09-12 14:56 ` [PATCH 14/22] move read_cache_unmerged into read-cache.c Chuck Lever
2005-09-12 14:56 ` [PATCH 15/22] replace cache_name_pos Chuck Lever
2005-09-12 14:56 ` [PATCH 16/22] teach apply.c to use cache_find_name() Chuck Lever
2005-09-12 14:56 ` [PATCH 17/22] teach checkout-index.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 18/22] teach diff.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 19/22] teach ls-files.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 20/22] teach merge-index.c " Chuck Lever
2005-09-12 14:56 ` [PATCH 21/22] teach the merge algorithm about cache iterators Chuck Lever
2005-09-12 20:43 ` Daniel Barkalow
2005-09-13 0:02 ` Chuck Lever
2005-09-14 15:36 ` Chuck Lever
2005-09-14 16:41 ` Daniel Barkalow
2005-09-14 17:50 ` Junio C Hamano
2005-09-14 19:49 ` Chuck Lever
2005-09-14 20:40 ` Daniel Barkalow
2005-09-14 22:28 ` Chuck Lever
2005-09-14 22:50 ` Linus Torvalds
2005-09-14 23:23 ` Daniel Barkalow
2005-09-15 14:01 ` Chuck Lever
2005-09-12 14:56 ` [PATCH 22/22] teach read-cache.c to use cache_find_name() Chuck Lever
2005-09-12 15:38 ` [PATCH 00/22] cache cursors: an introduction A Large Angry SCM
2005-09-12 16:37 ` Chuck Lever
2005-09-12 20:26 ` Daniel Barkalow
2005-09-12 20:47 ` Junio C Hamano
2005-09-13 19:06 ` Tim Ottinger
2005-09-13 19:46 ` Junio C Hamano
2005-09-13 20:06 ` Tim Ottinger
2005-09-14 8:28 ` Catalin Marinas
2005-09-14 14:49 ` Chuck Lever
2005-09-12 19:53 ` Junio C Hamano
2005-09-12 20:22 ` Daniel Barkalow
2005-09-12 20:30 ` Junio C Hamano
2005-09-12 23:59 ` Chuck Lever
2005-09-13 0:14 ` Junio C Hamano
2005-09-13 0:17 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050912145605.28120.174.stgit@dexter.citi.umich.edu \
--to=cel@netapp.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).