Skip to content

Commit

Permalink
entry: extract update_ce_after_write() from write_entry()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
matheustavares authored and gitster committed Mar 23, 2021
1 parent 49cfd90 commit 584a0d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 16 additions & 9 deletions entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ void unlink_entry(const struct cache_entry *ce);

void *read_blob_entry(const struct cache_entry *ce, unsigned long *size);
int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st);
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
struct stat *st);

#endif /* ENTRY_H */

0 comments on commit 584a0d1

Please sign in to comment.