git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 09/10] fast-export: allow seeding the anonymized mapping

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 23, 2020, 17:16 UTC
Message-ID
<CAPig+cTMu3SW5UE59Eva=jh-07hOT8Dz5A5trWyEugKd_2HaKg@mail.gmail.com>
In-Reply-To
<20200623152505.GI1435482@coredump.intra.peff.net>
On Tue, Jun 23, 2020 at 11:25 AM Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
> @@ -238,6 +243,25 @@ collapse "User 0", "User 1", etc into "User X"). This produces a much
> +[...] For example, if you have a bug which reproduces
> +with `git rev-list mybranch -- foo.c`, you can run:
> +
> +---------------------------------------------------
> +$ git fast-export --anonymize --all \
> +   --seed-anonymized=foo.c:secret.c \
> +   --seed-anonymized=mybranch \
> +   >stream
> +---------------------------------------------------
> +
> +After importing the stream, you can then run `git rev-list mybranch --
> +secret.c` in the anonymized repository.

I understand that your intention here is to demonstrate both forms of --seed-anonymized, but I'm slightly concerned that people may interpret this example as meaning that you are not allowed to anonymize the refname when anonymizing a pathname. It might be less ambiguous to avoid the "short form" in the example; people who have read the description of --seed-anonymized will know that the short form can be used without having to see it in an example.

> +Note that paths and refnames are split into tokens at slash boundaries.
> +The command above would anonymize `subdir/foo.c` as something like
> +`path123/secret.c`.

Confusing. This seems to be saying that anonymizing filenames in subdirectories is pointless because you can't know how the leading directory names will be anonymized. That leaves the reader wondering how to deal with the situation. Does it require using --seed-anonymized for each path component leading up to the filename? Or can --seed-anonymized take an full pathname (leading directory components and filename) in one shot?

Show 14 quoted lines
> @@ -168,8 +169,18 @@ static const char *anonymize_str(struct hashmap *map,
> -    ret = hashmap_get_entry(map, &key, hash, &key);
>
> +    /* First check if it's a token the user configured manually... */
> +    if (anonymized_seeds.cmpfn)
> +        ret = hashmap_get_entry(&anonymized_seeds, &key, hash, &key);
> +    else
> +        ret = NULL;
> +
> +    /* ...otherwise check if we've already seen it in this context... */
> +    if (!ret)
> +        ret = hashmap_get_entry(map, &key, hash, &key);
> +
> +    /* ...and finally generate a new mapping if necessary */

I was a bit surprised to see that --seed-anonymized values are stored in a separate hash map rather than simply being used to (literally) seed the existing anonymization hash map. I guess there's a good technical reason for doing it this way, such as the normal anonymization hash map not yet being in existence at the time the --seed-anonymized option is processed? (I haven't checked because I'm too lazy, so it may not be worth spending time answering me.)

Show 5 quoted lines
> @@ -1188,6 +1230,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
>         OPT_BOOL(0, "anonymize", &anonymize, N_("anonymize output")),
> +        OPT_CALLBACK_F(0, "seed-anonymized", &anonymized_seeds, N_("from:to"),
> +               N_("convert <from> to <to> in anonymized output"),
> +               PARSE_OPT_NONEG, parse_opt_seed_anonymized),

Would it be worthwhile to add a check somewhere after the parse_options() invocation and complain if --seed-anonymized was used without --anonymize? (Or should --seed-anonymized perhaps imply --anonymize?)

Previous: Jeff KingNext: Jeff King
Message 41 of 64 in “fast-export: allow dumping anonymization mappings”
  1. 0/3 fast-export: allow dumping anonymization mappingsJeff King, Jun 19, 2020
  2. 1/3 fast-export: allow dumping the refname mappingJeff King, Jun 19, 2020
  3. Eric SunshineJun 19, 2020
  4. Jeff KingJun 19, 2020
  5. Eric SunshineJun 19, 2020
  6. Jeff KingJun 19, 2020
  7. Eric SunshineJun 19, 2020
  8. Jeff KingJun 22, 2020
  9. Junio C HamanoJun 19, 2020
  10. Jeff KingJun 22, 2020
  11. 2/3 fast-export: anonymize "master" refnameJeff King, Jun 19, 2020
  12. 3/3 fast-export: allow dumping the path mappingJeff King, Jun 19, 2020
  13. Eric SunshineJun 19, 2020
  14. Junio C HamanoJun 19, 2020
  15. Jeff KingJun 22, 2020
  16. Johannes SchindelinJun 19, 2020
  17. Junio C HamanoJun 22, 2020
  18. 0/4 fast-export: allow dumping anonymization mappingsJeff King, Jun 22, 2020
  19. 1/4 fast-export: allow dumping the refname mappingJeff King, Jun 22, 2020
  20. 2/4 fast-export: anonymize "master" refnameJeff King, Jun 22, 2020
  21. 3/4 fast-export: refactor path printing to not rely on stdoutJeff King, Jun 22, 2020
  22. 4/4 fast-export: allow dumping the path mappingJeff King, Jun 22, 2020
  23. 0/10 fast-export: allow seeding the anonymized mappingJeff King, Jun 23, 2020
  24. 01/10 t9351: derive anonymized tree checks from original repoJeff King, Jun 23, 2020
  25. 02/10 fast-export: use xmemdupz() for anonymizing oidsJeff King, Jun 23, 2020
  26. 03/10 fast-export: store anonymized oids as hex stringsJeff King, Jun 23, 2020
  27. SZEDER GáborJun 24, 2020
  28. Jeff KingJun 24, 2020
  29. Jeff KingJun 25, 2020
  30. SZEDER GáborJun 25, 2020
  31. Jeff KingJun 25, 2020
  32. Johannes SchindelinJun 29, 2020
  33. Jeff KingJun 30, 2020
  34. 04/10 fast-export: tighten anonymize_mem() interface to handle only stringsJeff King, Jun 23, 2020
  35. 05/10 fast-export: stop storing lengths in anonymized hashmapsJeff King, Jun 23, 2020
  36. 06/10 fast-export: use a flex array to store anonymized entriesJeff King, Jun 23, 2020
  37. 07/10 fast-export: move global "idents" anonymize hashmap into functionJeff King, Jun 23, 2020
  38. 08/10 fast-export: add a "data" callback parameter to anonymize_str()Jeff King, Jun 23, 2020
  39. Junio C HamanoJun 24, 2020
  40. 09/10 fast-export: allow seeding the anonymized mappingJeff King, Jun 23, 2020
  41. Eric SunshineJun 23, 2020
  42. Jeff KingJun 23, 2020
  43. Eric SunshineJun 23, 2020
  44. Jeff KingJun 24, 2020
  45. Eric SunshineJun 23, 2020
  46. Jeff KingJun 23, 2020
  47. Eric SunshineJun 23, 2020
  48. Jeff KingJun 24, 2020
  49. 10/10 fast-export: anonymize "master" refnameJeff King, Jun 23, 2020
  50. Junio C HamanoJun 23, 2020
  51. Jeff KingJun 23, 2020
  52. 0/11 fast-export: allow seeding the anonymized mappingJeff King, Jun 25, 2020
  53. 01/11 t9351: derive anonymized tree checks from original repoJeff King, Jun 25, 2020
  54. 02/11 fast-export: use xmemdupz() for anonymizing oidsJeff King, Jun 25, 2020
  55. 03/11 fast-export: store anonymized oids as hex stringsJeff King, Jun 25, 2020
  56. 05/11 fast-export: stop storing lengths in anonymized hashmapsJeff King, Jun 25, 2020
  57. 06/11 fast-export: use a flex array to store anonymized entriesJeff King, Jun 25, 2020
  58. 04/11 fast-export: tighten anonymize_mem() interface to handle only stringsJeff King, Jun 25, 2020
  59. 07/11 fast-export: move global "idents" anonymize hashmap into functionJeff King, Jun 25, 2020
  60. 08/11 fast-export: add a "data" callback parameter to anonymize_str()Jeff King, Jun 25, 2020
  61. 09/11 fast-export: allow seeding the anonymized mappingJeff King, Jun 25, 2020
  62. 11/11 fast-export: use local array to store anonymized oidJeff King, Jun 25, 2020
  63. 10/11 fast-export: anonymize "master" refnameJeff King, Jun 25, 2020
  64. Junio C HamanoJun 25, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.