Merge branch 'jl/diff-submodule-ignore'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Jan 2010 06:53:13 +0000 (22:53 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Jan 2010 06:53:13 +0000 (22:53 -0800)
* jl/diff-submodule-ignore:
Teach diff --submodule that modified submodule directory is dirty
git diff: Don't test submodule dirtiness with --ignore-submodules
Make ce_uptodate() trustworthy again

1  2 
diff-lib.c
diff.c
diff --combined diff-lib.c
index ec2e2ac0058a71a58f6e3af57f2bd86520a67779,899034d354e4f009a1e9aab1e49f01e856a3a30a..d7e13cb177a3c345eb076a9ffede87c6e6afa367
@@@ -161,7 -161,7 +161,7 @@@ int run_diff_files(struct rev_info *rev
                                continue;
                }
  
-               if ((ce_uptodate(ce) && !S_ISGITLINK(ce->ce_mode)) || ce_skip_worktree(ce))
+               if (ce_uptodate(ce) || ce_skip_worktree(ce))
                        continue;
  
                /* If CE_VALID is set, don't look at workdir for file removal */
                }
                changed = ce_match_stat(ce, &st, ce_option);
                if (S_ISGITLINK(ce->ce_mode)
+                   && !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)
                    && (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
                    && is_submodule_modified(ce->name)) {
                        changed = 1;
@@@ -220,7 -221,7 +221,7 @@@ static int get_stat_data(struct cache_e
                         const unsigned char **sha1p,
                         unsigned int *modep,
                         int cached, int match_missing,
-                        unsigned *dirty_submodule, int output_format)
+                        unsigned *dirty_submodule, struct diff_options *diffopt)
  {
        const unsigned char *sha1 = ce->sha1;
        unsigned int mode = ce->ce_mode;
                }
                changed = ce_match_stat(ce, &st, 0);
                if (S_ISGITLINK(ce->ce_mode)
-                   && (!changed || (output_format & DIFF_FORMAT_PATCH))
+                   && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
+                   && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))
                    && is_submodule_modified(ce->name)) {
                        changed = 1;
                        *dirty_submodule = 1;
@@@ -270,7 -272,7 +272,7 @@@ static void show_new_file(struct rev_in
         * the working copy.
         */
        if (get_stat_data(new, &sha1, &mode, cached, match_missing,
-           &dirty_submodule, revs->diffopt.output_format) < 0)
+           &dirty_submodule, &revs->diffopt) < 0)
                return;
  
        diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
@@@ -287,7 -289,7 +289,7 @@@ static int show_modified(struct rev_inf
        unsigned dirty_submodule = 0;
  
        if (get_stat_data(new, &sha1, &mode, cached, match_missing,
-                         &dirty_submodule, revs->diffopt.output_format) < 0) {
+                         &dirty_submodule, &revs->diffopt) < 0) {
                if (report_missing)
                        diff_index_show_file(revs, "-", old,
                                             old->sha1, old->ce_mode, 0);
@@@ -380,6 -382,21 +382,6 @@@ static void do_oneway_diff(struct unpac
        show_modified(revs, tree, idx, 1, cached, match_missing);
  }
  
 -static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
 -{
 -      int len = ce_namelen(ce);
 -      const struct index_state *index = o->src_index;
 -
 -      while (o->pos < index->cache_nr) {
 -              struct cache_entry *next = index->cache[o->pos];
 -              if (len != ce_namelen(next))
 -                      break;
 -              if (memcmp(ce->name, next->name, len))
 -                      break;
 -              o->pos++;
 -      }
 -}
 -
  /*
   * The unpack_trees() interface is designed for merging, so
   * the different source entries are designed primarily for
@@@ -401,6 -418,9 +403,6 @@@ static int oneway_diff(struct cache_ent
        struct cache_entry *tree = src[1];
        struct rev_info *revs = o->unpack_data;
  
 -      if (idx && ce_stage(idx))
 -              skip_same_name(idx, o);
 -
        /*
         * Unpack-trees generates a DF/conflict entry if
         * there was a directory in the index and a tree
@@@ -446,7 -466,6 +448,7 @@@ int run_diff_index(struct rev_info *rev
                exit(128);
  
        diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/");
 +      diffcore_fix_diff_index(&revs->diffopt);
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
        return 0;
diff --combined diff.c
index f130a367dcfe8668d09a0e4a55f96d6b66251db9,0190ec6d9f295fbd92b2cd3561b29ca0d0e0af1a..381cc8d4fd69ca31fb8fc8af31422160e3ec1fd3
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -1615,7 -1615,7 +1615,7 @@@ static void builtin_diff(const char *na
                const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
                const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
                show_submodule_summary(o->file, one ? one->path : two->path,
-                               one->sha1, two->sha1,
+                               one->sha1, two->sha1, two->dirty_submodule,
                                del, add, reset);
                return;
        }
@@@ -3678,23 -3678,6 +3678,23 @@@ static void diffcore_skip_stat_unmatch(
        *q = outq;
  }
  
 +static int diffnamecmp(const void *a_, const void *b_)
 +{
 +      const struct diff_filepair *a = *((const struct diff_filepair **)a_);
 +      const struct diff_filepair *b = *((const struct diff_filepair **)b_);
 +      const char *name_a, *name_b;
 +
 +      name_a = a->one ? a->one->path : a->two->path;
 +      name_b = b->one ? b->one->path : b->two->path;
 +      return strcmp(name_a, name_b);
 +}
 +
 +void diffcore_fix_diff_index(struct diff_options *options)
 +{
 +      struct diff_queue_struct *q = &diff_queued_diff;
 +      qsort(q->queue, q->nr, sizeof(q->queue[0]), diffnamecmp);
 +}
 +
  void diffcore_std(struct diff_options *options)
  {
        if (options->skip_stat_unmatch)