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 <pclouds@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html