Re: [PATCH 18/19] update-index: test the system before enabling untracked cache

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

 



On Mon, Oct 27, 2014 at 8:10 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/update-index.c b/builtin/update-index.c
> index e57e2d7..471c0b4 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -48,6 +48,145 @@ static void report(const char *fmt, ...)
>         va_end(vp);
>  }
>
> +static int test_if_untracked_cache_is_supported(void)
> +{
> +       struct stat st;
> +       struct stat_data base;
> +       int fd;
> +
> +       fprintf(stderr, _("Testing "));
> +       xmkdir("dir-mtime-test");
> +       atexit(remove_test_directory);
> +       xstat("dir-mtime-test", &st);
> +       fill_stat_data(&base, &st);
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       fd = create_file("dir-mtime-test/newfile");
> +       xstat("dir-mtime-test", &st);
> +       if (!match_stat_data(&base, &st)) {

close(fd);

> +               fputc('\n', stderr);
> +               fprintf_ln(stderr,_("directory stat info does not "
> +                                   "change after adding a new file"));
> +               return 0;
> +       }
> +       fill_stat_data(&base, &st);
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       xmkdir("dir-mtime-test/new-dir");
> +       xstat("dir-mtime-test", &st);
> +       if (!match_stat_data(&base, &st)) {

close(fd);

> +               fputc('\n', stderr);
> +               fprintf_ln(stderr, _("directory stat info does not change "
> +                                    "after adding a new directory"));
> +               return 0;
> +       }
> +       fill_stat_data(&base, &st);
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       write_or_die(fd, "data", 4);
> +       close(fd);
> +       xstat("dir-mtime-test", &st);
> +       if (match_stat_data(&base, &st)) {
> +               fputc('\n', stderr);
> +               fprintf_ln(stderr, _("directory stat info changes "
> +                                    "after updating a file"));
> +               return 0;
> +       }
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       close(create_file("dir-mtime-test/new-dir/new"));
> +       xstat("dir-mtime-test", &st);
> +       if (match_stat_data(&base, &st)) {
> +               fputc('\n', stderr);
> +               fprintf_ln(stderr, _("directory stat info changes after "
> +                                    "adding a file inside subdirectory"));
> +               return 0;
> +       }
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       xunlink("dir-mtime-test/newfile");
> +       xstat("dir-mtime-test", &st);
> +       if (!match_stat_data(&base, &st)) {
> +               fputc('\n', stderr);
> +               fprintf_ln(stderr, _("directory stat info does not "
> +                                    "change after deleting a file"));
> +               return 0;
> +       }
> +       fill_stat_data(&base, &st);
> +       fputc('.', stderr);
> +
> +       avoid_racy();
> +       xunlink("dir-mtime-test/new-dir/new");
> +       xrmdir("dir-mtime-test/new-dir");
> +       xstat("dir-mtime-test", &st);
> +       if (!match_stat_data(&base, &st)) {
> +               fputc('\n', stderr);
> +               fprintf_ln(stderr, _("directory stat info does not "
> +                                    "change after deleting a directory"));
> +               return 0;
> +       }
> +
> +       xrmdir("dir-mtime-test");
> +       fprintf_ln(stderr, _(" OK"));
> +       return 1;
> +}
--
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]