]> Pileus Git - ~andy/git/commitdiff
revision.c: make --no-notes reset --notes list
authorJeff King <peff@peff.net>
Tue, 29 Mar 2011 20:59:42 +0000 (16:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Mar 2011 21:39:24 +0000 (14:39 -0700)
With most command line options, later instances of an option
override earlier ones. With cumulative options like
"--notes", however, there is no way to say "forget the
--notes I gave you before".

Let's have --no-notes trigger this forgetting, so that:

  git log --notes=foo --no-notes --notes=bar

will show only the "bar" notes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c
t/t3301-notes.sh

index c4ffee4649be7a87c03099bd3815a2a29c861986..541f09e218ae35c0784a59cea477e87c32bf3a23 100644 (file)
@@ -1389,6 +1389,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
        } else if (!strcmp(arg, "--no-notes")) {
                revs->show_notes = 0;
                revs->show_notes_given = 1;
+               revs->notes_opt.use_default_notes = -1;
+               /* we have been strdup'ing ourselves, so trick
+                * string_list into free()ing strings */
+               revs->notes_opt.extra_notes_refs.strdup_strings = 1;
+               string_list_clear(&revs->notes_opt.extra_notes_refs, 0);
+               revs->notes_opt.extra_notes_refs.strdup_strings = 0;
        } else if (!strcmp(arg, "--standard-notes")) {
                revs->show_notes_given = 1;
                revs->notes_opt.use_default_notes = 1;
index f0e7a581237a775443d720211032a7a3504876cf..8600db7edb5c73beb56a9059fa222ce4170d2a7f 100755 (executable)
@@ -269,6 +269,22 @@ test_expect_success 'git log --notes --notes=X shows both' '
        grep alternate output
 '
 
+test_expect_success 'git log --no-notes resets default state' '
+       git log -1 --notes --notes=alternate \
+               --no-notes --notes=alternate \
+               >output &&
+       ! grep xyzzy output &&
+       grep alternate output
+'
+
+test_expect_success 'git log --no-notes resets ref list' '
+       git log -1 --notes --notes=alternate \
+               --no-notes --notes \
+               >output &&
+       grep xyzzy output &&
+       ! grep alternate output
+'
+
 test_expect_success 'create -m notes (setup)' '
        : > a5 &&
        git add a5 &&