summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-10 18:32:54 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-10 18:32:54 (GMT)
commit121481abf8d752ef871821d4ab9a3747595d86ae (patch)
tree6722a6e40e1edeeec7cd4c527a16a51553074130 /read-cache.c
parentd6d3f9d0125a7215f3cdc2600b2307ca55b69536 (diff)
downloadgit-121481abf8d752ef871821d4ab9a3747595d86ae.zip
git-121481abf8d752ef871821d4ab9a3747595d86ae.tar.gz
git-121481abf8d752ef871821d4ab9a3747595d86ae.tar.bz2
Make "update-cache" a bit friendlier to use (and harder to mis-use).
It now requires the "--add" flag before you add any new files, and a "--remove" file if you want to mark files for removal. And giving it the "--refresh" flag makes it just update all the files that it already knows about.
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/read-cache.c b/read-cache.c
index 91b2628..ebace34 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -9,9 +9,13 @@ const char *sha1_file_directory = NULL;
struct cache_entry **active_cache = NULL;
unsigned int active_nr = 0, active_alloc = 0;
-void usage(const char *err)
+void usage(const char *err, ...)
{
- fprintf(stderr, "read-tree: %s\n", err);
+ va_list args;
+
+ va_start(args, err);
+ vfprintf(stderr, err, args);
+ va_end(args);
exit(1);
}
@@ -294,7 +298,7 @@ int remove_file_from_cache(char *path)
return 0;
}
-int add_cache_entry(struct cache_entry *ce)
+int add_cache_entry(struct cache_entry *ce, int ok_to_add)
{
int pos;
@@ -306,6 +310,9 @@ int add_cache_entry(struct cache_entry *ce)
return 0;
}
+ if (!ok_to_add)
+ return -1;
+
/* Make sure the array is big enough .. */
if (active_nr == active_alloc) {
active_alloc = alloc_nr(active_alloc);