From: Junio C Hamano Date: Tue, 29 Jun 2010 00:42:26 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.7.2-rc1~14 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1ba5c532e1f6ede63fd46bf6b647e70baa10a364?hp=-c Merge branch 'maint' * maint: Update draft release notes to 1.7.1.1 notes: Initialise variable to appease gcc notes: check number of parameters to "git notes copy" --- 1ba5c532e1f6ede63fd46bf6b647e70baa10a364 diff --combined builtin/notes.c index f1f53a80e1,f678f9cb52..190005f3cd --- a/builtin/notes.c +++ b/builtin/notes.c @@@ -26,7 -26,7 +26,7 @@@ static const char * const git_notes_usa "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 +67,7 @@@ static const char * const git_notes_rem }; static const char * const git_notes_prune_usage[] = { - "git notes prune", + "git notes prune []", NULL }; @@@ -614,6 -614,10 +614,10 @@@ static int copy(int argc, const char ** } } + if (argc < 2) { + error("too few parameters"); + usage_with_options(git_notes_copy_usage, options); + } if (2 < argc) { error("too many parameters"); usage_with_options(git_notes_copy_usage, options); @@@ -792,10 -796,7 +796,10 @@@ static int remove_cmd(int argc, const c 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() }; @@@ -809,10 -810,8 +813,10 @@@ 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; } diff --combined notes.c index 6ee04e79e9,cc92cf351a..30d6ded78e --- a/notes.c +++ b/notes.c @@@ -716,7 -716,7 +716,7 @@@ static int write_each_non_note_until(co struct write_each_note_data *d) { struct non_note *n = d->next_non_note; - int cmp, ret; + int cmp = 0, ret; while (n && (!note_path || (cmp = strcmp(n->path, note_path)) <= 0)) { if (note_path && cmp == 0) ; /* do nothing, prefer note to non-note */ @@@ -1083,7 -1083,7 +1083,7 @@@ int write_notes_tree(struct notes_tree return ret; } -void prune_notes(struct notes_tree *t) +void prune_notes(struct notes_tree *t, int flags) { struct note_delete_list *l = NULL; @@@ -1094,10 -1094,7 +1094,10 @@@ for_each_note(t, 0, prune_notes_helper, &l); while (l) { - remove_note(t, l->sha1); + if (flags & NOTES_PRUNE_VERBOSE) + printf("%s\n", sha1_to_hex(l->sha1)); + if (!(flags & NOTES_PRUNE_DRYRUN)) + remove_note(t, l->sha1); l = l->next; } }