@@ -8,24 +8,32 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
88. ./test-lib.sh
99
1010print_all_reflog_entries () {
11- repo=$1 &&
12- test-tool -C " $repo " ref-store main for-each-reflog > reflogs &&
11+ repo_flag=$1 &&
12+ repo=$2 &&
13+ test-tool " $repo_flag " " $repo " ref-store main for-each-reflog > reflogs &&
1314 while read reflog
1415 do
1516 echo " REFLOG: $reflog " &&
16- test-tool -C " $repo " ref-store main for-each-reflog-ent " $reflog " ||
17+ test-tool " $repo_flag " " $repo " ref-store main for-each-reflog-ent " $reflog " ||
1718 return 1
1819 done < reflogs
1920}
2021
2122# Migrate the provided repository from one format to the other and
2223# verify that the references and logs are migrated over correctly.
23- # Usage: test_migration <repo> <format> [<skip_reflog_verify> [<options...>]]
24+ # Usage: test_migration [--git-dir] <repo> <format> [<skip_reflog_verify> [<options...>]]
25+ # --git-dir: treat <repo> as a git directory (for bare repositories).
2426# <repo> is the relative path to the repo to be migrated.
2527# <format> is the ref format to be migrated to.
2628# <skip_reflog_verify> (default: false) whether to skip reflog verification.
2729# <options...> are other options be passed directly to 'git refs migrate'.
2830test_migration () {
31+ repo_flag=-C &&
32+ if test " $1 " = " --git-dir"
33+ then
34+ repo_flag=--git-dir &&
35+ shift
36+ fi &&
2937 repo=$1 &&
3038 format=$2 &&
3139 shift 2 &&
@@ -35,25 +43,25 @@ test_migration () {
3543 skip_reflog_verify=$1
3644 shift
3745 fi &&
38- git -C " $repo " for-each-ref --include-root-refs \
46+ git " $repo_flag " " $repo " for-each-ref --include-root-refs \
3947 --format=' %(refname) %(objectname) %(symref)' > expect &&
4048 if ! $skip_reflog_verify
4149 then
42- print_all_reflog_entries " $repo " > expect_logs
50+ print_all_reflog_entries " $repo_flag " " $ repo" > expect_logs
4351 fi &&
4452
45- git -C " $repo " refs migrate --ref-format=" $format " " $@ " &&
53+ git " $repo_flag " " $repo " refs migrate --ref-format=" $format " " $@ " &&
4654
47- git -C " $repo " for-each-ref --include-root-refs \
55+ git " $repo_flag " " $repo " for-each-ref --include-root-refs \
4856 --format=' %(refname) %(objectname) %(symref)' > actual &&
4957 test_cmp expect actual &&
5058 if ! $skip_reflog_verify
5159 then
52- print_all_reflog_entries " $repo " > actual_logs &&
60+ print_all_reflog_entries " $repo_flag " " $ repo" > actual_logs &&
5361 test_cmp expect_logs actual_logs
5462 fi &&
5563
56- git -C " $repo " rev-parse --show-ref-format > actual &&
64+ git " $repo_flag " " $repo " rev-parse --show-ref-format > actual &&
5765 echo " $format " > expect &&
5866 test_cmp expect actual
5967}
144152 git init --ref-format=$from_format repo &&
145153 test_commit -C repo initial &&
146154 git clone --ref-format=$from_format --mirror repo repo.git &&
147- test_migration repo.git "$to_format"
155+ test_migration --git-dir repo.git "$to_format"
148156 '
149157
150158 test_expect_success " $from_format -> $to_format : dangling symref" '
0 commit comments