aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t1460-refs-migrate.sh73
1 files changed, 51 insertions, 22 deletions
diff --git a/t/t1460-refs-migrate.sh b/t/t1460-refs-migrate.sh
index 1bfff3a7af..f59bc4860f 100755
--- a/t/t1460-refs-migrate.sh
+++ b/t/t1460-refs-migrate.sh
@@ -7,23 +7,44 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
+# Migrate the provided repository from one format to the other and
+# verify that the references and logs are migrated over correctly.
+# Usage: test_migration <repo> <format> <skip_reflog_verify>
+# <repo> is the relative path to the repo to be migrated.
+# <format> is the ref format to be migrated to.
+# <skip_reflog_verify> (true or false) whether to skip reflog verification.
test_migration () {
- git -C "$1" for-each-ref --include-root-refs \
+ repo=$1 &&
+ format=$2 &&
+ skip_reflog_verify=${3:-false} &&
+ git -C "$repo" for-each-ref --include-root-refs \
--format='%(refname) %(objectname) %(symref)' >expect &&
- git -C "$1" refs migrate --ref-format="$2" &&
- git -C "$1" for-each-ref --include-root-refs \
+ if ! $skip_reflog_verify
+ then
+ git -C "$repo" reflog --all >expect_logs &&
+ git -C "$repo" reflog list >expect_log_list
+ fi &&
+
+ git -C "$repo" refs migrate --ref-format="$2" &&
+
+ git -C "$repo" for-each-ref --include-root-refs \
--format='%(refname) %(objectname) %(symref)' >actual &&
test_cmp expect actual &&
+ if ! $skip_reflog_verify
+ then
+ git -C "$repo" reflog --all >actual_logs &&
+ git -C "$repo" reflog list >actual_log_list &&
+ test_cmp expect_logs actual_logs &&
+ test_cmp expect_log_list actual_log_list
+ fi &&
- git -C "$1" rev-parse --show-ref-format >actual &&
- echo "$2" >expect &&
+ git -C "$repo" rev-parse --show-ref-format >actual &&
+ echo "$format" >expect &&
test_cmp expect actual
}
test_expect_success 'setup' '
- rm -rf .git &&
- # The migration does not yet support reflogs.
- git config --global core.logAllRefUpdates false
+ rm -rf .git
'
test_expect_success "superfluous arguments" '
@@ -78,19 +99,6 @@ do
test_cmp expect err
'
- test_expect_success "$from_format -> $to_format: migration with reflog fails" '
- test_when_finished "rm -rf repo" &&
- git init --ref-format=$from_format repo &&
- test_config -C repo core.logAllRefUpdates true &&
- test_commit -C repo logged &&
- test_must_fail git -C repo refs migrate \
- --ref-format=$to_format 2>err &&
- cat >expect <<-EOF &&
- error: migrating reflogs is not supported yet
- EOF
- test_cmp expect err
- '
-
test_expect_success "$from_format -> $to_format: migration with worktree fails" '
test_when_finished "rm -rf repo" &&
git init --ref-format=$from_format repo &&
@@ -141,7 +149,7 @@ do
test_commit -C repo initial &&
test-tool -C repo ref-store main update-ref "" refs/heads/broken \
"$(test_oid 001)" "$ZERO_OID" REF_SKIP_CREATE_REFLOG,REF_SKIP_OID_VERIFICATION &&
- test_migration repo "$to_format" &&
+ test_migration repo "$to_format" true &&
test_oid 001 >expect &&
git -C repo rev-parse refs/heads/broken >actual &&
test_cmp expect actual
@@ -195,6 +203,27 @@ do
git -C repo rev-parse --show-ref-format >actual &&
test_cmp expect actual
'
+
+ test_expect_success "$from_format -> $to_format: reflogs of symrefs with target deleted" '
+ test_when_finished "rm -rf repo" &&
+ git init --ref-format=$from_format repo &&
+ test_commit -C repo initial &&
+ git -C repo branch branch-1 HEAD &&
+ git -C repo symbolic-ref refs/heads/symref refs/heads/branch-1 &&
+ cat >input <<-EOF &&
+ delete refs/heads/branch-1
+ EOF
+ git -C repo update-ref --stdin <input &&
+ test_migration repo "$to_format"
+ '
+
+ test_expect_success "$from_format -> $to_format: reflogs order is retained" '
+ test_when_finished "rm -rf repo" &&
+ git init --ref-format=$from_format repo &&
+ test_commit --date "100005000 +0700" --no-tag -C repo initial &&
+ test_commit --date "100003000 +0700" --no-tag -C repo second &&
+ test_migration repo "$to_format"
+ '
done
done