Thread (48 messages) flat view 48 messages, 1 author, 2016-06-15
STALE3753d

[PATCH 11/20] worktree.c: recognize no main worktree

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 23:08:04
Subsystem: the rest · Maintainer: Linus Torvalds

Because HEAD is part of repository signature, even if it's per-worktree
file, we can't simply delete it. So main worktree is considered gone if
.git/HEAD contains all-zero SHA-1.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 worktree.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/worktree.c b/worktree.c
index e878f49..80c525b 100644
--- a/worktree.c
+++ b/worktree.c
@@ -49,6 +49,8 @@ static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached)
 		if (!starts_with(ref->buf, "ref:")) {
 			if (is_detached)
 				*is_detached = 1;
+			if (starts_with(ref->buf, sha1_to_hex(null_sha1)))
+				return -1;
 		} else {
 			strbuf_remove(ref, 0, strlen("ref:"));
 			strbuf_trim(ref);
-- 
2.7.0.377.g4cd97dd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help