Fixed t0000-basic.sh and test-lib.sh permissions
[git.git] / diff-files.c
index fdd7dd4..28f1b13 100644 (file)
@@ -6,8 +6,8 @@
 #include "cache.h"
 #include "diff.h"
 
-static const char *show_diff_usage =
-"show-diff [-p] [-q] [-r] [-z] [paths...]";
+static const char *diff_files_usage =
+"diff-files [-p] [-q] [-r] [-z] [paths...]";
 
 static int generate_patch = 0;
 static int line_termination = '\n';
@@ -80,7 +80,7 @@ int main(int argc, char **argv)
                else if (!strcmp(argv[1], "-z"))
                        line_termination = 0;
                else
-                       usage(show_diff_usage);
+                       usage(diff_files_usage);
                argv++; argc--;
        }
 
@@ -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);