builtin/gc: don't peek into `struct lock_file`
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> Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Ågren committed
Jan 5, 2021 at 20:23 UTC
d4a497664875c84c4ab8318625bb8881508ac18a
1 file changed
+3
-3
builtin/gc.c
+3
-3
@@ -92,7 +92,7 @@ static void process_log_file(void)
92
*/
93
int saved_errno = errno;
94
fprintf(stderr, _("Failed to fstat %s: %s"),
95
- get_tempfile_path(log_lock.tempfile),
95
+ get_lock_file_path(&log_lock),
96
strerror(saved_errno));
97
fflush(stderr);
98
commit_lock_file(&log_lock);
@@ -1518,7 +1518,7 @@ static int update_background_schedule(int run_maintenance)
1518
strvec_split(&crontab_list.args, crontab_name);
1519
strvec_push(&crontab_list.args, "-l");
1520
crontab_list.in = -1;
1521
- crontab_list.out = dup(lk.tempfile->fd);
1521
+ crontab_list.out = dup(get_lock_file_fd(&lk));
1522
crontab_list.git_cmd = 0;
1523
1524
if (start_command(&crontab_list)) {
@@ -1533,7 +1533,7 @@ static int update_background_schedule(int run_maintenance)
1533
* Read from the .lock file, filtering out the old
1534
* schedule while appending the new schedule.
1535
*/
1536
- cron_list = fdopen(lk.tempfile->fd, "r");
1536
+ cron_list = fdopen(get_lock_file_fd(&lk), "r");
1537
rewind(cron_list);
1538
1539
strvec_split(&crontab_edit.args, crontab_name);