Re: [PATCH 16/25] list-files: add --unmerged

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

 



On Mon, Apr 6, 2015 at 9:52 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
> diff --git a/builtin/list-files.c b/builtin/list-files.c
> index 31991a4..fe15417 100644
> --- a/builtin/list-files.c
> +++ b/builtin/list-files.c
> @@ -225,12 +229,46 @@ static void populate_untracked(struct item_list *result,
>         }
>  }
>
> +static void populate_unmerged(struct item_list *result,
> +                             const struct string_list *change)
> +{
> +       int i;
> +
> +       for (i = 0; i < change->nr; i++) {
> +               const struct string_list_item *it = change->items + i;
> +               struct wt_status_change_data *d = it->util;
> +               const char *name = it->string;
> +               const char *tag;
> +               struct stat st;
> +
> +               switch (d->stagemask) {
> +               case 1: tag = "DD"; break; /* both deleted */
> +               case 2: tag = "AU"; break; /* added by us */
> +               case 3: tag = "UD"; break; /* deleted by them */
> +               case 4: tag = "UA"; break; /* added by them */
> +               case 5: tag = "DU"; break; /* deleted by us */
> +               case 6: tag = "AA"; break; /* both added */
> +               case 7: tag = "UU"; break; /* both modified */
> +               default: continue;

Does the 'default' case represent a "cannot happen" situation? If so,
does it deserve some sort of "BUG" diagnostic message or something?

More below.

> +               }
> +
> +               if (lstat(name, &st))
> +                       /* color_filename() treats this as an orphan file */
> +                       st.st_mode = 0;
> +
> +               if (!matched(result, name, st.st_mode))
> +                       continue;
> +
> +               add_wt_item(result, IS_UNMERGED, name, tag, &st);
> +       }
> +}
> +
> diff --git a/t/t7013-list-files.sh b/t/t7013-list-files.sh
> index 6b76d1f..7fe9673 100755
> --- a/t/t7013-list-files.sh
> +++ b/t/t7013-list-files.sh
> @@ -218,4 +218,39 @@ test_expect_success '--classify' '
>         )
>  '
>
> +test_expect_success 'list-files unmerged' '
> +       (
> +       add_stage() {
> +               echo "100644 $1 $2      $3" | git update-index --index-info
> +       }
> +       git init 3 &&
> +       cd 3 &&
> +       test_commit 1 &&
> +       SHA1=`echo 1 | git hash-object -w --stdin` &&

    SHA1=$(echo 1 | git hash-object -w --stdin) &&

> +       add_stage $SHA1 1 deleted-by-both &&
> +       add_stage $SHA1 2 added-by-us &&
> +       add_stage $SHA1 1 deleted-by-them &&
> +       add_stage $SHA1 2 deleted-by-them &&
> +       add_stage $SHA1 3 added-by-them &&
> +       add_stage $SHA1 3 deleted-by-us &&
> +       add_stage $SHA1 1 deleted-by-us &&
> +       add_stage $SHA1 2 added-by-both &&
> +       add_stage $SHA1 3 added-by-both &&
> +       add_stage $SHA1 1 modified-by-both &&
> +       add_stage $SHA1 2 modified-by-both &&
> +       add_stage $SHA1 3 modified-by-both &&
> +       git list-files -u >actual &&
> +       cat >expected <<-\EOF &&
> +       AA added-by-both
> +       UA added-by-them
> +       AU added-by-us
> +       DD deleted-by-both
> +       UD deleted-by-them
> +       DU deleted-by-us
> +       UU modified-by-both
> +       EOF
> +       test_cmp expected actual
> +       )
> +'
> +
>  test_done
> --
> 2.3.0.rc1.137.g477eb31
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]