diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-03-22 00:18:55 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-03-22 00:18:55 +0300 |
commit | ea09dff59a99ff78a36e79fa1a27a509c75be852 (patch) | |
tree | 35d169be1c015d844f57d039cd574fcf862a0e54 /builtin/receive-pack.c | |
parent | 1071deae006ab5b43ee530ee681eb20a7accc020 (diff) | |
parent | c55c30669ced6e08b41b3c921f0da200247c9811 (diff) |
Merge branch 'ps/receive-pack-unlock-before-die'
"git receive-pack" that responds to "git push" requests failed to
clean a stale lockfile when killed in the middle, which has been
corrected.
* ps/receive-pack-unlock-before-die:
receive-pack: fix stale packfile locks when dying
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r-- | builtin/receive-pack.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 6a24ab4f45..cccdb73807 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2183,7 +2183,7 @@ static const char *parse_pack_header(struct pack_header *hdr) } } -static const char *pack_lockfile; +static struct tempfile *pack_lockfile; static void push_header_arg(struct strvec *args, struct pack_header *hdr) { @@ -2250,6 +2250,7 @@ static const char *unpack(int err_fd, struct shallow_info *si) return "unpack-objects abnormal exit"; } else { char hostname[HOST_NAME_MAX + 1]; + char *lockfile; strvec_pushl(&child.args, "index-pack", "--stdin", NULL); push_header_arg(&child.args, &hdr); @@ -2279,8 +2280,14 @@ static const char *unpack(int err_fd, struct shallow_info *si) status = start_command(&child); if (status) return "index-pack fork failed"; - pack_lockfile = index_pack_lockfile(child.out, NULL); + + lockfile = index_pack_lockfile(child.out, NULL); + if (lockfile) { + pack_lockfile = register_tempfile(lockfile); + free(lockfile); + } close(child.out); + status = finish_command(&child); if (status) return "index-pack abnormal exit"; @@ -2567,8 +2574,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) use_keepalive = KEEPALIVE_ALWAYS; execute_commands(commands, unpack_status, &si, &push_options); - if (pack_lockfile) - unlink_or_warn(pack_lockfile); + delete_tempfile(&pack_lockfile); sigchain_push(SIGPIPE, SIG_IGN); if (report_status_v2) report_v2(commands, unpack_status); |