From: Junio C Hamano Date: Wed, 27 Jan 2010 06:53:13 +0000 (-0800) Subject: Merge branch 'jl/diff-submodule-ignore' X-Git-Tag: v1.7.0-rc1~29 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d539de9f25920f099e4e56b0acbb4ebf246ff0f4?ds=inline;hp=-c Merge branch 'jl/diff-submodule-ignore' * 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 --- d539de9f25920f099e4e56b0acbb4ebf246ff0f4 diff --combined diff-lib.c index ec2e2ac005,899034d354..d7e13cb177 --- a/diff-lib.c +++ b/diff-lib.c @@@ -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 */ @@@ -179,6 -179,7 +179,7 @@@ } 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; @@@ -241,7 -242,8 +242,8 @@@ } 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 f130a367dc,0190ec6d9f..381cc8d4fd --- a/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)