X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=update-index.c;h=ce1db38d16928d8b5085cb6e177f40fff9a978cf;hb=1d3d03bbeaaf55844868affc96231930aae792e6;hp=767fd49721b26eb6c48d8dc77e5f83d2364eae28;hpb=5f73076c1a9b4b8dc94f77eac98eb558d25e33c0;p=git.git diff --git a/update-index.c b/update-index.c index 767fd497..ce1db38d 100644 --- a/update-index.c +++ b/update-index.c @@ -161,8 +161,13 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce, int really) return ERR_PTR(-errno); changed = ce_match_stat(ce, &st, really); - if (!changed) - return NULL; + if (!changed) { + if (really && assume_unchanged && + !(ce->ce_flags & htons(CE_VALID))) + ; /* mark this one VALID again */ + else + return NULL; + } if (ce_modified(ce, &st, really)) return ERR_PTR(-EINVAL); @@ -172,6 +177,15 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce, int really) memcpy(updated, ce, size); fill_stat_cache_info(updated, &st); + /* In this case, if really is not set, we should leave + * CE_VALID bit alone. Otherwise, paths marked with + * --no-assume-unchanged (i.e. things to be edited) will + * reacquire CE_VALID bit automatically, which is not + * really what we want. + */ + if (!really && assume_unchanged && !(ce->ce_flags & htons(CE_VALID))) + updated->ce_flags &= ~htons(CE_VALID); + return updated; }