Thread (1 message) 1 message, 1 author, 2022-02-19

Re: [PATCH] ls-files: support --recurse-submodules --stage

From: Junio C Hamano <hidden>
Date: 2022-02-19 00:33:09

Jonathan Tan [off-list ref] writes:
quoted hunk
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index f7ea56cc63..e791b65e7e 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -244,7 +244,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
 			printf("%s%06o %s %d\t",
 			       tag,
 			       ce->ce_mode,
-			       find_unique_abbrev(&ce->oid, abbrev),
+			       repo_find_unique_abbrev(repo, &ce->oid, abbrev),
 			       ce_stage(ce));
 		}
Quite straight-forward.  At this point, repo is the repository we
are currently working in (which will be updated to the submodule
repository by show_submodule() and passed down to show_files()), so
the only thing we need to do is to make sure we use that repo
consistently.  Makes sense.
quoted hunk
 		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();
 
 	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))
 		die("ls-files --recurse-submodules unsupported mode");
 
diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh
index 4a08000713..3d2da360d1 100755
--- a/t/t3007-ls-files-recurse-submodules.sh
+++ b/t/t3007-ls-files-recurse-submodules.sh
@@ -34,6 +34,25 @@ test_expect_success 'ls-files correctly outputs files in submodule' '
 	test_cmp expect actual
 '
 
+test_expect_success '--stage' '
+	# In order to test hash abbreviation, write two objects that have the
+	# same first 4 hexadecimal characters in their (SHA-1) hashes.
+	echo brocdnra >submodule/c &&
+	git -C submodule commit -am "update c" &&
+	echo brigddsv >submodule/c &&
+	git -C submodule commit -am "update c again" &&
+
+	cat >expect <<-\EOF &&
+	100644 6da7 0	.gitmodules
+	100644 7898 0	a
+	100644 6178 0	b/b
+	100644 dead9 0	submodule/c
+	EOF
+
+	git ls-files --stage --recurse-submodules --abbrev=4 >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'ls-files correctly outputs files in submodule with -z' '
 	lf_to_nul >expect <<-\EOF &&
 	.gitmodules
@@ -292,7 +311,6 @@ test_incompatible_with_recurse_submodules () {
 test_incompatible_with_recurse_submodules --deleted
 test_incompatible_with_recurse_submodules --modified
 test_incompatible_with_recurse_submodules --others
-test_incompatible_with_recurse_submodules --stage
 test_incompatible_with_recurse_submodules --killed
 test_incompatible_with_recurse_submodules --unmerged
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help