Fix 'git diff --no-index' with a non-existing symlink target
When trying to find out mode changes, we should not access the symlink targets using stat(); instead we use lstat() so that the diff does not fail trying to find a non-existing symlink target. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
41a4d16e20
commit
418566b6fd
@@ -40,7 +40,7 @@ static int get_mode(const char *path, int *mode)
|
|||||||
*mode = 0;
|
*mode = 0;
|
||||||
else if (!strcmp(path, "-"))
|
else if (!strcmp(path, "-"))
|
||||||
*mode = create_ce_mode(0666);
|
*mode = create_ce_mode(0666);
|
||||||
else if (stat(path, &st))
|
else if (lstat(path, &st))
|
||||||
return error("Could not access '%s'", path);
|
return error("Could not access '%s'", path);
|
||||||
else
|
else
|
||||||
*mode = st.st_mode;
|
*mode = st.st_mode;
|
||||||
|
|||||||
@@ -82,4 +82,11 @@ test_expect_success \
|
|||||||
git diff-index -M -p $tree > current &&
|
git diff-index -M -p $tree > current &&
|
||||||
compare_diff_patch current expected'
|
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
|
test_done
|
||||||
|
|||||||
Reference in New Issue
Block a user