sha1_name: add get_sha1_with_context()
[gitweb.git] / diff-lib.c
index ea9cf561cd66564602ab3a66c29a15dc85ae19b0..c9f6e05badf7b752188dcb5fa28a9bef53521dee 100644 (file)
@@ -71,9 +71,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
        if (S_ISGITLINK(ce->ce_mode)
            && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
            && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
-               *dirty_submodule = is_submodule_modified(ce->name);
-               if (*dirty_submodule)
-                       changed = 1;
+               *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
        }
        return changed;
 }
@@ -202,7 +200,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                }
                changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
                                                    ce_option, &dirty_submodule);
-               if (!changed) {
+               if (!changed && !dirty_submodule) {
                        ce_mark_uptodate(ce);
                        if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                                continue;
@@ -333,7 +331,7 @@ static int show_modified(struct rev_info *revs,
        }
 
        oldmode = old->ce_mode;
-       if (mode == oldmode && !hashcmp(sha1, old->sha1) &&
+       if (mode == oldmode && !hashcmp(sha1, old->sha1) && !dirty_submodule &&
            !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
                return 0;
 
@@ -521,9 +519,12 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
 int index_differs_from(const char *def, int diff_flags)
 {
        struct rev_info rev;
+       struct setup_revision_opt opt;
 
        init_revisions(&rev, NULL);
-       setup_revisions(0, NULL, &rev, def);
+       memset(&opt, 0, sizeof(opt));
+       opt.def = def;
+       setup_revisions(0, NULL, &rev, &opt);
        DIFF_OPT_SET(&rev.diffopt, QUICK);
        DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
        rev.diffopt.flags |= diff_flags;