Re: [PATCH 9/9] Add git-check-ignores

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

 



On Tue, Sep 04, 2012 at 08:06:12PM +0700, Nguyen Thai Ngoc Duy wrote:
> On Sun, Sep 2, 2012 at 7:12 AM, Adam Spiers <git@xxxxxxxxxxxxxx> wrote:
> > --- a/builtin/add.c
> > +++ b/builtin/add.c
> > @@ -273,7 +273,7 @@ static int add_files(struct dir_struct *dir, int flags)
> >                 fprintf(stderr, _(ignore_error));
> >                 for (i = 0; i < dir->ignored_nr; i++)
> >                         fprintf(stderr, "%s\n", dir->ignored[i]->name);
> > -               fprintf(stderr, _("Use -f if you really want to add them.\n"));
> > +               fprintf(stderr, _("Use -f if you really want to add them, or git check-ignore to see\nwhy they're ignored.\n"));
> >                 die(_("no files added"));
> >         }
> 
> String too long (> 80 chars).

You mean the line of code is too long, or the argument to _(), or
both?  I didn't like this either, but I saw that builtin/checkout.c
already did something similar twice, and I wasn't sure how else to do
it.  Suggestions gratefully received.

> > +static const char * const check_ignore_usage[] = {
> > +"git check-ignore pathname...",
> > +"git check-ignore --stdin [-z] < <list-of-paths>",
> > +NULL
> > +};
> > +
> > +static const struct option check_ignore_options[] = {
> > +       OPT_BOOLEAN(0 , "stdin", &stdin_paths, "read file names from stdin"),
> > +       OPT_BOOLEAN('z', NULL, &null_term_line,
> > +               "input paths are terminated by a null character"),
> > +       OPT_END()
> > +};
> 
> You may want to mark help strings ("read file names from stdin" and
> "input paths... null character") and check_ignore_usage[] for
> translation. Just wrap those strings with N_() and you'll be fine. For
> similar changes, check out nd/i18n-parseopt-help on branch 'pu'.

Thanks, I'll do that.

[snipped discussion of "include" / "exclude" which already continued elsewhere]

> > +static void check_ignore(const char *prefix, const char **pathspec)
> > +{
> > +       struct dir_struct dir;
> > +       const char *path;
> > +       char *seen = NULL;
> > +
> > +       /* read_cache() is only necessary so we can watch out for submodules. */
> > +       if (read_cache() < 0)
> > +               die(_("index file corrupt"));
> > +
> > +       memset(&dir, 0, sizeof(dir));
> > +       dir.flags |= DIR_COLLECT_IGNORED;
> > +       setup_standard_excludes(&dir);
> 
> You should support ignore rules from files and command line arguments
> too, like ls-files. For quick testing.

You mean --exclude, --exclude-from, and --exclude-per-directory?
Sure, although I have limited time right now, so maybe these could be
added in a later iteration?

> > +static NORETURN void error_with_usage(const char *msg)
> > +{
> > +       error("%s", msg);
> > +       usage_with_options(check_ignore_usage, check_ignore_options);
> > +}
> 
> Interesting. We have usage_msg_opt() in parse-options.c, but it's more
> verbose. Perhaps this function should be moved to parse-options.c
> because it may be useful to other commands as well?

I'll look into it.
--
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]