Re: [PATCH] receive-pack: fix stale packfile locks when dying
Patrick Steinhardt <ps@pks.im> writes:
Show 22 quoted lines
> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index cd5c7a28ef..0a6030d775 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -2186,6 +2186,12 @@ static const char *parse_pack_header(struct pack_header *hdr)
>
> static const char *pack_lockfile;
>
> +static void unlink_pack_lockfile(void)
> +{
> + if (pack_lockfile)
> + unlink(pack_lockfile);
> +}
> +
> static void push_header_arg(struct strvec *args, struct pack_header *hdr)
> {
> strvec_pushf(args, "--pack_header=%"PRIu32",%"PRIu32,
> @@ -2281,6 +2287,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
> if (status)
> return "index-pack fork failed";
> pack_lockfile = index_pack_lockfile(child.out, NULL);
> + atexit(unlink_pack_lockfile);Hmph, why isn't this a straight application of tempfile API?