aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-11-27 07:57:08 +0900
committerJunio C Hamano <gitster@pobox.com>2024-11-27 07:57:08 +0900
commit8eaa06590fe916d4f2baa1fdb93959f1cfa9ab47 (patch)
treebae07cc5dc2973486420b8f64a611fb99d7c7031 /t
parentMerge branch 'kh/trailer-in-glossary' (diff)
parentfast-import: avoid making replace refs point to themselves (diff)
downloadgit-8eaa06590fe916d4f2baa1fdb93959f1cfa9ab47.tar.gz
git-8eaa06590fe916d4f2baa1fdb93959f1cfa9ab47.zip
Merge branch 'en/fast-import-avoid-self-replace'
"git fast-import" can be tricked into a replace ref that maps an object to itself, which is a useless thing to do. * en/fast-import-avoid-self-replace: fast-import: avoid making replace refs point to themselves
Diffstat (limited to 't')
-rwxr-xr-xt/t9300-fast-import.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 6224f54d4d..425a261c16 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3692,6 +3692,34 @@ test_expect_success ICONV 'X: handling encoding' '
git log -1 --format=%B encoding | grep $(printf "\317\200")
'
+test_expect_success 'X: replace ref that becomes useless is removed' '
+ git init -qb main testrepo &&
+ cd testrepo &&
+ (
+ test_commit test &&
+
+ test_commit msg somename content &&
+
+ git mv somename othername &&
+ NEW_TREE=$(git write-tree) &&
+ MSG="$(git log -1 --format=%B HEAD)" &&
+ NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) &&
+ git replace main $NEW_COMMIT &&
+
+ echo more >>othername &&
+ git add othername &&
+ git commit -qm more &&
+
+ git fast-export --all >tmp &&
+ sed -e s/othername/somename/ tmp >tmp2 &&
+ git fast-import --force <tmp2 2>msgs &&
+
+ grep "Dropping.*since it would point to itself" msgs &&
+ git show-ref >refs &&
+ ! grep refs/replace refs
+ )
+'
+
###
### series Y (submodules and hash algorithms)
###