commit 4847cca148b9969c7270f53e12008d8be7dd01a7 from: Stefan Sperling date: Mon Mar 12 19:56:31 2018 UTC make is_git_repo() check for a usable HEAD reference commit - 4986b9d5fdccbfe5567643b87d0c855fc7eca8b0 commit + 4847cca148b9969c7270f53e12008d8be7dd01a7 blob - 96fa4ce373bd26fae26fa0ef06ec8d581f1b0d3a blob + 1dc1c5a51c6686f80d8a7431f508604a99e48c30 --- lib/repository.c +++ lib/repository.c @@ -108,6 +108,7 @@ is_git_repo(struct got_repository *repo) char *path_head = get_path_head(repo); int ret = 0; struct stat sb; + struct got_reference *head_ref; if (lstat(path_git, &sb) == -1) goto done; @@ -128,6 +129,12 @@ is_git_repo(struct got_repository *repo) goto done; if (!S_ISREG(sb.st_mode)) goto done; + + /* Check if the HEAD reference can be opened. */ + if (got_ref_open(&head_ref, repo, GOT_REF_HEAD) != NULL) + goto done; + got_ref_close(head_ref); + ret = 1; done: free(path_git);