@matheusbsbs / matheus-bagliano / commits / 92e0d42539
Fork 0

revision.c: make --no-notes reset --notes list

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>

Jeff King committed Mar 29, 2011 at 16:59 UTC 92e0d42539a34e90f5c9bf29eb741f0d87173027
2 files changed +22
revision.c
+6
@@ -1389,6 +1389,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1389 } else if (!strcmp(arg, "--no-notes")) {
1390 revs->show_notes = 0;
1391 revs->show_notes_given = 1;
1392 + revs->notes_opt.use_default_notes = -1;
1393 + /* we have been strdup'ing ourselves, so trick
1394 + * string_list into free()ing strings */
1395 + revs->notes_opt.extra_notes_refs.strdup_strings = 1;
1396 + string_list_clear(&revs->notes_opt.extra_notes_refs, 0);
1397 + revs->notes_opt.extra_notes_refs.strdup_strings = 0;
1398 } else if (!strcmp(arg, "--standard-notes")) {
1399 revs->show_notes_given = 1;
1400 revs->notes_opt.use_default_notes = 1;
t/t3301-notes.sh
+16
@@ -269,6 +269,22 @@ test_expect_success 'git log --notes --notes=X shows both' '
269 grep alternate output
270 '
271
272 +test_expect_success 'git log --no-notes resets default state' '
273 + git log -1 --notes --notes=alternate \
274 + --no-notes --notes=alternate \
275 + >output &&
276 + ! grep xyzzy output &&
277 + grep alternate output
278 +'
279 +
280 +test_expect_success 'git log --no-notes resets ref list' '
281 + git log -1 --notes --notes=alternate \
282 + --no-notes --notes \
283 + >output &&
284 + grep xyzzy output &&
285 + ! grep alternate output
286 +'
287 +
288 test_expect_success 'create -m notes (setup)' '
289 : > a5 &&
290 git add a5 &&