Skip to content

Commit 657ab61

Browse files
lilyballgitster
authored andcommitted
format-patch: Squelch 'fatal: Not a range." error
Don't output an error on `git format-patch --ignore-if-in-upstream HEAD`. This matches the behavior of `git format-patch HEAD`. Signed-off-by: Kevin Ballard <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e07665e commit 657ab61

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

builtin-log.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
11061106
return 0;
11071107
}
11081108

1109-
if (ignore_if_in_upstream)
1109+
if (ignore_if_in_upstream) {
1110+
/* Don't say anything if head and upstream are the same. */
1111+
if (rev.pending.nr == 2) {
1112+
struct object_array_entry *o = rev.pending.objects;
1113+
if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
1114+
return 0;
1115+
}
11101116
get_patch_ids(&rev, &ids, prefix);
1117+
}
11111118

11121119
if (!use_stdout)
11131120
realstdout = xfdopen(xdup(1), "w");

t/t4014-format-patch.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,8 @@ test_expect_success 'format-patch -- <path>' '
557557
! grep "Use .--" error
558558
'
559559

560+
test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
561+
git format-patch --ignore-if-in-upstream HEAD
562+
'
563+
560564
test_done

0 commit comments

Comments
 (0)