Skip to content

Commit

Permalink
Merge branch 'pw/diff-no-index-from-named-pipes'
Browse files Browse the repository at this point in the history
"git diff --no-index -R <(one) <(two)" did not work correctly,
which has been corrected.

* pw/diff-no-index-from-named-pipes:
  diff --no-index: fix -R with stdin
  • Loading branch information
gitster committed Sep 20, 2023
2 parents d4a83d0 + 48944f2 commit 7435d51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions diff-no-index.c
Expand Up @@ -232,6 +232,7 @@ static int queue_diff(struct diff_options *o,
if (o->flags.reverse_diff) {
SWAP(mode1, mode2);
SWAP(name1, name2);
SWAP(special1, special2);
}

d1 = noindex_filespec(name1, mode1, special1);
Expand Down
19 changes: 19 additions & 0 deletions t/t4053-diff-no-index.sh
Expand Up @@ -224,6 +224,25 @@ test_expect_success "diff --no-index treats '-' as stdin" '
test_must_be_empty actual
'

test_expect_success "diff --no-index -R treats '-' as stdin" '
cat >expect <<-EOF &&
diff --git b/a/1 a/-
index $(git hash-object --stdin <a/1)..$ZERO_OID 100644
--- b/a/1
+++ a/-
@@ -1 +1 @@
-1
+x
EOF
test_write_lines x | test_expect_code 1 \
git -c core.abbrev=no diff --no-index -R -- - a/1 >actual &&
test_cmp expect actual &&
test_write_lines 1 | git diff --no-index -R -- a/1 - >actual &&
test_must_be_empty actual
'

test_expect_success 'diff --no-index refuses to diff stdin and a directory' '
test_must_fail git diff --no-index -- - a </dev/null 2>err &&
grep "fatal: cannot compare stdin to a directory" err
Expand Down

0 comments on commit 7435d51

Please sign in to comment.