[PATCH 6/6] revision.c: make --no-notes reset --notes list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
Technically this is a regression for:

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

which used to show both. But I consider that behavior useless and crazy,
and since the --no-notes actually did nothing there, why would anyone
have been using it?

 revision.c       |    6 ++++++
 t/t3301-notes.sh |   16 ++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/revision.c b/revision.c
index c4ffee4..541f09e 100644
--- a/revision.c
+++ b/revision.c
@@ -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;
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index f0e7a58..8600db7 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -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 &&
-- 
1.7.4.2.7.g9407
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]