Git fork

Merge branch 'kh/format-patch-range-diff-notes'

"git format-patch --range-diff=... --notes=..." did not drive the
underlying range-diff with correct --notes parameter, ending up
comparing with different set of notes from its main patch output
you would get from "git format-patch --notes=..." for a singleton
patch.

* kh/format-patch-range-diff-notes:
format-patch: handle range-diff on notes correctly for single patches
revision: add rdiff_log_arg to rev_info
range-diff: rename other_arg to log_arg

+36 -20
+3 -4
builtin/log.c
··· 1406 1406 * can be added later if deemed desirable. 1407 1407 */ 1408 1408 struct diff_options opts; 1409 - struct strvec other_arg = STRVEC_INIT; 1410 1409 struct range_diff_options range_diff_opts = { 1411 1410 .creation_factor = rev->creation_factor, 1412 1411 .dual_color = 1, 1413 1412 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 1414 1413 .diffopt = &opts, 1415 - .other_arg = &other_arg 1414 + .log_arg = &rev->rdiff_log_arg 1416 1415 }; 1417 1416 1418 1417 repo_diff_setup(the_repository, &opts); ··· 1420 1419 opts.use_color = rev->diffopt.use_color; 1421 1420 diff_setup_done(&opts); 1422 1421 fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title); 1423 - get_notes_args(&other_arg, rev); 1424 1422 show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts); 1425 - strvec_clear(&other_arg); 1426 1423 } 1427 1424 } 1428 1425 ··· 2334 2331 rev.rdiff_title = diff_title(&rdiff_title, reroll_count, 2335 2332 _("Range-diff:"), 2336 2333 _("Range-diff against v%d:")); 2334 + get_notes_args(&(rev.rdiff_log_arg), &rev); 2337 2335 } 2338 2336 2339 2337 /* ··· 2493 2491 rev.diffopt.no_free = 0; 2494 2492 release_revisions(&rev); 2495 2493 format_config_release(&cfg); 2494 + strvec_clear(&rev.rdiff_log_arg); 2496 2495 return 0; 2497 2496 } 2498 2497
+8 -8
builtin/range-diff.c
··· 38 38 struct repository *repo UNUSED) 39 39 { 40 40 struct diff_options diffopt = { NULL }; 41 - struct strvec other_arg = STRVEC_INIT; 41 + struct strvec log_arg = STRVEC_INIT; 42 42 struct strvec diff_merges_arg = STRVEC_INIT; 43 43 struct range_diff_options range_diff_opts = { 44 44 .creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT, 45 45 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 46 46 .diffopt = &diffopt, 47 - .other_arg = &other_arg 47 + .log_arg = &log_arg 48 48 }; 49 49 int simple_color = -1, left_only = 0, right_only = 0; 50 50 struct option range_diff_options[] = { ··· 53 53 N_("percentage by which creation is weighted")), 54 54 OPT_BOOL(0, "no-dual-color", &simple_color, 55 55 N_("use simple diff colors")), 56 - OPT_PASSTHRU_ARGV(0, "notes", &other_arg, 56 + OPT_PASSTHRU_ARGV(0, "notes", &log_arg, 57 57 N_("notes"), N_("passed to 'git log'"), 58 58 PARSE_OPT_OPTARG), 59 59 OPT_PASSTHRU_ARGV(0, "diff-merges", &diff_merges_arg, ··· 93 93 /* If `--diff-merges` was specified, imply `--merges` */ 94 94 if (diff_merges_arg.nr) { 95 95 range_diff_opts.include_merges = 1; 96 - strvec_pushv(&other_arg, diff_merges_arg.v); 96 + strvec_pushv(&log_arg, diff_merges_arg.v); 97 97 } 98 98 99 99 for (i = 0; i < argc; i++) ··· 125 125 strbuf_addf(&range1, "%s..%s", argv[0], argv[1]); 126 126 strbuf_addf(&range2, "%s..%s", argv[0], argv[2]); 127 127 128 - strvec_pushv(&other_arg, argv + 128 + strvec_pushv(&log_arg, argv + 129 129 (dash_dash < 0 ? 3 : dash_dash)); 130 130 } else if (dash_dash == 2 || 131 131 (dash_dash < 0 && argc > 1 && ··· 145 145 strbuf_addstr(&range1, argv[0]); 146 146 strbuf_addstr(&range2, argv[1]); 147 147 148 - strvec_pushv(&other_arg, argv + 148 + strvec_pushv(&log_arg, argv + 149 149 (dash_dash < 0 ? 2 : dash_dash)); 150 150 } else if (dash_dash == 1 || 151 151 (dash_dash < 0 && argc > 0 && ··· 176 176 strbuf_addf(&range1, "%s..%.*s", b, a_len, a); 177 177 strbuf_addf(&range2, "%.*s..%s", a_len, a, b); 178 178 179 - strvec_pushv(&other_arg, argv + 179 + strvec_pushv(&log_arg, argv + 180 180 (dash_dash < 0 ? 1 : dash_dash)); 181 181 } else 182 182 usage_msg_opt(_("need two commit ranges"), ··· 188 188 range_diff_opts.right_only = right_only; 189 189 res = show_range_diff(range1.buf, range2.buf, &range_diff_opts); 190 190 191 - strvec_clear(&other_arg); 191 + strvec_clear(&log_arg); 192 192 strvec_clear(&diff_merges_arg); 193 193 strbuf_release(&range1); 194 194 strbuf_release(&range2);
+2 -1
log-tree.c
··· 718 718 .creation_factor = opt->creation_factor, 719 719 .dual_color = 1, 720 720 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 721 - .diffopt = &opts 721 + .diffopt = &opts, 722 + .log_arg = &opt->rdiff_log_arg 722 723 }; 723 724 724 725 memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
+5 -5
range-diff.c
··· 39 39 * as struct object_id (will need to be free()d). 40 40 */ 41 41 static int read_patches(const char *range, struct string_list *list, 42 - const struct strvec *other_arg, 42 + const struct strvec *log_arg, 43 43 unsigned int include_merges) 44 44 { 45 45 struct child_process cp = CHILD_PROCESS_INIT; ··· 69 69 if (!include_merges) 70 70 strvec_push(&cp.args, "--no-merges"); 71 71 strvec_push(&cp.args, range); 72 - if (other_arg) 73 - strvec_pushv(&cp.args, other_arg->v); 72 + if (log_arg) 73 + strvec_pushv(&cp.args, log_arg->v); 74 74 cp.out = -1; 75 75 cp.no_stdin = 1; 76 76 cp.git_cmd = 1; ··· 594 594 if (range_diff_opts->left_only && range_diff_opts->right_only) 595 595 res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only"); 596 596 597 - if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg, include_merges)) 597 + if (!res && read_patches(range1, &branch1, range_diff_opts->log_arg, include_merges)) 598 598 res = error(_("could not parse log for '%s'"), range1); 599 - if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg, include_merges)) 599 + if (!res && read_patches(range2, &branch2, range_diff_opts->log_arg, include_merges)) 600 600 res = error(_("could not parse log for '%s'"), range2); 601 601 602 602 if (!res) {
+1 -1
range-diff.h
··· 23 23 unsigned include_merges:1; 24 24 size_t max_memory; 25 25 const struct diff_options *diffopt; /* may be NULL */ 26 - const struct strvec *other_arg; /* may be NULL */ 26 + const struct strvec *log_arg; /* may be NULL */ 27 27 }; 28 28 29 29 /*
+2
revision.h
··· 334 334 /* range-diff */ 335 335 const char *rdiff1; 336 336 const char *rdiff2; 337 + struct strvec rdiff_log_arg; 337 338 int creation_factor; 338 339 const char *rdiff_title; 339 340 ··· 410 411 .expand_tabs_in_log = -1, \ 411 412 .commit_format = CMIT_FMT_DEFAULT, \ 412 413 .expand_tabs_in_log_default = 8, \ 414 + .rdiff_log_arg = STRVEC_INIT, \ 413 415 } 414 416 415 417 /**
+15 -1
t/t3206-range-diff.sh
··· 707 707 ! grep "note" 0000-* 708 708 ' 709 709 710 - test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' ' 710 + test_expect_success 'format-patch --notes=custom --range-diff --cover-letter only compares custom notes' ' 711 711 test_when_finished "git notes remove topic unmodified || :" && 712 712 git notes add -m "topic note" topic && 713 713 git notes add -m "unmodified note" unmodified && ··· 719 719 main..unmodified >actual && 720 720 grep "## Notes (custom) ##" 0000-* && 721 721 ! grep "## Notes ##" 0000-* 722 + ' 723 + 724 + # --range-diff on a single commit requires --no-cover-letter 725 + test_expect_success 'format-patch --notes=custom --range-diff on single commit only compares custom notes' ' 726 + test_when_finished "git notes remove HEAD unmodified || :" && 727 + git notes add -m "topic note" HEAD && 728 + test_when_finished "git notes --ref=custom remove HEAD unmodified || :" && 729 + git notes add -m "unmodified note" unmodified && 730 + git notes --ref=custom add -m "topic note (custom)" HEAD && 731 + git notes --ref=custom add -m "unmodified note (custom)" unmodified && 732 + git format-patch --notes=custom --range-diff=$prev \ 733 + -1 --stdout >actual && 734 + test_grep "## Notes (custom) ##" actual && 735 + test_grep ! "## Notes ##" actual 722 736 ' 723 737 724 738 test_expect_success 'format-patch --range-diff with --no-notes' '