{"thread":{"id":"41963","subject":"[PATCH] set_worktree_head_symref(): fix error message","startedAt":"2016-04-08T08:03:07Z","lastAt":"2016-04-08T17:26:54Z","messageCount":2,"participants":["Kazuki Yamaguchi","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"282942","messageId":"1460102587-22297-1-git-send-email-k@rhe.jp","threadId":"41963","inReplyTo":null,"subject":"[PATCH] set_worktree_head_symref(): fix error message","fromName":"Kazuki Yamaguchi","fromEmail":"k@rhe.jp","sentAt":"2016-04-08T08:03:07Z","receivedAt":"2016-04-08T08:03:07Z","isPatch":true,"sender":{"key":"k@rhe.jp","avatar":"https://avatars.githubusercontent.com/u/1033740?v=4"},"body":"Emit an informative error when failed to hold lock of HEAD.\n\n2233066 (refs: add a new function set_worktree_head_symref) added\nset_worktree_head_symref() but this is missing a call to\nunable_to_lock_message() after hold_lock_file_for_update() fails, so it\nemits an empty error message:\n\n  % git branch -m oldname newname\n  error:\n  error: HEAD of working tree /path/to/wt is not updated\n  fatal: Branch renamed to newname, but HEAD is not updated!\n\nThanks to Eric Sunshine for pointing this out.\n\nSigned-off-by: Kazuki Yamaguchi <k@rhe.jp>\n---\nI'm sorry, this is my mistake in my previous patch which is already\nmerged to 'next':\n- 2233066 (refs: add a new function set_worktree_head_symref)\n- http://thread.gmane.org/gmane.comp.version-control.git/289413/focus=290008\n\nThis applies on top of ky/branch-m-worktree.\n\nThanks,\n\n refs/files-backend.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex ec237efec35d..ea78ce9d90f0 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2898,7 +2898,6 @@ int set_worktree_head_symref(const char *gitdir, const char *target)\n {\n \tstatic struct lock_file head_lock;\n \tstruct ref_lock *lock;\n-\tstruct strbuf err = STRBUF_INIT;\n \tstruct strbuf head_path = STRBUF_INIT;\n \tconst char *head_rel;\n \tint ret;\n@@ -2906,6 +2905,8 @@ int set_worktree_head_symref(const char *gitdir, const char *target)\n \tstrbuf_addf(&head_path, \"%s/HEAD\", absolute_path(gitdir));\n \tif (hold_lock_file_for_update(&head_lock, head_path.buf,\n \t\t\t\t      LOCK_NO_DEREF) < 0) {\n+\t\tstruct strbuf err = STRBUF_INIT;\n+\t\tunable_to_lock_message(head_path.buf, errno, &err);\n \t\terror(\"%s\", err.buf);\n \t\tstrbuf_release(&err);\n \t\tstrbuf_release(&head_path);\n-- \n2.8.0.rc4.18.g70999e9.dirty\n"},{"id":"282969","messageId":"xmqqvb3svwo1.fsf@gitster.mtv.corp.google.com","threadId":"41963","inReplyTo":"1460102587-22297-1-git-send-email-k@rhe.jp","subject":"Re: [PATCH] set_worktree_head_symref(): fix error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-08T17:26:54Z","receivedAt":"2016-04-08T17:26:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Will queue.\n"}]}