From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Cc: Alban Gruin <alban.gruin@gmail.com>, Derrick Stolee <stolee@gmail.com>
Subject: [PATCH 5/5] read-cache: try not to peek into `struct {lock_,temp}file`
Date: Tue, 5 Jan 2021 20:23:50 +0100 [thread overview]
Message-ID: <bb2327c7dca20fa563b18a9ec74180d7c595ca24.1609874026.git.martin.agren@gmail.com> (raw)
In-Reply-To: <cover.1609874026.git.martin.agren@gmail.com>
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 <martin.agren@gmail.com>
---
read-cache.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index ecf6f68994..29144cf879 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3014,10 +3014,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
if (ce_flush(&c, newfd, istate->oid.hash))
return -1;
if (close_tempfile_gently(tempfile)) {
- error(_("could not close '%s'"), tempfile->filename.buf);
+ error(_("could not close '%s'"), get_tempfile_path(tempfile));
return -1;
}
- if (stat(tempfile->filename.buf, &st))
+ if (stat(get_tempfile_path(tempfile), &st))
return -1;
istate->timestamp.sec = (unsigned int)st.st_mtime;
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
* that is associated with the given "istate".
*/
trace2_region_enter_printf("index", "do_write_index", the_repository,
- "%s", lock->tempfile->filename.buf);
+ "%s", get_lock_file_path(lock));
ret = do_write_index(istate, lock->tempfile, 0);
trace2_region_leave_printf("index", "do_write_index", the_repository,
- "%s", lock->tempfile->filename.buf);
+ "%s", get_lock_file_path(lock));
if (ret)
return ret;
@@ -3158,10 +3158,10 @@ static int write_shared_index(struct index_state *istate,
move_cache_to_base_index(istate);
trace2_region_enter_printf("index", "shared/do_write_index",
- the_repository, "%s", (*temp)->filename.buf);
+ the_repository, "%s", get_tempfile_path(*temp));
ret = do_write_index(si->base, *temp, 1);
trace2_region_leave_printf("index", "shared/do_write_index",
- the_repository, "%s", (*temp)->filename.buf);
+ the_repository, "%s", get_tempfile_path(*temp));
if (ret)
return ret;
--
2.30.0
next prev parent reply other threads:[~2021-01-05 19:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-05 19:23 [PATCH 0/5] avoid peeking into `struct lock_file` Martin Ågren
2021-01-05 19:23 ` [PATCH 1/5] builtin/gc: don't peek " Martin Ågren
2021-01-05 19:23 ` [PATCH 2/5] commit-graph: " Martin Ågren
2021-01-05 19:23 ` [PATCH 3/5] midx: " Martin Ågren
2021-01-05 19:23 ` [PATCH 4/5] refs/files-backend: " Martin Ågren
2021-01-05 19:23 ` Martin Ågren [this message]
2021-01-06 2:16 ` [PATCH 0/5] avoid peeking " Derrick Stolee
2021-01-06 11:55 ` Junio C Hamano
2021-01-06 22:36 ` Junio C Hamano
2021-01-07 2:08 ` Derrick Stolee
2021-01-07 7:55 ` Martin Ågren
2021-01-07 8:19 ` Junio C Hamano
2021-01-07 18:17 ` Martin Ågren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb2327c7dca20fa563b18a9ec74180d7c595ca24.1609874026.git.martin.agren@gmail.com \
--to=martin.agren@gmail.com \
--cc=alban.gruin@gmail.com \
--cc=git@vger.kernel.org \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).