Git fork

range-diff: rename other_arg to log_arg

Rename `other_arg` to `log_arg` in `range_diff_options` and
related places.

“Other argument” comes from bd361918 (range-diff: pass through --notes
to `git log`, 2019-11-20) which introduced Git notes handling to
git-range-diff(1) by passing that option on to git-log(1). And that kind
of name might be fine in a local context. However, it was initially
spread among multiple files, and is now[1] part of the
`range_diff_options` struct. It is, prima facie, difficult to guess what
“other” means, especially when just looking at the struct.

But with a little reading we find out that it is used for `--[no-]notes`
and `--diff-merges`, which are both passed on to git-log(1). We should
just rename it to reflect this role; `log_arg` suggests, along with the
`strvec` type, that it is used to pass extra arguments to git-log(1).

† 1: since f1ce6c19 (range-diff: combine all options in a single data
structure, 2021-02-05)

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Kristoffer Haugsbakk and committed by
Junio C Hamano
71fd6c69 ca2559c1

+18 -18
+4 -4
builtin/log.c
··· 1400 1400 * can be added later if deemed desirable. 1401 1401 */ 1402 1402 struct diff_options opts; 1403 - struct strvec other_arg = STRVEC_INIT; 1403 + struct strvec log_arg = STRVEC_INIT; 1404 1404 struct range_diff_options range_diff_opts = { 1405 1405 .creation_factor = rev->creation_factor, 1406 1406 .dual_color = 1, 1407 1407 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 1408 1408 .diffopt = &opts, 1409 - .other_arg = &other_arg 1409 + .log_arg = &log_arg 1410 1410 }; 1411 1411 1412 1412 repo_diff_setup(the_repository, &opts); ··· 1414 1414 opts.use_color = rev->diffopt.use_color; 1415 1415 diff_setup_done(&opts); 1416 1416 fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title); 1417 - get_notes_args(&other_arg, rev); 1417 + get_notes_args(&log_arg, rev); 1418 1418 show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts); 1419 - strvec_clear(&other_arg); 1419 + strvec_clear(&log_arg); 1420 1420 } 1421 1421 } 1422 1422
+8 -8
builtin/range-diff.c
··· 37 37 struct repository *repo UNUSED) 38 38 { 39 39 struct diff_options diffopt = { NULL }; 40 - struct strvec other_arg = STRVEC_INIT; 40 + struct strvec log_arg = STRVEC_INIT; 41 41 struct strvec diff_merges_arg = STRVEC_INIT; 42 42 struct range_diff_options range_diff_opts = { 43 43 .creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT, 44 44 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 45 45 .diffopt = &diffopt, 46 - .other_arg = &other_arg 46 + .log_arg = &log_arg 47 47 }; 48 48 int simple_color = -1, left_only = 0, right_only = 0; 49 49 struct option range_diff_options[] = { ··· 52 52 N_("percentage by which creation is weighted")), 53 53 OPT_BOOL(0, "no-dual-color", &simple_color, 54 54 N_("use simple diff colors")), 55 - OPT_PASSTHRU_ARGV(0, "notes", &other_arg, 55 + OPT_PASSTHRU_ARGV(0, "notes", &log_arg, 56 56 N_("notes"), N_("passed to 'git log'"), 57 57 PARSE_OPT_OPTARG), 58 58 OPT_PASSTHRU_ARGV(0, "diff-merges", &diff_merges_arg, ··· 92 92 /* If `--diff-merges` was specified, imply `--merges` */ 93 93 if (diff_merges_arg.nr) { 94 94 range_diff_opts.include_merges = 1; 95 - strvec_pushv(&other_arg, diff_merges_arg.v); 95 + strvec_pushv(&log_arg, diff_merges_arg.v); 96 96 } 97 97 98 98 for (i = 0; i < argc; i++) ··· 124 124 strbuf_addf(&range1, "%s..%s", argv[0], argv[1]); 125 125 strbuf_addf(&range2, "%s..%s", argv[0], argv[2]); 126 126 127 - strvec_pushv(&other_arg, argv + 127 + strvec_pushv(&log_arg, argv + 128 128 (dash_dash < 0 ? 3 : dash_dash)); 129 129 } else if (dash_dash == 2 || 130 130 (dash_dash < 0 && argc > 1 && ··· 144 144 strbuf_addstr(&range1, argv[0]); 145 145 strbuf_addstr(&range2, argv[1]); 146 146 147 - strvec_pushv(&other_arg, argv + 147 + strvec_pushv(&log_arg, argv + 148 148 (dash_dash < 0 ? 2 : dash_dash)); 149 149 } else if (dash_dash == 1 || 150 150 (dash_dash < 0 && argc > 0 && ··· 175 175 strbuf_addf(&range1, "%s..%.*s", b, a_len, a); 176 176 strbuf_addf(&range2, "%.*s..%s", a_len, a, b); 177 177 178 - strvec_pushv(&other_arg, argv + 178 + strvec_pushv(&log_arg, argv + 179 179 (dash_dash < 0 ? 1 : dash_dash)); 180 180 } else 181 181 usage_msg_opt(_("need two commit ranges"), ··· 187 187 range_diff_opts.right_only = right_only; 188 188 res = show_range_diff(range1.buf, range2.buf, &range_diff_opts); 189 189 190 - strvec_clear(&other_arg); 190 + strvec_clear(&log_arg); 191 191 strvec_clear(&diff_merges_arg); 192 192 strbuf_release(&range1); 193 193 strbuf_release(&range2);
+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 /*