Re: [PATCH] entry: check for fstat() errors after checkout
- From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
- Date
- Jul 21, 2020, 15:39 UTC
- Message-ID
- <CAHd-oW4_A7JRmdTqCMrDU7b6-PqBSpNVD-csm3y9Bype6Vn9rA@mail.gmail.com>
- In-Reply-To
- <fbde5e1c9042ea06b448bc759cea9d45e300961f.1594260597.git.matheus.bernardino@usp.br>
Hi, Junio and Stolee
I was looking further at this code and noticed that the conditions under which we fstat() (or lstat()) an entry are slightly different throughout entry.c:
- In write_entry()'s footer, we call lstat() iff stat->refresh_cache. - In write_entry()'s `write_file_entry` label, we call fstat_output() when !to_tempfile. - In streaming_write_entry() we call fstat_output() without checking if !to_tempfile. - And, finally, in fstat_output() itself, we check `state->refresh_cache && !state->base_dir_len`.
I understand we always check state->refresh_cache to avoid getting stat information we won't really need later, as we are not updating the index. But why do we check !to_tempfile and !state->base_dir_len? Doesn't writing to a tempfile or using a checkout prefix already imply !state->refresh_cache?
Thanks, Matheus