path: root/t/
diff options
authorElijah Newren <>2018-11-16 07:59:56 (GMT)
committerJunio C Hamano <>2018-11-17 09:43:52 (GMT)
commita965bb31166d04f3e5c8f7a93569fb73f9a9d749 (patch)
tree385913d97dba601ccc48903a5867bb54b92c5a60 /t/
parent25dd3e4889a41a1ee40fbf961209e55d208382f0 (diff)
fast-export: add a --show-original-ids option to show original names
Knowing the original names (hashes) of commits can sometimes enable post-filtering that would otherwise be difficult or impossible. In particular, the desire to rewrite commit messages which refer to other prior commits (on top of whatever other filtering is being done) is very difficult without knowing the original names of each commit. In addition, knowing the original names (hashes) of blobs can allow filtering by blob-id without requiring re-hashing the content of the blob, and is thus useful as a small optimization. Once we add original ids for both commits and blobs, we may as well add them for tags too for completeness. Perhaps someone will have a use for them. This commit teaches a new --show-original-ids option to fast-export which will make it add a 'original-oid <hash>' line to blob, commits, and tags. It also teaches fast-import to parse (and ignore) such lines. Signed-off-by: Elijah Newren <> Acked-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 17 insertions, 0 deletions
diff --git a/t/ b/t/
index d7d7306..5690fe2 100755
--- a/t/
+++ b/t/
@@ -77,6 +77,23 @@ test_expect_success 'fast-export --reference-excluded-parents master~2..master'
test $MASTER = $(git rev-parse --verify refs/heads/rewrite))
+test_expect_success 'fast-export --show-original-ids' '
+ git fast-export --show-original-ids master >output &&
+ grep ^original-oid output| sed -e s/^original-oid.// | sort >actual &&
+ git rev-list --objects master muss >objects-and-names &&
+ awk "{print \$1}" objects-and-names | sort >commits-trees-blobs &&
+ comm -23 actual commits-trees-blobs >unfound &&
+ test_must_be_empty unfound
+test_expect_success 'fast-export --show-original-ids | git fast-import' '
+ git fast-export --show-original-ids master muss | git fast-import --quiet &&
+ test $MASTER = $(git rev-parse --verify refs/heads/master) &&
+ test $MUSS = $(git rev-parse --verify refs/tags/muss)
test_expect_success 'iso-8859-1' '
git config i18n.commitencoding ISO8859-1 &&