Skip to content

Commit 2d20551

Browse files
authored
Merge pull request libgit2#3992 from joshtriplett/env-namespace
git_repository_open_ext: fix handling of $GIT_NAMESPACE
2 parents 1998146 + c9e967a commit 2d20551

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/repository.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,10 @@ static int _git_repository_open_ext_from_env(
613613
git_repository_set_odb(repo, odb);
614614

615615
error = git__getenv(&alts_buf, "GIT_ALTERNATE_OBJECT_DIRECTORIES");
616-
if (error == GIT_ENOTFOUND)
616+
if (error == GIT_ENOTFOUND) {
617617
giterr_clear();
618-
else if (error < 0)
618+
error = 0;
619+
} else if (error < 0)
619620
goto error;
620621
else {
621622
const char *end;
@@ -638,9 +639,11 @@ static int _git_repository_open_ext_from_env(
638639
}
639640
}
640641

641-
error = git_repository_set_namespace(repo, git_buf_cstr(&namespace_buf));
642-
if (error < 0)
643-
goto error;
642+
if (git_buf_len(&namespace_buf)) {
643+
error = git_repository_set_namespace(repo, git_buf_cstr(&namespace_buf));
644+
if (error < 0)
645+
goto error;
646+
}
644647

645648
git_repository_set_index(repo, index);
646649

0 commit comments

Comments
 (0)