diff options
-rw-r--r-- | builtin-add.c | 2 | ||||
-rw-r--r-- | diff-lib.c | 4 | ||||
-rw-r--r-- | diff.h | 2 | ||||
-rw-r--r-- | read-cache.c | 3 |
4 files changed, 8 insertions, 3 deletions
diff --git a/builtin-add.c b/builtin-add.c index 373f87f9f2..e072320d20 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -123,7 +123,7 @@ static void update(int verbose, const char *prefix, const char **files) rev.diffopt.format_callback_data = &verbose; if (read_cache() < 0) die("index file corrupt"); - run_diff_files(&rev, 0); + run_diff_files(&rev, DIFF_RACY_IS_MODIFIED); } static void refresh(int verbose, const char **pathspec) diff --git a/diff-lib.c b/diff-lib.c index 9f8afbe71a..ec1b5e3d44 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -338,6 +338,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) int entries, i; int diff_unmerged_stage = revs->max_count; int silent_on_removed = option & DIFF_SILENT_ON_REMOVED; + unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) + ? CE_MATCH_RACY_IS_DIRTY : 0); if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; @@ -443,7 +445,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) ce->sha1, ce->name, NULL); continue; } - changed = ce_match_stat(ce, &st, 0); + changed = ce_match_stat(ce, &st, ce_option); if (!changed && !revs->diffopt.find_copies_harder) continue; oldmode = ntohl(ce->ce_mode); @@ -226,6 +226,8 @@ extern const char *diff_unique_abbrev(const unsigned char *, int); /* do not report anything on removed paths */ #define DIFF_SILENT_ON_REMOVED 01 +/* report racily-clean paths as modified */ +#define DIFF_RACY_IS_MODIFIED 02 extern int run_diff_files(struct rev_info *revs, unsigned int option); extern int setup_diff_no_index(struct rev_info *revs, int argc, const char ** argv, int nongit, const char *prefix); diff --git a/read-cache.c b/read-cache.c index 9e4d4a9136..c3dbf89426 100644 --- a/read-cache.c +++ b/read-cache.c @@ -388,6 +388,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose) int size, namelen, pos; struct stat st; struct cache_entry *ce; + unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY; if (lstat(path, &st)) die("%s: unable to stat (%s)", path, strerror(errno)); @@ -422,7 +423,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose) pos = index_name_pos(istate, ce->name, namelen); if (0 <= pos && !ce_stage(istate->cache[pos]) && - !ie_modified(istate, istate->cache[pos], &st, CE_MATCH_IGNORE_VALID)) { + !ie_match_stat(istate, istate->cache[pos], &st, ce_option)) { /* Nothing changed, really */ free(ce); return 0; |