]> git.ipfire.org Git - thirdparty/git.git/commit
fast-export: allow seeding the anonymized mapping
authorJeff King <peff@peff.net>
Thu, 25 Jun 2020 19:48:32 +0000 (15:48 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Jun 2020 21:19:23 +0000 (14:19 -0700)
commit65b5d9fae7684a282f48295b645c2f9da77c2736
tree3a5c42c4ec2c542d7327403ad712796f91680669
parentd5bf91fde4430532eb725425c3ef9827048af6b5
fast-export: allow seeding the anonymized mapping

After you anonymize a repository, it can be hard to find which commits
correspond between the original and the result, and thus hard to
reproduce commands that triggered bugs in the original.

Let's make it possible to seed the anonymization map. This lets users
either:

  - mark names to be retained as-is, if they don't consider them secret
    (in which case their original commands would just work)

  - map names to new values, which lets them adapt the reproduction
    recipe to the new names without revealing the originals

The implementation is fairly straight-forward. We already store each
anonymized token in a hashmap (so that the same token appearing twice is
converted to the same result). We can just introduce a new "seed"
hashmap which is consulted first.

This does make a few more promises to the user about how we'll anonymize
things (e.g., token-splitting pathnames). But it's unlikely that we'd
want to change those rules, even if the actual anonymization of a single
token changes. And it makes things much easier for the user, who can
unblind only a directory name without having to specify each path within
it.

One alternative to this approach would be to anonymize as we see fit,
and then dump the whole refname and pathname mappings to a file. This
does work, but it's a bit awkward to use (you have to manually dig the
items you care about out of the mapping).

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fast-export.txt
builtin/fast-export.c
t/t9351-fast-export-anonymize.sh