Thread (184 messages) 184 messages, 6 authors, 2021-04-01
STALE2005d

[RFC/PATCH 2/5] ls-files: make "mode" in show_ce() loop a variable

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-03-17 13:29:24
Subsystem: the rest · Maintainer: Linus Torvalds

In a subsequent commit I'll optionally change the mode in a new sparse
mode, let's do this first to make that change smaller.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 builtin/ls-files.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index eb72d16493..4db75351f2 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -242,9 +242,17 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
 		if (!show_stage) {
 			fputs(tag, stdout);
 		} else {
+			unsigned int mode = ce->ce_mode;
+			if (show_sparse && S_ISSPARSEDIR(mode))
+				/*
+				 * We could just do & 0177777 all the
+				 * time, just make it clear this is
+				 * for --stage-sparse.
+				 */
+				mode &= 0177777;
 			printf("%s%06o %s %d\t",
 			       tag,
-			       ce->ce_mode,
+			       mode,
 			       find_unique_abbrev(&ce->oid, abbrev),
 			       ce_stage(ce));
 		}
-- 
2.31.0.260.g719c683c1d
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help