Skip to content

Commit 85bd88a

Browse files
LemmingAvalanchegitster
authored andcommitted
revision: add rdiff_log_arg to rev_info
git-format-patch(1) supports Git notes by showing them beneath the patch/commit message, similar to git-log(1). The command also supports showing those same notes ref names in the range diff output. Note *the same* ref names; any Git notes options or configuration variables need to be handed off to the range-diff machinery. This works correctly in the case when the range diff is on the cover letter. But it does not work correctly when the output is a single patch with an embedded range diff. Concretely, git-format-patch(1) needs to pass `--[no-]notes` options on to the range-diff subprocess in `range-diff.c`. This is handled in `builtin/log.c` by the local variable `log_arg` in the case of mul- tiple commits, but not in the single commit case where there is no cover letter and the range diff is embedded in the patch output; the range diff is then made in `log-tree.c`, whither `log_arg` has not been propagated. This means that the range-diff subprocess reverts to its default behavior, which is to act like git-log(1) w.r.t. notes. We need to fix this. But first lay the groundwork by converting `log_arg` to a struct member; next we can simply use that member in `log-tree.c` without having to thread it from `builtin/log.c`. No functional changes. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Kristoffer Haugsbakk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71fd6c6 commit 85bd88a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin/log.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,23 +1400,20 @@ 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 log_arg = STRVEC_INIT;
14041403
struct range_diff_options range_diff_opts = {
14051404
.creation_factor = rev->creation_factor,
14061405
.dual_color = 1,
14071406
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
14081407
.diffopt = &opts,
1409-
.log_arg = &log_arg
1408+
.log_arg = &rev->rdiff_log_arg
14101409
};
14111410

14121411
repo_diff_setup(the_repository, &opts);
14131412
opts.file = rev->diffopt.file;
14141413
opts.use_color = rev->diffopt.use_color;
14151414
diff_setup_done(&opts);
14161415
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
1417-
get_notes_args(&log_arg, rev);
14181416
show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts);
1419-
strvec_clear(&log_arg);
14201417
}
14211418
}
14221419

@@ -2328,6 +2325,7 @@ int cmd_format_patch(int argc,
23282325
rev.rdiff_title = diff_title(&rdiff_title, reroll_count,
23292326
_("Range-diff:"),
23302327
_("Range-diff against v%d:"));
2328+
get_notes_args(&(rev.rdiff_log_arg), &rev);
23312329
}
23322330

23332331
/*
@@ -2487,6 +2485,7 @@ int cmd_format_patch(int argc,
24872485
rev.diffopt.no_free = 0;
24882486
release_revisions(&rev);
24892487
format_config_release(&cfg);
2488+
strvec_clear(&rev.rdiff_log_arg);
24902489
return 0;
24912490
}
24922491

revision.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ struct rev_info {
334334
/* range-diff */
335335
const char *rdiff1;
336336
const char *rdiff2;
337+
struct strvec rdiff_log_arg;
337338
int creation_factor;
338339
const char *rdiff_title;
339340

@@ -410,6 +411,7 @@ struct rev_info {
410411
.expand_tabs_in_log = -1, \
411412
.commit_format = CMIT_FMT_DEFAULT, \
412413
.expand_tabs_in_log_default = 8, \
414+
.rdiff_log_arg = STRVEC_INIT, \
413415
}
414416

415417
/**

0 commit comments

Comments
 (0)