aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff-no-index.c2
-rwxr-xr-xt/t4011-diff-symlink.sh7
2 files changed, 8 insertions, 1 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index 60ed17470..0dbd9dad8 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -40,7 +40,7 @@ static int get_mode(const char *path, int *mode)
*mode = 0;
else if (!strcmp(path, "-"))
*mode = create_ce_mode(0666);
- else if (stat(path, &st))
+ else if (lstat(path, &st))
return error("Could not access '%s'", path);
else
*mode = st.st_mode;
diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh
index 02efecae3..9055c8b31 100755
--- a/t/t4011-diff-symlink.sh
+++ b/t/t4011-diff-symlink.sh
@@ -82,4 +82,11 @@ test_expect_success \
git diff-index -M -p $tree > current &&
compare_diff_patch current expected'
+test_expect_success \
+ 'diff symlinks with non-existing targets' \
+ 'ln -s narf pinky &&
+ ln -s take\ over brain &&
+ test_must_fail git diff --no-index pinky brain > output 2> output.err &&
+ grep narf output &&
+ ! grep error output.err'
test_done