Re: [PATCH 1/2] checkout,clone: check return value of create_symref
From: Michael Haggerty <hidden>
Date: 2016-06-15 23:07:42
On 01/11/2016 04:49 PM, Jeff King wrote:
It's unlikely that we would fail to create or update a symbolic ref (especially HEAD), but if we do, we should notice and complain. Note that there's no need to give more details in our error message; create_symref will already have done so. While we're here, let's also fix a minor memory leak in clone. Signed-off-by: Jeff King <redacted>
LGTM.
---
This patch could go to maint. I don't know if it's worth the trouble. I
was unable to figure out a way to trigger this reliably (hence no
tests). The two ways I considered were:
- "chmod -w .git", but it results in a die() already
- the bug I'm fixing in 2/2; but we don't want to rely on that in our
test suite, since I'm about to fix it. :-/A locking conflict is an easy way to trigger this error: $ git --version git version 2.7.0.rc2.31.g396da8f $ git branch foo $ touch .git/HEAD.lock $ git checkout foo error: Unable to create '/home/mhagger/tmp/brokhead/.git/HEAD.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue. Switched to branch 'foo' $ echo $? 0 After this patch, the above "checkout" command fails with retcode=128. Michael -- Michael Haggerty mhagger@alum.mit.edu