summaryrefslogtreecommitdiff
path: root/builtin-prune.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-03-25 06:20:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-03-27 22:39:57 (GMT)
commitfe308f53730f168be65c57c46e5c573b449b3e32 (patch)
treecfadcf52fb96445c230f4e60bd77d7cc39a21b73 /builtin-prune.c
parent629de472b67bdb6b1fbdc72a95e1f569e3b8f02d (diff)
downloadgit-fe308f53730f168be65c57c46e5c573b449b3e32.zip
git-fe308f53730f168be65c57c46e5c573b449b3e32.tar.gz
git-fe308f53730f168be65c57c46e5c573b449b3e32.tar.bz2
builtin-prune: protect objects listed on the command line
Finally, this resurrects the documented behaviour to protect other objects listed on the command line from getting pruned. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-prune.c')
-rw-r--r--builtin-prune.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/builtin-prune.c b/builtin-prune.c
index 71caac5..25f9304 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -140,8 +140,19 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
init_revisions(&revs, prefix);
argc = parse_options(argc, argv, options, prune_usage, 0);
- if (argc)
- die ("unrecognized argument: %s", name);
+ while (argc--) {
+ unsigned char sha1[20];
+ const char *name = *argv++;
+
+ if (!get_sha1(name, sha1)) {
+ struct object *object = parse_object(sha1);
+ if (!object)
+ die("bad object: %s", name);
+ add_pending_object(&revs, object, "");
+ }
+ else
+ die("unrecognized argument: %s", name);
+ }
mark_reachable_objects(&revs, 1);
prune_object_dir(get_object_directory());