diff options
author | Derrick Stolee <derrickstolee@github.com> | 2022-04-26 23:43:20 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-26 23:56:39 +0300 |
commit | 124b05b23005437fa5fb91863bde2a8f5840e164 (patch) | |
tree | 0cd13eaa15f19fe4d15297d9b26516edda3e4ed3 /builtin/rev-parse.c | |
parent | 4925adb4dac1f794cc5d5c82dee49e2f5f47560f (diff) |
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>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r-- | builtin/rev-parse.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 8480a59f57..4fc6185b2d 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -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, "--")) { |