Skip to content

Commit 6a8c89d

Browse files
Martin Ågrengitster
authored andcommitted
read-cache: try not to peek into struct {lock_,temp}file
Similar to the previous commits, try to avoid peeking into the `struct lock_file`. We also have some `struct tempfile`s -- let's avoid looking into those as well. Note that `do_write_index()` takes a tempfile and that when we call it, we either have a tempfile which we can easily hand down, or we have a lock file, from which we need to somehow obtain the internal tempfile. So we need to leave that one instance of peeking-into. Nevertheless, this commit leaves us not relying on exactly how the path of the tempfile / lock file is stored internally. Signed-off-by: Martin Ågren <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f0dc79 commit 6a8c89d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

read-cache.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,10 +3014,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30143014
if (ce_flush(&c, newfd, istate->oid.hash))
30153015
return -1;
30163016
if (close_tempfile_gently(tempfile)) {
3017-
error(_("could not close '%s'"), tempfile->filename.buf);
3017+
error(_("could not close '%s'"), get_tempfile_path(tempfile));
30183018
return -1;
30193019
}
3020-
if (stat(tempfile->filename.buf, &st))
3020+
if (stat(get_tempfile_path(tempfile), &st))
30213021
return -1;
30223022
istate->timestamp.sec = (unsigned int)st.st_mtime;
30233023
istate->timestamp.nsec = ST_MTIME_NSEC(st);
@@ -3058,10 +3058,10 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l
30583058
* that is associated with the given "istate".
30593059
*/
30603060
trace2_region_enter_printf("index", "do_write_index", the_repository,
3061-
"%s", lock->tempfile->filename.buf);
3061+
"%s", get_lock_file_path(lock));
30623062
ret = do_write_index(istate, lock->tempfile, 0);
30633063
trace2_region_leave_printf("index", "do_write_index", the_repository,
3064-
"%s", lock->tempfile->filename.buf);
3064+
"%s", get_lock_file_path(lock));
30653065

30663066
if (ret)
30673067
return ret;
@@ -3158,10 +3158,10 @@ static int write_shared_index(struct index_state *istate,
31583158
move_cache_to_base_index(istate);
31593159

31603160
trace2_region_enter_printf("index", "shared/do_write_index",
3161-
the_repository, "%s", (*temp)->filename.buf);
3161+
the_repository, "%s", get_tempfile_path(*temp));
31623162
ret = do_write_index(si->base, *temp, 1);
31633163
trace2_region_leave_printf("index", "shared/do_write_index",
3164-
the_repository, "%s", (*temp)->filename.buf);
3164+
the_repository, "%s", get_tempfile_path(*temp));
31653165

31663166
if (ret)
31673167
return ret;

0 commit comments

Comments
 (0)