Fix git-format-patch -s to include a Signed-off-by: line...
[git.git] / diff-index.c
index 62b36cc..87e1061 100644 (file)
@@ -15,7 +15,7 @@ static void show_file(const char *prefix,
 }
 
 static int get_stat_data(struct cache_entry *ce,
-                        unsigned char **sha1p, unsigned int *modep)
+                        unsigned char ** sha1p, unsigned int *modep)
 {
        unsigned char *sha1 = ce->sha1;
        unsigned int mode = ce->ce_mode;
@@ -35,6 +35,10 @@ static int get_stat_data(struct cache_entry *ce,
                changed = ce_match_stat(ce, &st);
                if (changed) {
                        mode = create_ce_mode(st.st_mode);
+                       if (!trust_executable_bit &&
+                           S_ISREG(mode) && S_ISREG(ce->ce_mode) &&
+                           ((mode ^ ce->ce_mode) == 0111))
+                               mode = ce->ce_mode;
                        sha1 = no_sha1;
                }
        }
@@ -49,7 +53,9 @@ static void show_new_file(struct cache_entry *new)
        unsigned char *sha1;
        unsigned int mode;
 
-       /* New file in the index: it might actually be different in the working copy */
+       /* New file in the index: it might actually be different in
+        * the working copy.
+        */
        if (get_stat_data(new, &sha1, &mode) < 0)
                return;
 
@@ -110,7 +116,7 @@ static int diff_cache(struct cache_entry **ac, int entries, const char **pathspe
                        /* We come here with ce pointing at stage 1
                         * (original tree) and ac[1] pointing at stage
                         * 3 (unmerged).  show-modified with
-                        * report-mising set to false does not say the
+                        * report-missing set to false does not say the
                         * file is deleted but reports true if work
                         * tree does not have it, in which case we
                         * fall through to report the unmerged state.
@@ -174,6 +180,7 @@ int main(int argc, const char **argv)
        int allow_options = 1;
        int i;
 
+       git_config(git_diff_config);
        diff_setup(&diff_options);
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];