commit - c94b2859b3b5268adec2353832d0491a11382f83
commit + c22ed3f5d5d97db3f1d8fc8c649537c9033136f9
blob - 7578e3c914d6acd6881cd996f0fbd10c94745f47
blob + 8f5652bc11cd7acbd00b1be84dd5bb45e953f855
--- got/got.c
+++ got/got.c
if (error)
goto done;
break;
+ }
+
+ if (!fpa.configs_created && pe != NULL) {
+ error = create_config_files(fpa.config_info.proto,
+ fpa.config_info.host, fpa.config_info.port,
+ fpa.config_info.remote_repo_path,
+ fpa.config_info.git_url,
+ fpa.config_info.fetch_all_branches,
+ fpa.config_info.mirror_references,
+ fpa.config_info.symrefs,
+ fpa.config_info.wanted_branches,
+ fpa.config_info.wanted_refs, fpa.repo);
+ if (error)
+ goto done;
}
}
blob - 16b72acf9a498e271bc42310058798b44aa39782
blob + 8bc2915d90c8ece2b75b50b15d013841faaad3ef
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
break;
}
}
- continue;
+ if (default_branch)
+ continue;
}
if (strstr(refname, "^{}")) {
if (chattygot) {
blob - 35d7c0ba41e646078b5beea834a05d4d28891363
blob + 6881cc1cec543e7bfd4986adaba1e99620dfeabd
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
url = ssh://127.0.0.1$testroot/repo
fetch = refs/heads/foo:refs/remotes/origin/foo
fetch = refs/heads/bar:refs/remotes/origin/bar
+ fetch = refs/tags/*:refs/tags/*
+EOF
+ cmp -s $testroot/repo-clone/config $testroot/config.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/config.expected \
+ $testroot/repo-clone/config
+ fi
+ test_done "$testroot" "$ret"
+}
+
+test_clone_dangling_headref() {
+ local testroot=`test_init clone_dangling_headref`
+ local testurl=ssh://127.0.0.1/$testroot
+ local commit_id=`git_show_head $testroot/repo`
+
+ got branch -r $testroot/repo -d master > /dev/null
+ got branch -r $testroot/repo -c $commit_id foo
+
+ got ref -l -r $testroot/repo > $testroot/stdout
+
+ echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+ echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
+ # refs/heads/master is missing because it was deleted above
+
+ cmp -s $testroot/stdout $testroot/stdout.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got clone -q -b foo $testurl/repo $testroot/repo-clone
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got clone command failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got ref -l -r $testroot/repo-clone > $testroot/stdout
+
+ echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
+ echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
+ echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout $testroot/stdout.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cat > $testroot/got.conf.expected <<EOF
+remote "origin" {
+ server 127.0.0.1
+ protocol ssh
+ repository "$testroot/repo"
+ branch { "foo" }
+}
+EOF
+ cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/got.conf.expected \
+ $testroot/repo-clone/got.conf
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cat > $testroot/config.expected <<EOF
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = true
+
+[remote "origin"]
+ url = ssh://127.0.0.1$testroot/repo
+ fetch = refs/heads/foo:refs/remotes/origin/foo
fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
run_test test_clone_branch_and_reference
run_test test_clone_reference_mirror
run_test test_clone_multiple_branches
+run_test test_clone_dangling_headref