X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=diff-index.c;h=c9a9f4c74d96ea22b2a6c4c7593bccc3d5396457;hb=4ddba79db76bd6425f00e99ceb1d82d179319aec;hp=62b36cc8ee2bad8e4c37c4c7e2a99d6d4abc2f88;hpb=6b5ee137e56af8093391411389dd4b18416707ec;p=git.git diff --git a/diff-index.c b/diff-index.c index 62b36cc8..c9a9f4c7 100644 --- a/diff-index.c +++ b/diff-index.c @@ -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; @@ -174,6 +180,7 @@ int main(int argc, const char **argv) int allow_options = 1; int i; + git_config(git_default_config); diff_setup(&diff_options); for (i = 1; i < argc; i++) { const char *arg = argv[i];