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 <kevin@sb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Ballard committed
Mar 29, 2010 at 19:46 UTC
657ab61efa918f46f1b412613643d1a1bbed2194
2 files changed
+12
-1
builtin-log.c
+8
-1
@@ -1106,8 +1106,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1106
return 0;
1107
}
1108
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
+ }
1116
get_patch_ids(&rev, &ids, prefix);
1117
+ }
1118
1119
if (!use_stdout)
1120
realstdout = xfdopen(xdup(1), "w");
t/t4014-format-patch.sh
+4
@@ -557,4 +557,8 @@ test_expect_success 'format-patch -- <path>' '
557
! grep "Use .--" error
558
'
559
560
+test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
561
+ git format-patch --ignore-if-in-upstream HEAD
562
+'
563
+
564
test_done