diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-08 17:03:07 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-08 10:26:23 -0700 |
commit | 18eb3a9ce7c544e74d424b942c5a5c9720c20112 (patch) | |
tree | 60afd33c1692739a11119cc7014723391eab1968 | |
parent | branch -m: update all per-worktree HEADs (diff) | |
download | tgif-18eb3a9ce7c544e74d424b942c5a5c9720c20112.tar.xz |
set_worktree_head_symref(): fix error message
Emit an informative error when failed to hold lock of HEAD.
2233066e (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 <k@rhe.jp>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | refs/files-backend.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index ec237efec3..ea78ce9d90 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2898,7 +2898,6 @@ int set_worktree_head_symref(const char *gitdir, const char *target) { static struct lock_file head_lock; struct ref_lock *lock; - struct strbuf err = STRBUF_INIT; struct strbuf head_path = STRBUF_INIT; const char *head_rel; int ret; @@ -2906,6 +2905,8 @@ int set_worktree_head_symref(const char *gitdir, const char *target) strbuf_addf(&head_path, "%s/HEAD", absolute_path(gitdir)); if (hold_lock_file_for_update(&head_lock, head_path.buf, LOCK_NO_DEREF) < 0) { + struct strbuf err = STRBUF_INIT; + unable_to_lock_message(head_path.buf, errno, &err); error("%s", err.buf); strbuf_release(&err); strbuf_release(&head_path); |