@@ -9,14 +9,21 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
9
10
10
# Migrate the provided repository from one format to the other and
11
11
# verify that the references and logs are migrated over correctly.
12
- # Usage: test_migration <repo> <format> <skip_reflog_verify>
12
+ # Usage: test_migration <repo> <format> [ <skip_reflog_verify> [<options...>]]
13
13
# <repo> is the relative path to the repo to be migrated.
14
14
# <format> is the ref format to be migrated to.
15
- # <skip_reflog_verify> (true or false) whether to skip reflog verification.
15
+ # <skip_reflog_verify> (default: false) whether to skip reflog verification.
16
+ # <options...> are other options be passed directly to 'git refs migrate'.
16
17
test_migration () {
17
18
repo=$1 &&
18
19
format=$2 &&
19
- skip_reflog_verify=${3:- false} &&
20
+ shift 2 &&
21
+ skip_reflog_verify=false &&
22
+ if test $# -ge 1
23
+ then
24
+ skip_reflog_verify=$1
25
+ shift
26
+ fi &&
20
27
git -C " $repo " for-each-ref --include-root-refs \
21
28
--format=' %(refname) %(objectname) %(symref)' > expect &&
22
29
if ! $skip_reflog_verify
@@ -25,7 +32,7 @@ test_migration () {
25
32
git -C " $repo " reflog list > expect_log_list
26
33
fi &&
27
34
28
- git -C " $repo " refs migrate --ref-format=" $2 " &&
35
+ git -C " $repo " refs migrate --ref-format=" $format " " $@ " &&
29
36
30
37
git -C " $repo " for-each-ref --include-root-refs \
31
38
--format=' %(refname) %(objectname) %(symref)' > actual &&
241
248
test_cmp expect.reflog actual.reflog
242
249
)
243
250
'
251
+
252
+ test_expect_success " $from_format -> $to_format : skip reflog with --skip-reflog" '
253
+ test_when_finished "rm -rf repo" &&
254
+ git init --ref-format=$from_format repo &&
255
+ test_commit -C repo initial &&
256
+ # we see that the repository contains reflogs.
257
+ git -C repo reflog --all >reflogs &&
258
+ test_line_count = 2 reflogs &&
259
+ test_migration repo "$to_format" true --no-reflog &&
260
+ # there should be no reflogs post migration.
261
+ git -C repo reflog --all >reflogs &&
262
+ test_must_be_empty reflogs
263
+ '
244
264
done
245
265
done
246
266
0 commit comments