From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Stefan Beller" <sbeller@google.com>,
"Eric Sunshine" <sunshine@sunshineco.com>
Subject: [RFC PATCH 3/5] format-patch: extend --range-diff to accept revision range
Date: Wed, 30 May 2018 04:03:23 -0400 [thread overview]
Message-ID: <20180530080325.37520-4-sunshine@sunshineco.com> (raw)
In-Reply-To: <20180530080325.37520-1-sunshine@sunshineco.com>
When submitting a revised a patch series, the --range-diff option embeds
a range-diff in the cover letter showing changes since the previous
version of the patch series. The argument to --range-diff is a simple
revision naming the tip of the previous series, which works fine if the
previous and current versions of the patch series share a common base.
However, it fails if the revision ranges of the old and new versions of
the series are disjoint. To address this shortcoming, extend
--range-diff to also accept an explicit revision range for the previous
series. For example:
git format-patch --cover-letter --range-diff=v1~3..v1 -3 v2
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
Documentation/git-format-patch.txt | 8 +++++---
builtin/log.c | 16 +++++++++++++---
t/t7910-branch-diff.sh | 1 +
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index f4c70e6b64..25026ae26e 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -233,10 +233,12 @@ feeding the result to `git send-email`.
As a reviewer aid, insert a range-diff (see linkgit:git-branch-diff[1])
into the cover letter showing the differences between the previous
version of the patch series and the series currently being formatted.
- `previous` is a single revision naming the tip of the previous
- series which shares a common base with the series being formatted (for
+ `previous` can be a single revision naming the tip of the previous
+ series if it shares a common base with the series being formatted (for
example `git format-patch --cover-letter --range-diff=feature/v1 -3
- feature/v2`).
+ feature/v2`), or a revision range if the two versions of the series are
+ disjoint (for example `git format-patch --cover-letter
+ --range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
--notes[=<ref>]::
Append the notes (see linkgit:git-notes[1]) for the commit
diff --git a/builtin/log.c b/builtin/log.c
index 460c31a293..e38cf06050 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -995,10 +995,20 @@ static char *find_branch_name(struct rev_info *rev)
static void infer_diff_ranges(struct argv_array *args,
const char *prev,
+ struct commit *origin,
struct commit *head)
{
- argv_array_pushf(args, "%s...%s", prev,
- oid_to_hex(&head->object.oid));
+ if (strstr(prev, "..")) {
+ if (!origin)
+ die(_("failed to infer range-diff ranges"));
+ argv_array_push(args, prev);
+ argv_array_pushf(args, "%s..%s",
+ oid_to_hex(&origin->object.oid),
+ oid_to_hex(&head->object.oid));
+ } else {
+ argv_array_pushf(args, "%s...%s", prev,
+ oid_to_hex(&head->object.oid));
+ }
}
static int get_range_diff(struct strbuf *sb,
@@ -1059,7 +1069,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
/* might die from bad user input so try before creating cover letter */
if (range_diff) {
struct argv_array ranges = ARGV_ARRAY_INIT;
- infer_diff_ranges(&ranges, range_diff, head);
+ infer_diff_ranges(&ranges, range_diff, origin, head);
if (get_range_diff(&diff, &ranges))
die(_("failed to generate range-diff"));
argv_array_clear(&ranges);
diff --git a/t/t7910-branch-diff.sh b/t/t7910-branch-diff.sh
index edbd69b6f8..c0e8668ed9 100755
--- a/t/t7910-branch-diff.sh
+++ b/t/t7910-branch-diff.sh
@@ -155,5 +155,6 @@ format_patch () {
}
format_patch 'B...C' topic
+format_patch 'A..B A..C' master..topic
test_done
--
2.17.1.1235.ge295dfb56e
next prev parent reply other threads:[~2018-05-30 8:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-30 8:03 [RFC PATCH 0/5] format-patch: automate cover letter range-diff Eric Sunshine
2018-05-30 8:03 ` [RFC PATCH 1/5] format-patch: allow additional generated content in make_cover_letter() Eric Sunshine
2018-07-17 10:15 ` Johannes Schindelin
2018-07-17 10:24 ` Eric Sunshine
2018-05-30 8:03 ` [RFC PATCH 2/5] format-patch: add --range-diff option to embed diff in cover letter Eric Sunshine
2018-07-17 10:30 ` Johannes Schindelin
2018-07-17 10:49 ` Eric Sunshine
2018-07-26 10:55 ` Johannes Schindelin
2018-07-26 20:57 ` Eric Sunshine
2018-07-27 15:18 ` Johannes Schindelin
2018-05-30 8:03 ` Eric Sunshine [this message]
2018-05-30 18:58 ` [RFC PATCH 3/5] format-patch: extend --range-diff to accept revision range Stefan Beller
2018-05-30 20:26 ` Eric Sunshine
2018-07-17 10:44 ` Johannes Schindelin
2018-07-17 10:50 ` Eric Sunshine
2018-05-30 8:03 ` [RFC PATCH 4/5] format-patch: teach --range-diff to respect -v/--reroll-count Eric Sunshine
2018-05-30 19:03 ` Stefan Beller
2018-05-30 20:44 ` Eric Sunshine
2018-05-30 21:03 ` Stefan Beller
2018-05-30 21:14 ` Eric Sunshine
2018-05-30 8:03 ` [RFC PATCH 5/5] format-patch: add --creation-weight tweak for --range-diff Eric Sunshine
2018-07-17 11:00 ` Johannes Schindelin
2018-05-30 9:25 ` [RFC PATCH 0/5] format-patch: automate cover letter range-diff Ævar Arnfjörð Bjarmason
2018-06-06 19:16 ` Duy Nguyen
2018-06-07 8:34 ` Eric Sunshine
2018-06-07 15:09 ` Duy Nguyen
2018-07-17 10:04 ` Johannes Schindelin
2018-07-26 12:03 ` Andrei Rybak
2018-07-26 15:57 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180530080325.37520-4-sunshine@sunshineco.com \
--to=sunshine@sunshineco.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).