aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-01-27 09:45:07 -0500
committerJunio C Hamano <gitster@pobox.com>2014-02-24 14:31:10 -0800
commit2e2e7ec1ef567ac0a4ad8294ada15836661e6589 (patch)
tree7249fb30c8d7c927de067363bb80524dcea93e7f
parent29d9af586ba3ee1e6df1dc070f42ea659ad77cc2 (diff)
downloadgit-2e2e7ec1ef567ac0a4ad8294ada15836661e6589.tar.gz
git-2e2e7ec1ef567ac0a4ad8294ada15836661e6589.tar.xz
read-cache.c: refactor --ignore-missing implementation
Move lstat ENOENT handling from refresh_index to refresh_cache_ent and activate it with a new CE_MATCH_IGNORE_MISSING option. This will allow other call paths into refresh_cache_ent to use the feature. Signed-off-by: Brad King <brad.king@kitware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--cache.h2
-rw-r--r--read-cache.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 415d88308..87429db0e 100644
--- a/cache.h
+++ b/cache.h
@@ -488,6 +488,8 @@ extern void *read_blob_data_from_index(struct index_state *, const char *, unsig
#define CE_MATCH_RACY_IS_DIRTY 02
/* do stat comparison even if CE_SKIP_WORKTREE is true */
#define CE_MATCH_IGNORE_SKIP_WORKTREE 04
+/* ignore non-existent files during stat update */
+#define CE_MATCH_IGNORE_MISSING 0x08
extern int ie_match_stat(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
extern int ie_modified(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
diff --git a/read-cache.c b/read-cache.c
index c3d5e3543..bb38115a9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1031,6 +1031,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
int changed, size;
int ignore_valid = options & CE_MATCH_IGNORE_VALID;
int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE;
+ int ignore_missing = options & CE_MATCH_IGNORE_MISSING;
if (ce_uptodate(ce))
return ce;
@@ -1050,6 +1051,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
}
if (lstat(ce->name, &st) < 0) {
+ if (ignore_missing && errno == ENOENT)
+ return ce;
if (err)
*err = errno;
return NULL;
@@ -1126,7 +1129,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
int first = 1;
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
- unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
+ unsigned int options = ((really ? CE_MATCH_IGNORE_VALID : 0) |
+ (not_new ? CE_MATCH_IGNORE_MISSING : 0));
const char *modified_fmt;
const char *deleted_fmt;
const char *typechange_fmt;
@@ -1175,8 +1179,6 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
if (!new) {
const char *fmt;
- if (not_new && cache_errno == ENOENT)
- continue;
if (really && cache_errno == EINVAL) {
/* If we are doing --really-refresh that
* means the index is not valid anymore.