Add a comment to the object_type() function to explain what it returns, and whet the "mode" is in the "else" case. The object_type() function dates back to 4d1012c3709 (Fix rev-list when showing objects involving submodules, 2007-11-11). It's not immediately obvious to someone looking at its history and how it's come to be used. Despite what Linus noted in 4d1012c3709 (Fix rev-list when showing objects involving submodules, 2007-11-11) about wanting to move away from users of object_type() relying on S_ISLNK(mode) being true here we do currently rely on that. If this is changed to a condition to only return OBJ_BLOB on S_ISREG(mode) then t4008, t4023 and t7415 will have failing tests. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- cache.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cache.h b/cache.h index d9281496140..e513f0ee5b4 100644 --- a/cache.h +++ b/cache.h @@ -451,11 +451,16 @@ enum object_type { OBJ_MAX }; +/* + * object_type() returns an object of a type that'll appear in a tree, + * so no OBJ_TAG is possible. This is mostly (and dates back to) + * consumers of the tree-walk.h API's "mode" field. + */ static inline enum object_type object_type(unsigned int mode) { return S_ISDIR(mode) ? OBJ_TREE : S_ISGITLINK(mode) ? OBJ_COMMIT : - OBJ_BLOB; + OBJ_BLOB; /* S_ISREG(mode) || S_ISLNK(mode) */ } /* Double-check local_repo_env below if you add to this list. */ -- 2.31.0.rc0.126.g04f22c5b82