Fixed t0000-basic.sh and test-lib.sh permissions
[git.git] / diff-files.c
index 0cf2c24..28f1b13 100644 (file)
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
                        continue;
                }
  
-               if (stat(ce->name, &st) < 0) {
+               if (lstat(ce->name, &st) < 0) {
                        if (errno != ENOENT) {
                                perror(ce->name);
                                continue;
@@ -126,7 +126,8 @@ int main(int argc, char **argv)
                        continue;
 
                oldmode = ntohl(ce->ce_mode);
-               mode = S_IFREG | ce_permissions(st.st_mode);
+               mode = (S_ISLNK(st.st_mode) ? S_IFLNK :
+                       S_IFREG | ce_permissions(st.st_mode));
 
                show_modified(oldmode, mode, ce->sha1, null_sha1,
                              ce->name);