diff options
author | Jeff King <peff@peff.net> | 2021-01-28 01:14:11 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-28 11:21:27 -0800 |
commit | 2bc1a87e42cc07408a1e7442a3315d1e27b8737f (patch) | |
tree | b67a7217d374891e15451fe56c1d7c028d453940 /pkt-line.h | |
parent | commit_graft_pos(): take an oid instead of a bare hash (diff) | |
download | tgif-2bc1a87e42cc07408a1e7442a3315d1e27b8737f.tar.xz |
rerere: check dirname format while iterating rr_cache directory
In rerere_gc(), we walk over the .git/rr_cache directory and create a
struct for each entry we find. We feed any name we get from readdir() to
find_rerere_dir(), which then calls get_sha1_hex() on it (since we use
the binary hash as a lookup key). If that fails (i.e., the directory
name is not what we expected), it returns NULL. But the comment in
find_rerere_dir() says "BUG".
It _would_ be a bug for the call from new_rerere_id_hex(), the only
other code path, to fail here; it's generating the hex internally. But
the call in rerere_gc() is using it say "is this a plausible directory
name".
Let's instead have rerere_gc() do its own "is this plausible" check.
That has two benefits:
- we can now reliably BUG() inside find_rerere_dir(), which would
catch bugs in the other code path (and we now will never return NULL
from the function, which makes it easier to see that a rerere_id
struct will always have a non-NULL "collection" field).
- it makes the use of the binary hash an implementation detail of
find_rerere_dir(), not known by callers. That will free us up to
change it in a future patch.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pkt-line.h')
0 files changed, 0 insertions, 0 deletions