summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-03-18 18:55:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-19 20:38:07 (GMT)
commitee0e38727f1a67ddd3b8b7f6ecea34624b2a8b51 (patch)
tree5e92dca24ac8b8a57659b5a6bc58ad2da8614024 /utf8.h
parent282616c72d1d08a77ca4fe1186cb708c38408d87 (diff)
downloadgit-ee0e38727f1a67ddd3b8b7f6ecea34624b2a8b51.zip
git-ee0e38727f1a67ddd3b8b7f6ecea34624b2a8b51.tar.gz
git-ee0e38727f1a67ddd3b8b7f6ecea34624b2a8b51.tar.bz2
clone: initialize atexit cleanup handler earlier
If clone fails, we generally try to clean up any directories we've created. We do this by installing an atexit handler, so that we don't have to manually trigger cleanup. However, since we install this after touching the filesystem, any errors between our initial mkdir() and our atexit() call will result in us leaving a crufty directory around. We can fix this by moving our atexit() call earlier. It's OK to do it before the junk_work_tree variable is set, because remove_junk makes sure the variable is initialized. This means we "activate" the handler by assigning to the junk_work_tree variable, which we now bump down to just after we call mkdir(). We probably do not want to do it before, because a plausible reason for mkdir() to fail is EEXIST (i.e., we are racing with another "git init"), and we would not want to remove their work. OTOH, this is probably not that big a deal; we will allow cloning into an empty directory (and skip the mkdir), which is already racy (i.e., one clone may see the other's empty dir and start writing into it). Still, it does not hurt to err on the side of caution here. Note that writing into junk_work_tree and junk_git_dir after installing the handler is also technically racy, as we call our handler on an async signal. Depending on the platform, we could see a sheared write to the variables. Traditionally we have not worried about this, and indeed we already do this later in the function. If we want to address that, it can come as a separate topic. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'utf8.h')
0 files changed, 0 insertions, 0 deletions