From a9f2adff802308481f2e638bae0c5b6e205251a3 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 May 2010 23:42:07 +0200 Subject: notes: dry-run and verbose options for prune Introduce -n and -v options for "git notes prune" in complete analogy to "git prune" so that one can check for dangling notes easily. The output is a list of names of objects whose notes would be resp. are removed so that one can check the object ("git show sha1") as well as the note ("git notes show sha1"). Signed-off-by: Michael J Gruber Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- builtin/notes.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/notes.c b/builtin/notes.c index 52b72fca6..ba8fd178c 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -26,7 +26,7 @@ static const char * const git_notes_usage[] = { "git notes [--ref ] edit []", "git notes [--ref ] show []", "git notes [--ref ] remove []", - "git notes [--ref ] prune", + "git notes [--ref ] prune [-n | -v]", NULL }; @@ -67,7 +67,7 @@ static const char * const git_notes_remove_usage[] = { }; static const char * const git_notes_prune_usage[] = { - "git notes prune", + "git notes prune []", NULL }; @@ -792,7 +792,10 @@ static int remove_cmd(int argc, const char **argv, const char *prefix) static int prune(int argc, const char **argv, const char *prefix) { struct notes_tree *t; + int show_only = 0, verbose = 0; struct option options[] = { + OPT_BOOLEAN('n', NULL, &show_only, "do not remove, show only"), + OPT_BOOLEAN('v', NULL, &verbose, "report pruned notes"), OPT_END() }; @@ -806,8 +809,10 @@ static int prune(int argc, const char **argv, const char *prefix) t = init_notes_check("prune"); - prune_notes(t); - commit_notes(t, "Notes removed by 'git notes prune'"); + prune_notes(t, (verbose ? NOTES_PRUNE_VERBOSE : 0) | + (show_only ? NOTES_PRUNE_VERBOSE|NOTES_PRUNE_DRYRUN : 0) ); + if (!show_only) + commit_notes(t, "Notes removed by 'git notes prune'"); free_notes(t); return 0; } -- cgit v1.2.1