summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2022-08-10 21:01:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-10 21:26:25 (GMT)
commitec18b10bf20574fc6d60c966412a11c81f9c17e0 (patch)
tree3f695fc9baf3eb4c884a042d3bc6b5125fca3c3b /packfile.c
parenta5b4466536668ce595300de249412b2c5b97deb1 (diff)
downloadgit-ec18b10bf20574fc6d60c966412a11c81f9c17e0.zip
git-ec18b10bf20574fc6d60c966412a11c81f9c17e0.tar.gz
git-ec18b10bf20574fc6d60c966412a11c81f9c17e0.tar.bz2
tree-walk: add a mechanism for getting non-canonicalized modes
When using init_tree_desc() and tree_entry() to iterate over a tree, we always canonicalize the modes coming out of the tree. This is a good thing to prevent bugs or oddities in normal code paths, but it's counter-productive for tools like fsck that want to see the exact contents. We can address this by adding an option to avoid the extra canonicalization. A few notes on the implementation: - I've attached the new option to the tree_desc struct itself. The actual code change is in decode_tree_entry(), which is in turn called by the public update_tree_entry(), tree_entry(), and init_tree_desc() functions, plus their "gently" counterparts. By letting it ride along in the struct, we can avoid changing the signature of those functions, which are called many times. Plus it's conceptually simpler: you really want a particular iteration of a tree to be "raw" or not, rather than individual calls. - We still have to set the new option somewhere. The struct is initialized by init_tree_desc(). I added the new flags field only to the "gently" version. That avoids disturbing the much more numerous non-gentle callers, and it makes sense that anybody being careful about looking at raw modes would also be careful about bogus trees (i.e., the caller will be something like fsck in the first place). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/packfile.c b/packfile.c
index 8e812a8..e5b1d0e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2243,7 +2243,7 @@ static int add_promisor_object(const struct object_id *oid,
struct tree *tree = (struct tree *)obj;
struct tree_desc desc;
struct name_entry entry;
- if (init_tree_desc_gently(&desc, tree->buffer, tree->size))
+ if (init_tree_desc_gently(&desc, tree->buffer, tree->size, 0))
/*
* Error messages are given when packs are
* verified, so do not print any here.