]> git.ipfire.org Git - thirdparty/git.git/commit
rev-parse: integrate with sparse index
authorDerrick Stolee <derrickstolee@github.com>
Tue, 26 Apr 2022 20:43:20 +0000 (20:43 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Apr 2022 20:56:39 +0000 (13:56 -0700)
commit124b05b23005437fa5fb91863bde2a8f5840e164
tree0cd13eaa15f19fe4d15297d9b26516edda3e4ed3
parent4925adb4dac1f794cc5d5c82dee49e2f5f47560f
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>
builtin/rev-parse.c
t/t1092-sparse-checkout-compatibility.sh