]> git.ipfire.org Git - thirdparty/git.git/commit - shallow.c
shallow: automatically clean up shallow tempfiles
authorJeff King <peff@peff.net>
Thu, 27 Feb 2014 11:25:20 +0000 (06:25 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 20:07:13 +0000 (12:07 -0800)
commit0179c945fce361c56b465e8a3f0fdf0962a816a1
tree714556b0cbd64a39b374adc71484bc3e4e4a5a05
parent0cc77c386cea7afebb54a5e7263ca37569ecfe7a
shallow: automatically clean up shallow tempfiles

We sometimes write tempfiles of the form "shallow_XXXXXX"
during fetch/push operations with shallow repositories.
Under normal circumstances, we clean up the result when we
are done. However, we do no take steps to clean up after
ourselves when we exit due to die() or signal death.

This patch teaches the tempfile creation code to register
handlers to clean up after ourselves. To handle this, we
change the ownership semantics of the filename returned by
setup_temporary_shallow. It now keeps a copy of the filename
itself, and returns only a const pointer to it.

We can also do away with explicit tempfile removal in the
callers. They all exit not long after finishing with the
file, so they can rely on the auto-cleanup, simplifying the
code.

Note that we keep things simple and maintain only a single
filename to be cleaned. This is sufficient for the current
caller, but we future-proof it with a die("BUG").

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c
commit.h
fetch-pack.c
shallow.c
upload-pack.c