Skip to content

Commit 77c82f6

Browse files
committed
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 <[email protected]>
1 parent 66a7eab commit 77c82f6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

range-diff.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ static int read_mbox(const char *path, struct string_list *list)
242242

243243
while (next_line(&s)) {
244244
if (s.state == MBOX_BEFORE_HEADER) {
245+
if (starts_with(s.line, "diff --git ")) {
246+
/* This is a patch without commit message */
247+
util = xcalloc(1, sizeof(*util));
248+
oidcpy(&util->oid, null_oid());
249+
util->matching = -1;
250+
author = subject = "(none)";
251+
goto process_diff;
252+
}
253+
245254
parse_from_delimiter:
246255
if (!skip_prefix(s.line, "From ", &p))
247256
continue;
@@ -258,6 +267,7 @@ static int read_mbox(const char *path, struct string_list *list)
258267
continue;
259268
}
260269

270+
process_diff:
261271
if (starts_with(s.line, "diff --git ")) {
262272
struct patch patch = { 0 };
263273
struct strbuf root = STRBUF_INIT;

0 commit comments

Comments
 (0)