summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/log.c7
-rw-r--r--builtin/range-diff.c16
-rw-r--r--log-tree.c3
-rw-r--r--range-diff.c10
-rw-r--r--range-diff.h2
-rw-r--r--revision.h2
-rwxr-xr-xt/t3206-range-diff.sh16
7 files changed, 36 insertions, 20 deletions
diff --git a/builtin/log.c b/builtin/log.c
index 8aa1777940..c8319b8af3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1406,13 +1406,12 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
* can be added later if deemed desirable.
*/
struct diff_options opts;
- struct strvec other_arg = STRVEC_INIT;
struct range_diff_options range_diff_opts = {
.creation_factor = rev->creation_factor,
.dual_color = 1,
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
.diffopt = &opts,
- .other_arg = &other_arg
+ .log_arg = &rev->rdiff_log_arg
};
repo_diff_setup(the_repository, &opts);
@@ -1420,9 +1419,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
opts.use_color = rev->diffopt.use_color;
diff_setup_done(&opts);
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
- get_notes_args(&other_arg, rev);
show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts);
- strvec_clear(&other_arg);
}
}
@@ -2334,6 +2331,7 @@ int cmd_format_patch(int argc,
rev.rdiff_title = diff_title(&rdiff_title, reroll_count,
_("Range-diff:"),
_("Range-diff against v%d:"));
+ get_notes_args(&(rev.rdiff_log_arg), &rev);
}
/*
@@ -2493,6 +2491,7 @@ done:
rev.diffopt.no_free = 0;
release_revisions(&rev);
format_config_release(&cfg);
+ strvec_clear(&rev.rdiff_log_arg);
return 0;
}
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 1bc082a869..e54c0f7fe1 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -38,13 +38,13 @@ int cmd_range_diff(int argc,
struct repository *repo UNUSED)
{
struct diff_options diffopt = { NULL };
- struct strvec other_arg = STRVEC_INIT;
+ struct strvec log_arg = STRVEC_INIT;
struct strvec diff_merges_arg = STRVEC_INIT;
struct range_diff_options range_diff_opts = {
.creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT,
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
.diffopt = &diffopt,
- .other_arg = &other_arg
+ .log_arg = &log_arg
};
int simple_color = -1, left_only = 0, right_only = 0;
struct option range_diff_options[] = {
@@ -53,7 +53,7 @@ int cmd_range_diff(int argc,
N_("percentage by which creation is weighted")),
OPT_BOOL(0, "no-dual-color", &simple_color,
N_("use simple diff colors")),
- OPT_PASSTHRU_ARGV(0, "notes", &other_arg,
+ OPT_PASSTHRU_ARGV(0, "notes", &log_arg,
N_("notes"), N_("passed to 'git log'"),
PARSE_OPT_OPTARG),
OPT_PASSTHRU_ARGV(0, "diff-merges", &diff_merges_arg,
@@ -93,7 +93,7 @@ int cmd_range_diff(int argc,
/* If `--diff-merges` was specified, imply `--merges` */
if (diff_merges_arg.nr) {
range_diff_opts.include_merges = 1;
- strvec_pushv(&other_arg, diff_merges_arg.v);
+ strvec_pushv(&log_arg, diff_merges_arg.v);
}
for (i = 0; i < argc; i++)
@@ -125,7 +125,7 @@ int cmd_range_diff(int argc,
strbuf_addf(&range1, "%s..%s", argv[0], argv[1]);
strbuf_addf(&range2, "%s..%s", argv[0], argv[2]);
- strvec_pushv(&other_arg, argv +
+ strvec_pushv(&log_arg, argv +
(dash_dash < 0 ? 3 : dash_dash));
} else if (dash_dash == 2 ||
(dash_dash < 0 && argc > 1 &&
@@ -145,7 +145,7 @@ int cmd_range_diff(int argc,
strbuf_addstr(&range1, argv[0]);
strbuf_addstr(&range2, argv[1]);
- strvec_pushv(&other_arg, argv +
+ strvec_pushv(&log_arg, argv +
(dash_dash < 0 ? 2 : dash_dash));
} else if (dash_dash == 1 ||
(dash_dash < 0 && argc > 0 &&
@@ -176,7 +176,7 @@ int cmd_range_diff(int argc,
strbuf_addf(&range1, "%s..%.*s", b, a_len, a);
strbuf_addf(&range2, "%.*s..%s", a_len, a, b);
- strvec_pushv(&other_arg, argv +
+ strvec_pushv(&log_arg, argv +
(dash_dash < 0 ? 1 : dash_dash));
} else
usage_msg_opt(_("need two commit ranges"),
@@ -188,7 +188,7 @@ int cmd_range_diff(int argc,
range_diff_opts.right_only = right_only;
res = show_range_diff(range1.buf, range2.buf, &range_diff_opts);
- strvec_clear(&other_arg);
+ strvec_clear(&log_arg);
strvec_clear(&diff_merges_arg);
strbuf_release(&range1);
strbuf_release(&range2);
diff --git a/log-tree.c b/log-tree.c
index 67d9ace596..7d917f2a83 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -718,7 +718,8 @@ static void show_diff_of_diff(struct rev_info *opt)
.creation_factor = opt->creation_factor,
.dual_color = 1,
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
- .diffopt = &opts
+ .diffopt = &opts,
+ .log_arg = &opt->rdiff_log_arg
};
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
diff --git a/range-diff.c b/range-diff.c
index ca449a0769..57edff40a8 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -39,7 +39,7 @@ struct patch_util {
* as struct object_id (will need to be free()d).
*/
static int read_patches(const char *range, struct string_list *list,
- const struct strvec *other_arg,
+ const struct strvec *log_arg,
unsigned int include_merges)
{
struct child_process cp = CHILD_PROCESS_INIT;
@@ -69,8 +69,8 @@ static int read_patches(const char *range, struct string_list *list,
if (!include_merges)
strvec_push(&cp.args, "--no-merges");
strvec_push(&cp.args, range);
- if (other_arg)
- strvec_pushv(&cp.args, other_arg->v);
+ if (log_arg)
+ strvec_pushv(&cp.args, log_arg->v);
cp.out = -1;
cp.no_stdin = 1;
cp.git_cmd = 1;
@@ -594,9 +594,9 @@ int show_range_diff(const char *range1, const char *range2,
if (range_diff_opts->left_only && range_diff_opts->right_only)
res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only");
- if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg, include_merges))
+ if (!res && read_patches(range1, &branch1, range_diff_opts->log_arg, include_merges))
res = error(_("could not parse log for '%s'"), range1);
- if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg, include_merges))
+ if (!res && read_patches(range2, &branch2, range_diff_opts->log_arg, include_merges))
res = error(_("could not parse log for '%s'"), range2);
if (!res) {
diff --git a/range-diff.h b/range-diff.h
index 9d39818e34..9b70a80009 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -23,7 +23,7 @@ struct range_diff_options {
unsigned include_merges:1;
size_t max_memory;
const struct diff_options *diffopt; /* may be NULL */
- const struct strvec *other_arg; /* may be NULL */
+ const struct strvec *log_arg; /* may be NULL */
};
/*
diff --git a/revision.h b/revision.h
index a28e349044..b36acfc2d9 100644
--- a/revision.h
+++ b/revision.h
@@ -334,6 +334,7 @@ struct rev_info {
/* range-diff */
const char *rdiff1;
const char *rdiff2;
+ struct strvec rdiff_log_arg;
int creation_factor;
const char *rdiff_title;
@@ -410,6 +411,7 @@ struct rev_info {
.expand_tabs_in_log = -1, \
.commit_format = CMIT_FMT_DEFAULT, \
.expand_tabs_in_log_default = 8, \
+ .rdiff_log_arg = STRVEC_INIT, \
}
/**
diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index e091df6d01..1e812df806 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -707,7 +707,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
! grep "note" 0000-*
'
-test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
+test_expect_success 'format-patch --notes=custom --range-diff --cover-letter only compares custom notes' '
test_when_finished "git notes remove topic unmodified || :" &&
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
@@ -721,6 +721,20 @@ test_expect_success 'format-patch --notes=custom --range-diff only compares cust
! grep "## Notes ##" 0000-*
'
+# --range-diff on a single commit requires --no-cover-letter
+test_expect_success 'format-patch --notes=custom --range-diff on single commit only compares custom notes' '
+ test_when_finished "git notes remove HEAD unmodified || :" &&
+ git notes add -m "topic note" HEAD &&
+ test_when_finished "git notes --ref=custom remove HEAD unmodified || :" &&
+ git notes add -m "unmodified note" unmodified &&
+ git notes --ref=custom add -m "topic note (custom)" HEAD &&
+ git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
+ git format-patch --notes=custom --range-diff=$prev \
+ -1 --stdout >actual &&
+ test_grep "## Notes (custom) ##" actual &&
+ test_grep ! "## Notes ##" actual
+'
+
test_expect_success 'format-patch --range-diff with --no-notes' '
test_when_finished "git notes remove topic unmodified || :" &&
git notes add -m "topic note" topic &&