Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Aug 29, 2023
1 parent 4b98885 commit 15d1b8a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions range-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 15d1b8a

Please sign in to comment.