Skip to content

Commit c68be1f

Browse files
ebiedermgitster
authored andcommitted
builtin/ls-tree: let the oid determine the output algorithm
Update cmd_ls_tree to call get_oid_with_context and pass GET_OID_HASH_ANY instead of calling the simpler repo_get_oid. This implments in ls-tree the behavior that asking to display a sha1 hash displays the corrresponding sha1 encoded object and asking to display a sha256 hash displayes the corresponding sha256 encoded object. This is useful for testing the conversion of an object to an equivlanet object encoded with a different hash function. Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d69175 commit c68be1f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

builtin/ls-tree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
376376
OPT_END()
377377
};
378378
struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format;
379+
struct object_context obj_context;
379380
int ret;
380381

381382
git_config(git_default_config, NULL);
@@ -407,7 +408,9 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
407408
ls_tree_usage, ls_tree_options);
408409
if (argc < 1)
409410
usage_with_options(ls_tree_usage, ls_tree_options);
410-
if (repo_get_oid(the_repository, argv[0], &oid))
411+
if (get_oid_with_context(the_repository, argv[0],
412+
GET_OID_HASH_ANY, &oid,
413+
&obj_context))
411414
die("Not a valid object name %s", argv[0]);
412415

413416
/*

0 commit comments

Comments
 (0)