rev-parse: integrate with sparse index
It is not obvious that the 'git rev-parse' builtin would use the sparse index, but it is possible to parse paths out of the index using the ":<path>" syntax. The 'git rev-parse' output is only the OID of the object found at that location, but otherwise behaves similarly to 'git show :<path>'. This includes the failure conditions on directories and the error messages depending on whether a path is in the worktree or not. The only code change required is to change the command_requires_full_index setting in builtin/rev-parse.c, and we can re-use many existing 'git show' tests for the rev-parse case. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
4925adb4da
commit
124b05b230
@ -723,6 +723,9 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||
prefix = setup_git_directory();
|
||||
git_config(git_default_config, NULL);
|
||||
did_repo_setup = 1;
|
||||
|
||||
prepare_repo_settings(the_repository);
|
||||
the_repository->settings.command_requires_full_index = 0;
|
||||
}
|
||||
|
||||
if (!strcmp(arg, "--")) {
|
||||
|
||||
Reference in New Issue
Block a user