Skip to content

Commit 07a7f8d

Browse files
sunshinecogitster
authored andcommitted
format-patch: use 'origin' as start of current-series-range when known
When formatting a patch series over `origin..HEAD`, one would expect that range to be used as the current-series-range when computing a range-diff between the previous and current versions of a patch series. However, infer_range_diff_ranges() ignores `origin..HEAD` when --range-diff=<prev> specifies a single revision rather than a range, and instead unexpectedly computes the current-series-range based upon <prev>. Address this anomaly by unconditionally using `origin..HEAD` as the current-series-range regardless of <prev> as long as `origin` is known, and only fall back to basing current-series-range on <prev> when `origin` is not known. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 72a7239 commit 07a7f8d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

builtin/log.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,16 +1595,20 @@ static void infer_range_diff_ranges(struct strbuf *r1,
15951595
struct commit *head)
15961596
{
15971597
const char *head_oid = oid_to_hex(&head->object.oid);
1598+
int prev_is_range = !!strstr(prev, "..");
15981599

1599-
if (!strstr(prev, "..")) {
1600+
if (prev_is_range)
1601+
strbuf_addstr(r1, prev);
1602+
else
16001603
strbuf_addf(r1, "%s..%s", head_oid, prev);
1604+
1605+
if (origin)
1606+
strbuf_addf(r2, "%s..%s", oid_to_hex(&origin->object.oid), head_oid);
1607+
else if (prev_is_range)
1608+
die(_("failed to infer range-diff origin of current series"));
1609+
else {
1610+
warning(_("using '%s' as range-diff origin of current series"), prev);
16011611
strbuf_addf(r2, "%s..%s", prev, head_oid);
1602-
} else if (!origin) {
1603-
die(_("failed to infer range-diff ranges"));
1604-
} else {
1605-
strbuf_addstr(r1, prev);
1606-
strbuf_addf(r2, "%s..%s",
1607-
oid_to_hex(&origin->object.oid), head_oid);
16081612
}
16091613
}
16101614

0 commit comments

Comments
 (0)