All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] set_worktree_head_symref(): fix error message
@ 2016-04-08  8:03 Kazuki Yamaguchi
  2016-04-08 17:26 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Kazuki Yamaguchi @ 2016-04-08  8:03 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Junio C Hamano, Kazuki Yamaguchi

Emit an informative error when failed to hold lock of HEAD.

2233066 (refs: add a new function set_worktree_head_symref) 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>
---
I'm sorry, this is my mistake in my previous patch which is already
merged to 'next':
- 2233066 (refs: add a new function set_worktree_head_symref)
- http://thread.gmane.org/gmane.comp.version-control.git/289413/focus=290008

This applies on top of ky/branch-m-worktree.

Thanks,

 refs/files-backend.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index ec237efec35d..ea78ce9d90f0 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);
-- 
2.8.0.rc4.18.g70999e9.dirty

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] set_worktree_head_symref(): fix error message
  2016-04-08  8:03 [PATCH] set_worktree_head_symref(): fix error message Kazuki Yamaguchi
@ 2016-04-08 17:26 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2016-04-08 17:26 UTC (permalink / raw)
  To: Kazuki Yamaguchi; +Cc: git, Eric Sunshine

Thanks.  Will queue.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-08 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08  8:03 [PATCH] set_worktree_head_symref(): fix error message Kazuki Yamaguchi
2016-04-08 17:26 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.