mirror of
https://github.com/git/git.git
synced 2024-05-11 14:46:08 +02:00
Merge branch 'ma/more-opaque-lock-file' into next
Code clean-up. * ma/more-opaque-lock-file: read-cache: try not to peek into `struct {lock_,temp}file` refs/files-backend: don't peek into `struct lock_file` midx: don't peek into `struct lock_file` commit-graph: don't peek into `struct lock_file` builtin/gc: don't peek into `struct lock_file`
This commit is contained in:
commit
f246e38b50
|
@ -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);
|
||||
|
@ -1953,11 +1953,11 @@ static int update_background_schedule(int enable)
|
|||
return error(_("another process is scheduling background maintenance"));
|
||||
|
||||
if (!strcmp(scheduler, "launchctl"))
|
||||
result = launchctl_update_schedule(enable, lk.tempfile->fd, cmd);
|
||||
result = launchctl_update_schedule(enable, get_lock_file_fd(&lk), cmd);
|
||||
else if (!strcmp(scheduler, "schtasks"))
|
||||
result = schtasks_update_schedule(enable, lk.tempfile->fd, cmd);
|
||||
result = schtasks_update_schedule(enable, get_lock_file_fd(&lk), cmd);
|
||||
else if (!strcmp(scheduler, "crontab"))
|
||||
result = crontab_update_schedule(enable, lk.tempfile->fd, cmd);
|
||||
result = crontab_update_schedule(enable, get_lock_file_fd(&lk), cmd);
|
||||
else
|
||||
die("unknown background scheduler: %s", scheduler);
|
||||
|
||||
|
|
|
@ -1694,8 +1694,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
|
|||
} else {
|
||||
hold_lock_file_for_update_mode(&lk, ctx->graph_name,
|
||||
LOCK_DIE_ON_ERROR, 0444);
|
||||
fd = lk.tempfile->fd;
|
||||
f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
|
||||
fd = get_lock_file_fd(&lk);
|
||||
f = hashfd(fd, get_lock_file_path(&lk));
|
||||
}
|
||||
|
||||
chunks[0].id = GRAPH_CHUNKID_OIDFANOUT;
|
||||
|
@ -1833,7 +1833,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
|
|||
result = rename(ctx->graph_name, final_graph_name);
|
||||
|
||||
for (i = 0; i < ctx->num_commit_graphs_after; i++)
|
||||
fprintf(lk.tempfile->fp, "%s\n", ctx->commit_graph_hash_after[i]);
|
||||
fprintf(get_lock_file_fp(&lk), "%s\n", ctx->commit_graph_hash_after[i]);
|
||||
|
||||
if (result) {
|
||||
error(_("failed to rename temporary commit-graph file"));
|
||||
|
|
2
midx.c
2
midx.c
|
@ -918,7 +918,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
|
|||
(pack_name_concat_len % MIDX_CHUNK_ALIGNMENT);
|
||||
|
||||
hold_lock_file_for_update(&lk, midx_name, LOCK_DIE_ON_ERROR);
|
||||
f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
|
||||
f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
|
||||
FREE_AND_NULL(midx_name);
|
||||
|
||||
if (packs.m)
|
||||
|
|
12
read-cache.c
12
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;
|
||||
|
|
|
@ -1824,12 +1824,12 @@ static int create_symref_locked(struct files_ref_store *refs,
|
|||
|
||||
if (!fdopen_lock_file(&lock->lk, "w"))
|
||||
return error("unable to fdopen %s: %s",
|
||||
lock->lk.tempfile->filename.buf, strerror(errno));
|
||||
get_lock_file_path(&lock->lk), strerror(errno));
|
||||
|
||||
update_symref_reflog(refs, lock, refname, target, logmsg);
|
||||
|
||||
/* no error check; commit_ref will check ferror */
|
||||
fprintf(lock->lk.tempfile->fp, "ref: %s\n", target);
|
||||
fprintf(get_lock_file_fp(&lock->lk), "ref: %s\n", target);
|
||||
if (commit_ref(lock) < 0)
|
||||
return error("unable to write symref for %s: %s", refname,
|
||||
strerror(errno));
|
||||
|
|
Loading…
Reference in New Issue