summaryrefslogtreecommitdiff
path: root/t/t9351-fast-export-anonymize.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-03-22 17:42:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-03-22 22:37:09 (GMT)
commitaa548459a0d773cd53083d9f73228fef653ec124 (patch)
treec11b6882fc9b3ae074d29c0d6ccb9b18aea424f2 /t/t9351-fast-export-anonymize.sh
parentdcc4e134aa7e469ef56a988696229e7b9a686f96 (diff)
downloadgit-aa548459a0d773cd53083d9f73228fef653ec124.zip
git-aa548459a0d773cd53083d9f73228fef653ec124.tar.gz
git-aa548459a0d773cd53083d9f73228fef653ec124.tar.bz2
fast-export: de-obfuscate --anonymize-map handling
When we handle an --anonymize-map option, we parse the orig/anon pair, and then feed the "orig" string to anonymize_str(), along with a generator function that duplicates the "anon" string to be cached in the map. This works, because anonymize_str() says "ah, there is no mapping yet for orig; I'll add one from the generator". But there are some downsides: 1. It's a bit too clever, as it's not obvious what the code is trying to do or why it works. 2. It requires allowing generator functions to take an extra void pointer, which is not something any of the normal callers of anonymize_str() want. 3. It does the wrong thing if the same token is provided twice. When there are conflicting options, like: git fast-export --anonymize \ --anonymize-map=foo:one \ --anonymize-map=foo:two we usually let the second one override the first. But by using anonymize_str(), which has first-one-wins logic, we do the opposite. So instead of relying on anonymize_str(), let's directly add the entry ourselves. We can tweak the tests to show that we handle overridden options correctly now. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9351-fast-export-anonymize.sh')
-rwxr-xr-xt/t9351-fast-export-anonymize.sh2
1 files changed, 2 insertions, 0 deletions
diff --git a/t/t9351-fast-export-anonymize.sh b/t/t9351-fast-export-anonymize.sh
index 77047e2..156a647 100755
--- a/t/t9351-fast-export-anonymize.sh
+++ b/t/t9351-fast-export-anonymize.sh
@@ -25,6 +25,7 @@ test_expect_success 'setup simple repo' '
test_expect_success 'export anonymized stream' '
git fast-export --anonymize --all \
--anonymize-map=retain-me \
+ --anonymize-map=xyzzy:should-not-appear \
--anonymize-map=xyzzy:custom-name \
--anonymize-map=other \
>stream
@@ -41,6 +42,7 @@ test_expect_success 'stream omits path names' '
test_expect_success 'stream contains user-specified names' '
grep retain-me stream &&
+ ! grep should-not-appear stream &&
grep custom-name stream
'