Skip to content

Commit 71fd6c6

Browse files
LemmingAvalanchegitster
authored andcommitted
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 bd36191 (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 f1ce6c1 (range-diff: combine all options in a single data structure, 2021-02-05) Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Kristoffer Haugsbakk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca2559c commit 71fd6c6

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

builtin/log.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,23 +1400,23 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
14001400
* can be added later if deemed desirable.
14011401
*/
14021402
struct diff_options opts;
1403-
struct strvec other_arg = STRVEC_INIT;
1403+
struct strvec log_arg = STRVEC_INIT;
14041404
struct range_diff_options range_diff_opts = {
14051405
.creation_factor = rev->creation_factor,
14061406
.dual_color = 1,
14071407
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
14081408
.diffopt = &opts,
1409-
.other_arg = &other_arg
1409+
.log_arg = &log_arg
14101410
};
14111411

14121412
repo_diff_setup(the_repository, &opts);
14131413
opts.file = rev->diffopt.file;
14141414
opts.use_color = rev->diffopt.use_color;
14151415
diff_setup_done(&opts);
14161416
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
1417-
get_notes_args(&other_arg, rev);
1417+
get_notes_args(&log_arg, rev);
14181418
show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts);
1419-
strvec_clear(&other_arg);
1419+
strvec_clear(&log_arg);
14201420
}
14211421
}
14221422

builtin/range-diff.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ int cmd_range_diff(int argc,
3737
struct repository *repo UNUSED)
3838
{
3939
struct diff_options diffopt = { NULL };
40-
struct strvec other_arg = STRVEC_INIT;
40+
struct strvec log_arg = STRVEC_INIT;
4141
struct strvec diff_merges_arg = STRVEC_INIT;
4242
struct range_diff_options range_diff_opts = {
4343
.creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT,
4444
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
4545
.diffopt = &diffopt,
46-
.other_arg = &other_arg
46+
.log_arg = &log_arg
4747
};
4848
int simple_color = -1, left_only = 0, right_only = 0;
4949
struct option range_diff_options[] = {
@@ -52,7 +52,7 @@ int cmd_range_diff(int argc,
5252
N_("percentage by which creation is weighted")),
5353
OPT_BOOL(0, "no-dual-color", &simple_color,
5454
N_("use simple diff colors")),
55-
OPT_PASSTHRU_ARGV(0, "notes", &other_arg,
55+
OPT_PASSTHRU_ARGV(0, "notes", &log_arg,
5656
N_("notes"), N_("passed to 'git log'"),
5757
PARSE_OPT_OPTARG),
5858
OPT_PASSTHRU_ARGV(0, "diff-merges", &diff_merges_arg,
@@ -92,7 +92,7 @@ int cmd_range_diff(int argc,
9292
/* If `--diff-merges` was specified, imply `--merges` */
9393
if (diff_merges_arg.nr) {
9494
range_diff_opts.include_merges = 1;
95-
strvec_pushv(&other_arg, diff_merges_arg.v);
95+
strvec_pushv(&log_arg, diff_merges_arg.v);
9696
}
9797

9898
for (i = 0; i < argc; i++)
@@ -124,7 +124,7 @@ int cmd_range_diff(int argc,
124124
strbuf_addf(&range1, "%s..%s", argv[0], argv[1]);
125125
strbuf_addf(&range2, "%s..%s", argv[0], argv[2]);
126126

127-
strvec_pushv(&other_arg, argv +
127+
strvec_pushv(&log_arg, argv +
128128
(dash_dash < 0 ? 3 : dash_dash));
129129
} else if (dash_dash == 2 ||
130130
(dash_dash < 0 && argc > 1 &&
@@ -144,7 +144,7 @@ int cmd_range_diff(int argc,
144144
strbuf_addstr(&range1, argv[0]);
145145
strbuf_addstr(&range2, argv[1]);
146146

147-
strvec_pushv(&other_arg, argv +
147+
strvec_pushv(&log_arg, argv +
148148
(dash_dash < 0 ? 2 : dash_dash));
149149
} else if (dash_dash == 1 ||
150150
(dash_dash < 0 && argc > 0 &&
@@ -175,7 +175,7 @@ int cmd_range_diff(int argc,
175175
strbuf_addf(&range1, "%s..%.*s", b, a_len, a);
176176
strbuf_addf(&range2, "%.*s..%s", a_len, a, b);
177177

178-
strvec_pushv(&other_arg, argv +
178+
strvec_pushv(&log_arg, argv +
179179
(dash_dash < 0 ? 1 : dash_dash));
180180
} else
181181
usage_msg_opt(_("need two commit ranges"),
@@ -187,7 +187,7 @@ int cmd_range_diff(int argc,
187187
range_diff_opts.right_only = right_only;
188188
res = show_range_diff(range1.buf, range2.buf, &range_diff_opts);
189189

190-
strvec_clear(&other_arg);
190+
strvec_clear(&log_arg);
191191
strvec_clear(&diff_merges_arg);
192192
strbuf_release(&range1);
193193
strbuf_release(&range2);

range-diff.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct patch_util {
3939
* as struct object_id (will need to be free()d).
4040
*/
4141
static int read_patches(const char *range, struct string_list *list,
42-
const struct strvec *other_arg,
42+
const struct strvec *log_arg,
4343
unsigned int include_merges)
4444
{
4545
struct child_process cp = CHILD_PROCESS_INIT;
@@ -69,8 +69,8 @@ static int read_patches(const char *range, struct string_list *list,
6969
if (!include_merges)
7070
strvec_push(&cp.args, "--no-merges");
7171
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);
7474
cp.out = -1;
7575
cp.no_stdin = 1;
7676
cp.git_cmd = 1;
@@ -594,9 +594,9 @@ int show_range_diff(const char *range1, const char *range2,
594594
if (range_diff_opts->left_only && range_diff_opts->right_only)
595595
res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only");
596596

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))
598598
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))
600600
res = error(_("could not parse log for '%s'"), range2);
601601

602602
if (!res) {

range-diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct range_diff_options {
2323
unsigned include_merges:1;
2424
size_t max_memory;
2525
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 */
2727
};
2828

2929
/*

0 commit comments

Comments
 (0)