@@ -567,5 +567,17 @@ int show_range_diff(const char *range1, const char *range2,
int is_range_diff_range(const char *arg)
{
- return !!strstr(arg, "..");
+ static regex_t *regex;
+
+ if (strstr(arg, ".."))
+ return 1;
+
+ /* match `<rev>^!` and `<rev>^-<n>` */
+ if (!regex) {
+ regex = xmalloc(sizeof(*regex));
+ if (regcomp(regex, "\\^(!|-[0-9]*)$", REG_EXTENDED) < 0)
+ BUG("could not compile range-diff regex");
+ }
+
+ return !regexec(regex, arg, 0, NULL, 0);
}
@@ -150,6 +150,14 @@ test_expect_success 'simple A B C (unmodified)' '
test_cmp expect actual
'
+test_expect_success 'A^! and A^-<n> (unmodified)' '
+ git range-diff --no-color topic^! unmodified^-1 >actual &&
+ cat >expect <<-EOF &&
+ 1: $(test_oid t4) = 1: $(test_oid u4) s/12/B/
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'trivial reordering' '
git range-diff --no-color master topic reordered >actual &&
cat >expect <<-EOF &&