Skip to content

Commit 584a0d1

Browse files
matheustavaresgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 49cfd90 commit 584a0d1

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

entry.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
251251
return errs;
252252
}
253253

254+
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
255+
struct stat *st)
256+
{
257+
if (state->refresh_cache) {
258+
assert(state->istate);
259+
fill_stat_cache_info(state->istate, ce, st);
260+
ce->ce_flags |= CE_UPDATE_IN_BASE;
261+
mark_fsmonitor_invalid(state->istate, ce);
262+
state->istate->cache_changed |= CE_ENTRY_CHANGED;
263+
}
264+
}
265+
254266
static int write_entry(struct cache_entry *ce,
255267
char *path, const struct checkout *state, int to_tempfile)
256268
{
@@ -371,15 +383,10 @@ static int write_entry(struct cache_entry *ce,
371383

372384
finish:
373385
if (state->refresh_cache) {
374-
assert(state->istate);
375-
if (!fstat_done)
376-
if (lstat(ce->name, &st) < 0)
377-
return error_errno("unable to stat just-written file %s",
378-
ce->name);
379-
fill_stat_cache_info(state->istate, ce, &st);
380-
ce->ce_flags |= CE_UPDATE_IN_BASE;
381-
mark_fsmonitor_invalid(state->istate, ce);
382-
state->istate->cache_changed |= CE_ENTRY_CHANGED;
386+
if (!fstat_done && lstat(ce->name, &st) < 0)
387+
return error_errno("unable to stat just-written file %s",
388+
ce->name);
389+
update_ce_after_write(state, ce , &st);
383390
}
384391
delayed:
385392
return 0;

entry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ void unlink_entry(const struct cache_entry *ce);
4141

4242
void *read_blob_entry(const struct cache_entry *ce, unsigned long *size);
4343
int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st);
44+
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
45+
struct stat *st);
4446

4547
#endif /* ENTRY_H */

0 commit comments

Comments
 (0)