clone: test bare clone namespaced repo with no HEAD

Test that we can successfully clone a repository that is namespace
scoped to a bare repository locally. We need not specify a checkout
branch in this case (obviously, since we do not check anything out in a
bare clone).
This commit is contained in:
Edward Thomson
2022-09-16 14:27:13 -04:00
parent c928d96ea4
commit 9d9a90ad3d
38 changed files with 91 additions and 9 deletions

View File

@@ -22,9 +22,14 @@ CONTINUE_ON_FAILURE=0
cleanup() {
echo "Cleaning up..."
if [ ! -z "$GITDAEMON_PID" ]; then
echo "Stopping git daemon..."
kill $GITDAEMON_PID
if [ ! -z "$GIT_STANDARD_PID" ]; then
echo "Stopping git daemon (standard)..."
kill $GIT_STANDARD_PID
fi
if [ ! -z "$GIT_NAMESPACE_PID" ]; then
echo "Stopping git daemon (namespace)..."
kill $GIT_NAMESPACE_PID
fi
if [ ! -z "$PROXY_BASIC_PID" ]; then
@@ -98,11 +103,17 @@ echo "##########################################################################
echo ""
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo "Starting git daemon..."
GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
git init --bare "${GITDAEMON_DIR}/test.git" >/dev/null
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
GITDAEMON_PID=$!
echo "Starting git daemon (standard)..."
GIT_STANDARD_DIR=`mktemp -d ${TMPDIR}/git_standard.XXXXXXXX`
git init --bare "${GIT_STANDARD_DIR}/test.git" >/dev/null
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GIT_STANDARD_DIR}" "${GIT_STANDARD_DIR}" 2>/dev/null &
GIT_STANDARD_PID=$!
echo "Starting git daemon (namespace)..."
GIT_NAMESPACE_DIR=`mktemp -d ${TMPDIR}/git_namespace.XXXXXXXX`
cp -R "${SOURCE_DIR}/tests/resources/namespace.git" "${GIT_NAMESPACE_DIR}/namespace.git"
GIT_NAMESPACE="name1" git daemon --listen=localhost --port=9419 --export-all --enable=receive-pack --base-path="${GIT_NAMESPACE_DIR}" "${GIT_NAMESPACE_DIR}" &
GIT_NAMESPACE_PID=$!
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
@@ -229,12 +240,20 @@ fi
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo ""
echo "Running gitdaemon tests"
echo "Running gitdaemon (standard) tests"
echo ""
export GITTEST_REMOTE_URL="git://localhost/test.git"
run_test gitdaemon
unset GITTEST_REMOTE_URL
echo ""
echo "Running gitdaemon (namespace) tests"
echo ""
export GITTEST_REMOTE_URL="git://localhost:9419/namespace.git"
run_test gitdaemon_namespace
unset GITTEST_REMOTE_URL
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then

View File

@@ -69,6 +69,7 @@ add_clar_test(libgit2_tests invasive -v -sfilter::stream::bigfile -so
add_clar_test(libgit2_tests online -v -sonline -xonline::customcert)
add_clar_test(libgit2_tests online_customcert -v -sonline::customcert)
add_clar_test(libgit2_tests gitdaemon -v -sonline::push)
add_clar_test(libgit2_tests gitdaemon_namespace -v -sonline::clone::namespace)
add_clar_test(libgit2_tests ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
add_clar_test(libgit2_tests proxy -v -sonline::clone::proxy)
add_clar_test(libgit2_tests auth_clone -v -sonline::clone::cred)

View File

@@ -1006,3 +1006,22 @@ void test_online_clone__redirect_initial_fails_for_subsequent(void)
cl_git_fail(git_clone(&g_repo, _remote_redirect_subsequent, "./fail", &options));
}
void test_online_clone__namespace_bare(void)
{
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
git_reference *head;
if (!_remote_url)
cl_skip();
options.bare = true;
cl_git_pass(git_clone(&g_repo, _remote_url, "./namespaced.git", &options));
cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE));
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head));
cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
git_reference_free(head);
}

View File

@@ -0,0 +1 @@
four

1
tests/resources/namespace.git/HEAD vendored Normal file
View File

@@ -0,0 +1 @@
ref: refs/heads/four

7
tests/resources/namespace.git/config vendored Normal file
View File

@@ -0,0 +1,7 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true

View File

@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

BIN
tests/resources/namespace.git/index vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

View File

@@ -0,0 +1,9 @@
0000000000000000000000000000000000000000 9ebfa6bdc9d38075d29d26aa5df89b1cf635b269 Edward Thomson <ethomson@edwardthomson.com> 1661110058 -0400 commit (initial): Hello, world.
9ebfa6bdc9d38075d29d26aa5df89b1cf635b269 7eeaa70d7c5592db920a2e107ce3918bd4c8a425 Edward Thomson <ethomson@edwardthomson.com> 1661110068 -0400 commit: with enthusiasm
7eeaa70d7c5592db920a2e107ce3918bd4c8a425 7eeaa70d7c5592db920a2e107ce3918bd4c8a425 Edward Thomson <ethomson@edwardthomson.com> 1661110072 -0400 checkout: moving from main to branch
7eeaa70d7c5592db920a2e107ce3918bd4c8a425 3d669d1b33ec8add4609d8043d025527db4989eb Edward Thomson <ethomson@edwardthomson.com> 1661110088 -0400 commit: capitalize
3d669d1b33ec8add4609d8043d025527db4989eb bfd17f429f4e2d121769213171ad57ca2e5173f9 Edward Thomson <ethomson@edwardthomson.com> 1661110104 -0400 commit: less enthusiastic
bfd17f429f4e2d121769213171ad57ca2e5173f9 7eeaa70d7c5592db920a2e107ce3918bd4c8a425 Edward Thomson <ethomson@edwardthomson.com> 1661110107 -0400 checkout: moving from branch to main
0000000000000000000000000000000000000000 420d51ce75a87909e29659da2072ffd3d5daf5b7 Edward Thomson <ethomson@edwardthomson.com> 1661110166 -0400 commit (initial): 1 2 3
420d51ce75a87909e29659da2072ffd3d5daf5b7 420d51ce75a87909e29659da2072ffd3d5daf5b7 Edward Thomson <ethomson@edwardthomson.com> 1661110209 -0400 checkout: moving from one to four
420d51ce75a87909e29659da2072ffd3d5daf5b7 04433ff5b52d6ad534fd6288de4a57b81cc12188 Edward Thomson <ethomson@edwardthomson.com> 1661110212 -0400 commit: four

View File

@@ -0,0 +1,3 @@
0000000000000000000000000000000000000000 7eeaa70d7c5592db920a2e107ce3918bd4c8a425 Edward Thomson <ethomson@edwardthomson.com> 1661110072 -0400 branch: Created from HEAD
7eeaa70d7c5592db920a2e107ce3918bd4c8a425 3d669d1b33ec8add4609d8043d025527db4989eb Edward Thomson <ethomson@edwardthomson.com> 1661110088 -0400 commit: capitalize
3d669d1b33ec8add4609d8043d025527db4989eb bfd17f429f4e2d121769213171ad57ca2e5173f9 Edward Thomson <ethomson@edwardthomson.com> 1661110104 -0400 commit: less enthusiastic

View File

@@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 420d51ce75a87909e29659da2072ffd3d5daf5b7 Edward Thomson <ethomson@edwardthomson.com> 1661110209 -0400 branch: Created from HEAD
420d51ce75a87909e29659da2072ffd3d5daf5b7 04433ff5b52d6ad534fd6288de4a57b81cc12188 Edward Thomson <ethomson@edwardthomson.com> 1661110212 -0400 commit: four

View File

@@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 9ebfa6bdc9d38075d29d26aa5df89b1cf635b269 Edward Thomson <ethomson@edwardthomson.com> 1661110058 -0400 commit (initial): Hello, world.
9ebfa6bdc9d38075d29d26aa5df89b1cf635b269 7eeaa70d7c5592db920a2e107ce3918bd4c8a425 Edward Thomson <ethomson@edwardthomson.com> 1661110068 -0400 commit: with enthusiasm

View File

@@ -0,0 +1 @@
0000000000000000000000000000000000000000 420d51ce75a87909e29659da2072ffd3d5daf5b7 Edward Thomson <ethomson@edwardthomson.com> 1661110166 -0400 commit (initial): 1 2 3

View File

@@ -0,0 +1,2 @@
x¥ŽQ
Â0DýÎ)re“&ÝDüñ^`ÝÐiJ<69>žÞ*ÞÀ¿™÷`˜TK™š¶ÎïÚ*¢%E‡Ò1#!zË€!aH™<05>ÇÁš,ÙµÐ*sÓ(B„À˜¼<CB9C>‡h<E280A1>¬À$]4a`—=ÚXW}á'­¬¯c-÷:ë£lô“Îò¿vHµœ´é{c @z@mt;ÛäÏ•h™ݦ—¨7-)Q

View File

@@ -0,0 +1,2 @@
xҐЋ]В „}ж{НІ
‰1ѕx/°ь4нЕPљ^_4ЮА·™o2“ %зҐi<µљРа} l=bfҐмG«$MЈВ наЁSdсвљЦ.щ‰MЇёЁ,Ћ:d<E280B9>uњ¬у2LFiOЖ ЮЫ\*<вБ5Вs.y++\S§uOЯаз.ЎдHc¤”€ЖВDСi?ЫТџ3вXЪ ээјo oYјw

View File

@@ -0,0 +1,2 @@
xҐЋ]
В0„}ОКжЧ €шв ј@љЭТ5¤x}«xЯfѕЃбЛeYжЖ›]Ї"Ђ‰"¬Св@c`т2ІсЦM.{"’ ћ©КЈѓе"лБZЙ”<D099>]АИ„О2пН‘)К ТЪ§RбКЇTnSYZyАI6ъIщїvИe9ѓAkЌмС!ЄЌnІјQwi 6ыimsj}Ок Ј•RМ

View File

@@ -0,0 +1 @@
bfd17f429f4e2d121769213171ad57ca2e5173f9

View File

@@ -0,0 +1 @@
7eeaa70d7c5592db920a2e107ce3918bd4c8a425

View File

@@ -0,0 +1 @@
04433ff5b52d6ad534fd6288de4a57b81cc12188

View File

@@ -0,0 +1 @@
420d51ce75a87909e29659da2072ffd3d5daf5b7