ls-files: support --recurse-submodules --stage
e77aa336f1
("ls-files: optionally recurse into submodules", 2016-10-10) taught ls-files the --recurse-submodules argument, but only in a limited set of circumstances. In particular, --stage was unsupported, perhaps because there was no repo_find_unique_abbrev(), which was only introduced in8bb95572b0
("sha1-name.c: add repo_find_unique_abbrev_r()", 2019-04-16). This function is needed for using --recurse-submodules with --stage. Now that we have repo_find_unique_abbrev(), teach support for this combination of arguments. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e6ebfd0e8c
commit
290eada0ac
@ -156,7 +156,7 @@ a space) at the start of each line:
|
|||||||
|
|
||||||
--recurse-submodules::
|
--recurse-submodules::
|
||||||
Recursively calls ls-files on each active submodule in the repository.
|
Recursively calls ls-files on each active submodule in the repository.
|
||||||
Currently there is only support for the --cached mode.
|
Currently there is only support for the --cached and --stage modes.
|
||||||
|
|
||||||
--abbrev[=<n>]::
|
--abbrev[=<n>]::
|
||||||
Instead of showing the full 40-byte hexadecimal object
|
Instead of showing the full 40-byte hexadecimal object
|
||||||
|
@ -244,7 +244,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
|
|||||||
printf("%s%06o %s %d\t",
|
printf("%s%06o %s %d\t",
|
||||||
tag,
|
tag,
|
||||||
ce->ce_mode,
|
ce->ce_mode,
|
||||||
find_unique_abbrev(&ce->oid, abbrev),
|
repo_find_unique_abbrev(repo, &ce->oid, abbrev),
|
||||||
ce_stage(ce));
|
ce_stage(ce));
|
||||||
}
|
}
|
||||||
write_eolinfo(repo->index, ce, fullname);
|
write_eolinfo(repo->index, ce, fullname);
|
||||||
@ -726,7 +726,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
|
|||||||
setup_work_tree();
|
setup_work_tree();
|
||||||
|
|
||||||
if (recurse_submodules &&
|
if (recurse_submodules &&
|
||||||
(show_stage || show_deleted || show_others || show_unmerged ||
|
(show_deleted || show_others || show_unmerged ||
|
||||||
show_killed || show_modified || show_resolve_undo || with_tree))
|
show_killed || show_modified || show_resolve_undo || with_tree))
|
||||||
die("ls-files --recurse-submodules unsupported mode");
|
die("ls-files --recurse-submodules unsupported mode");
|
||||||
|
|
||||||
|
@ -34,6 +34,23 @@ test_expect_success 'ls-files correctly outputs files in submodule' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--stage' '
|
||||||
|
GITMODULES_HASH=$(git rev-parse HEAD:.gitmodules) &&
|
||||||
|
A_HASH=$(git rev-parse HEAD:a) &&
|
||||||
|
B_HASH=$(git rev-parse HEAD:b/b) &&
|
||||||
|
C_HASH=$(git -C submodule rev-parse HEAD:c) &&
|
||||||
|
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
100644 $GITMODULES_HASH 0 .gitmodules
|
||||||
|
100644 $A_HASH 0 a
|
||||||
|
100644 $B_HASH 0 b/b
|
||||||
|
100644 $C_HASH 0 submodule/c
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git ls-files --stage --recurse-submodules >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'ls-files correctly outputs files in submodule with -z' '
|
test_expect_success 'ls-files correctly outputs files in submodule with -z' '
|
||||||
lf_to_nul >expect <<-\EOF &&
|
lf_to_nul >expect <<-\EOF &&
|
||||||
.gitmodules
|
.gitmodules
|
||||||
@ -292,7 +309,6 @@ test_incompatible_with_recurse_submodules () {
|
|||||||
test_incompatible_with_recurse_submodules --deleted
|
test_incompatible_with_recurse_submodules --deleted
|
||||||
test_incompatible_with_recurse_submodules --modified
|
test_incompatible_with_recurse_submodules --modified
|
||||||
test_incompatible_with_recurse_submodules --others
|
test_incompatible_with_recurse_submodules --others
|
||||||
test_incompatible_with_recurse_submodules --stage
|
|
||||||
test_incompatible_with_recurse_submodules --killed
|
test_incompatible_with_recurse_submodules --killed
|
||||||
test_incompatible_with_recurse_submodules --unmerged
|
test_incompatible_with_recurse_submodules --unmerged
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user