Skip to content

Commit 18eb3a9

Browse files
rheniumgitster
authored andcommitted
set_worktree_head_symref(): fix error message
Emit an informative error when failed to hold lock of HEAD. 2233066 (refs: add a new function set_worktree_head_symref, 2016-03-27) added set_worktree_head_symref(), but this is missing a call to unable_to_lock_message() after hold_lock_file_for_update() fails, so it emits an empty error message: % git branch -m oldname newname error: error: HEAD of working tree /path/to/wt is not updated fatal: Branch renamed to newname, but HEAD is not updated! Thanks to Eric Sunshine for pointing this out. Signed-off-by: Kazuki Yamaguchi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 70999e9 commit 18eb3a9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

refs/files-backend.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2898,14 +2898,15 @@ int set_worktree_head_symref(const char *gitdir, const char *target)
28982898
{
28992899
static struct lock_file head_lock;
29002900
struct ref_lock *lock;
2901-
struct strbuf err = STRBUF_INIT;
29022901
struct strbuf head_path = STRBUF_INIT;
29032902
const char *head_rel;
29042903
int ret;
29052904

29062905
strbuf_addf(&head_path, "%s/HEAD", absolute_path(gitdir));
29072906
if (hold_lock_file_for_update(&head_lock, head_path.buf,
29082907
LOCK_NO_DEREF) < 0) {
2908+
struct strbuf err = STRBUF_INIT;
2909+
unable_to_lock_message(head_path.buf, errno, &err);
29092910
error("%s", err.buf);
29102911
strbuf_release(&err);
29112912
strbuf_release(&head_path);

0 commit comments

Comments
 (0)