summaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2021-03-23 14:19:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-23 17:34:05 (GMT)
commit584a0d13f25d60694a1226cd274c33dba62bf9e4 (patch)
treec40df6cf2c9f4b2c4c099961eba6e78f5cbd1626 /entry.c
parent49cfd9032a5c1ef7401b79eff8db471b4c6ed7ef (diff)
downloadgit-584a0d13f25d60694a1226cd274c33dba62bf9e4.zip
git-584a0d13f25d60694a1226cd274c33dba62bf9e4.tar.gz
git-584a0d13f25d60694a1226cd274c33dba62bf9e4.tar.bz2
entry: extract update_ce_after_write() from write_entry()
The code that updates the in-memory index information after an entry is written currently resides in write_entry(). Extract it to a public function so that it can be called by the parallel checkout functions, outside entry.c, in a later patch. Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/entry.c b/entry.c
index 1e2d9f7..4cf0db3 100644
--- a/entry.c
+++ b/entry.c
@@ -251,6 +251,18 @@ int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
return errs;
}
+void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
+ struct stat *st)
+{
+ if (state->refresh_cache) {
+ assert(state->istate);
+ fill_stat_cache_info(state->istate, ce, st);
+ ce->ce_flags |= CE_UPDATE_IN_BASE;
+ mark_fsmonitor_invalid(state->istate, ce);
+ state->istate->cache_changed |= CE_ENTRY_CHANGED;
+ }
+}
+
static int write_entry(struct cache_entry *ce,
char *path, const struct checkout *state, int to_tempfile)
{
@@ -371,15 +383,10 @@ static int write_entry(struct cache_entry *ce,
finish:
if (state->refresh_cache) {
- assert(state->istate);
- if (!fstat_done)
- if (lstat(ce->name, &st) < 0)
- return error_errno("unable to stat just-written file %s",
- ce->name);
- fill_stat_cache_info(state->istate, ce, &st);
- ce->ce_flags |= CE_UPDATE_IN_BASE;
- mark_fsmonitor_invalid(state->istate, ce);
- state->istate->cache_changed |= CE_ENTRY_CHANGED;
+ if (!fstat_done && lstat(ce->name, &st) < 0)
+ return error_errno("unable to stat just-written file %s",
+ ce->name);
+ update_ce_after_write(state, ce , &st);
}
delayed:
return 0;