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 1/5] builtin/gc: don't peek into `struct lock_file`
Date: Tue, 5 Jan 2021 20:23:46 +0100 [thread overview]
Message-ID: <bbf24f7677eed41b80562d153b35be314cfb2750.1609874026.git.martin.agren@gmail.com> (raw)
In-Reply-To: <cover.1609874026.git.martin.agren@gmail.com>
A `struct lock_file` is pretty much just a wrapper around a tempfile.
But it's easy enough to avoid relying on this. Use the wrappers that the
lock file API provides rather than peeking at the temp file or even into
*its* internals.
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
builtin/gc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 4c24f41852..64f2b52d6e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -92,7 +92,7 @@ static void process_log_file(void)
*/
int saved_errno = errno;
fprintf(stderr, _("Failed to fstat %s: %s"),
- get_tempfile_path(log_lock.tempfile),
+ get_lock_file_path(&log_lock),
strerror(saved_errno));
fflush(stderr);
commit_lock_file(&log_lock);
@@ -1518,7 +1518,7 @@ static int update_background_schedule(int run_maintenance)
strvec_split(&crontab_list.args, crontab_name);
strvec_push(&crontab_list.args, "-l");
crontab_list.in = -1;
- crontab_list.out = dup(lk.tempfile->fd);
+ crontab_list.out = dup(get_lock_file_fd(&lk));
crontab_list.git_cmd = 0;
if (start_command(&crontab_list)) {
@@ -1533,7 +1533,7 @@ static int update_background_schedule(int run_maintenance)
* Read from the .lock file, filtering out the old
* schedule while appending the new schedule.
*/
- cron_list = fdopen(lk.tempfile->fd, "r");
+ cron_list = fdopen(get_lock_file_fd(&lk), "r");
rewind(cron_list);
strvec_split(&crontab_edit.args, crontab_name);
--
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 ` Martin Ågren [this message]
2021-01-05 19:23 ` [PATCH 2/5] commit-graph: don't peek " 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 ` [PATCH 5/5] read-cache: try not to peek into `struct {lock_,temp}file` Martin Ågren
2021-01-06 2:16 ` [PATCH 0/5] avoid peeking into `struct lock_file` 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=bbf24f7677eed41b80562d153b35be314cfb2750.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).