From 15d1b8a72305e63e14a8c29c5d830f6033494ab6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Aug 2023 09:47:59 +0200 Subject: [PATCH] WIP Need to add a test for a bare diff (i.e. without commit message), to allow things like: git range-diff $COMMIT^! mbox:<(git diff HEAD) Signed-off-by: Johannes Schindelin --- range-diff.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/range-diff.c b/range-diff.c index 7c0eb8e2145961..acb56ccbf76149 100644 --- a/range-diff.c +++ b/range-diff.c @@ -233,6 +233,15 @@ static int read_mbox(const char *path, struct string_list *list) while (next_line(&s)) { if (s.state == MBOX_BEFORE_HEADER) { + if (starts_with(s.line, "diff --git ")) { + /* This is a patch without commit message */ + util = xcalloc(1, sizeof(*util)); + oidcpy(&util->oid, null_oid()); + util->matching = -1; + author = subject = "(none)"; + goto process_diff; + } + parse_from_delimiter: if (!skip_prefix(s.line, "From ", &p)) continue; @@ -249,6 +258,7 @@ static int read_mbox(const char *path, struct string_list *list) continue; } +process_diff: if (starts_with(s.line, "diff --git ")) { struct patch patch = { 0 }; struct strbuf root = STRBUF_INIT;