]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff-lib.c
Show submodules as modified when they contain a dirty work tree
[thirdparty/git.git] / diff-lib.c
index adf1c5fdee2bc836f03eaa89160573973bb46a67..9cdf6daa9077e4c743822e461a08ff80530da38e 100644 (file)
@@ -10,6 +10,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "refs.h"
+#include "submodule.h"
 
 /*
  * diff-files
@@ -73,7 +74,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                struct cache_entry *ce = active_cache[i];
                int changed;
 
-               if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
+               if (DIFF_OPT_TST(&revs->diffopt, QUICK) &&
                        DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
                        break;
 
@@ -159,7 +160,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                continue;
                }
 
-               if (ce_uptodate(ce))
+               if ((ce_uptodate(ce) && !S_ISGITLINK(ce->ce_mode)) || ce_skip_worktree(ce))
                        continue;
 
                /* If CE_VALID is set, don't look at workdir for file removal */
@@ -176,6 +177,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                        continue;
                }
                changed = ce_match_stat(ce, &st, ce_option);
+               if (S_ISGITLINK(ce->ce_mode) && !changed)
+                       changed = is_submodule_modified(ce->name);
                if (!changed) {
                        ce_mark_uptodate(ce);
                        if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
@@ -230,7 +233,8 @@ static int get_stat_data(struct cache_entry *ce,
                        return -1;
                }
                changed = ce_match_stat(ce, &st, 0);
-               if (changed) {
+               if (changed
+                   || (S_ISGITLINK(ce->ce_mode) && is_submodule_modified(ce->name))) {
                        mode = ce_mode_from_stat(ce, st.st_mode);
                        sha1 = null_sha1;
                }
@@ -323,7 +327,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
        int match_missing, cached;
 
        /* if the entry is not checked out, don't examine work tree */
-       cached = o->index_only || (idx && (idx->ce_flags & CE_VALID));
+       cached = o->index_only ||
+               (idx && ((idx->ce_flags & CE_VALID) || ce_skip_worktree(idx)));
        /*
         * Backward compatibility wart - "diff-index -m" does
         * not mean "do not ignore merges", but "match_missing".
@@ -507,7 +512,7 @@ int index_differs_from(const char *def, int diff_flags)
 
        init_revisions(&rev, NULL);
        setup_revisions(0, NULL, &rev, def);
-       DIFF_OPT_SET(&rev.diffopt, QUIET);
+       DIFF_OPT_SET(&rev.diffopt, QUICK);
        DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
        rev.diffopt.flags |= diff_flags;
        run_diff_index(&rev, 1);