Skip to content

Commit 15d1b8a

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 4b98885 commit 15d1b8a

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
@@ -233,6 +233,15 @@ static int read_mbox(const char *path, struct string_list *list)
233233

234234
while (next_line(&s)) {
235235
if (s.state == MBOX_BEFORE_HEADER) {
236+
if (starts_with(s.line, "diff --git ")) {
237+
/* This is a patch without commit message */
238+
util = xcalloc(1, sizeof(*util));
239+
oidcpy(&util->oid, null_oid());
240+
util->matching = -1;
241+
author = subject = "(none)";
242+
goto process_diff;
243+
}
244+
236245
parse_from_delimiter:
237246
if (!skip_prefix(s.line, "From ", &p))
238247
continue;
@@ -249,6 +258,7 @@ static int read_mbox(const char *path, struct string_list *list)
249258
continue;
250259
}
251260

261+
process_diff:
252262
if (starts_with(s.line, "diff --git ")) {
253263
struct patch patch = { 0 };
254264
struct strbuf root = STRBUF_INIT;

0 commit comments

Comments
 (0)