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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 17, 2021 at 6:28 AM Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:
>
> 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 <avarab@xxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux