Re: [PATCH] builtin/ls-files.c:add git ls-file --dedup option

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

 



On Wed, Jan 6, 2021 at 3:54 AM 阿德烈 via GitGitGadget
<gitgitgadget@xxxxxxxxx> wrote:
> [...]
> Therefore, I added the --dedup option to git ls-files.
> 1. It can be achieved that only the deleted file name
> is displayed when using -m, -d, and --dedup at the same time.
> 2. Add --dedup when merging branches to remove duplicate file
>  names. (unless -s, -u are used)

I'm just pointing out a few minor style issues below; I'm not properly
reviewing the patch...

> Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx>
> ---
>  builtin/ls-files.c | 43 ++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 38 insertions(+), 5 deletions(-)

This change adds a new command-line option, so the documentation
(Documentation/git-ls-files.txt) should be updated and at least one
new test should be added (in one of the t/t30??-ls-files-*.sh scripts
probably).

> diff --git a/builtin/ls-files.c b/builtin/ls-files.c
> @@ -301,6 +302,7 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
>         struct strbuf fullname = STRBUF_INIT;
> +       const struct cache_entry *last_stage=NULL;

Add spaces around `=` similar to the preceding line:

    const struct cache_entry *last_stage = NULL;

> @@ -315,7 +317,20 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
>                 for (i = 0; i < repo->index->cache_nr; i++) {
>                         const struct cache_entry *ce = repo->index->cache[i];
> -

This patch deletes the blank line but this project usually prefers to
have a blank line after declarations.

> +                       if(show_cached && delete_dup){

Add space after `if` and before `{`:

    if (show_cached && delete_dup) {

> @@ -336,7 +351,20 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
> +                       if(delete_dup){

Style: if (delete_dup) {

> @@ -347,10 +375,14 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
> -                       if (show_deleted && err)
> +                       if(delete_dup && show_deleted && show_modified && err)

Style: if (delete_dup && ...

> -                       if (show_modified && ie_modified(repo->index, ce, &st, 0))
> -                               show_ce(repo, dir, ce, fullname.buf, tag_modified);
> +                       else{

Style: else {

> +                               if (show_deleted && err)/* you can't find it,so it's actually removed at all! */

Add space before `/* comment */`.
Add space in "...it, so...".

> @@ -578,6 +610,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
> +               OPT_BOOL(0, "dedup", &delete_dup, N_("delete duplicate entry in index")),

The short help makes it seem like it's modifying the index. Perhaps instead:

    N_("suppress duplicate entries")



[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