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

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

From: Elijah Newren <hidden>
Date: 2021-03-17 18:12:06

On Wed, Mar 17, 2021 at 6:28 AM Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
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;
I could kind of see referencing the magic constant 0177777 in a test-*
source file, but it really needs an explanation when showing up in
actual git source code.  At least reference something about how
cache.h mentions these are the mode bits, or better yet #define this
constant somewhere in cache.h with an explanation.

Also, what is --stage-sparse?
                        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