Skip to content

Commit

Permalink
builtin-prune: protect objects listed on the command line
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Mar 27, 2008
1 parent 629de47 commit fe308f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions builtin-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion t/t5304-prune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test_expect_success 'prune: prune unreachable heads' '
'

test_expect_failure 'prune: do not prune heads listed as an argument' '
test_expect_success 'prune: do not prune heads listed as an argument' '
: > file2 &&
git add file2 &&
Expand Down

0 comments on commit fe308f5

Please sign in to comment.