diff --git a/path.c b/path.c index cd8e2d6e686e41f0a53479bf34d810a1a338650e..35d498e9bc33e1827178970c5136de3edc7e226a 100644 --- a/path.c +++ b/path.c @@ -103,7 +103,8 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len) char *base = buf->buf + git_dir_len; const char **p; - if (is_dir_file(base, "logs", "HEAD")) + if (is_dir_file(base, "logs", "HEAD") || + is_dir_file(base, "info", "sparse-checkout")) return; /* keep this in $GIT_DIR */ for (p = common_list; *p; p++) { const char *path = *p; diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index f5d6f80d66dd440335507348448eb2f235d67e44..93605f42f27cef9ef3ffe381c84aea9f6f4be426 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -270,6 +270,7 @@ test_git_path GIT_COMMON_DIR=bar objects bar/objects test_git_path GIT_COMMON_DIR=bar objects/bar bar/objects/bar test_git_path GIT_COMMON_DIR=bar info/exclude bar/info/exclude test_git_path GIT_COMMON_DIR=bar info/grafts bar/info/grafts +test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-checkout test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar test_git_path GIT_COMMON_DIR=bar logs/refs/heads/master bar/logs/refs/heads/master