[PATCH 11/20] worktree.c: recognize no main worktree
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Feb 3, 2016, 09:35 UTC
- Message-ID
- <1454492150-10628-12-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1454492150-10628-1-git-send-email-pclouds@gmail.com>
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@gmail.com> --- 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