From: Nguyen Thai Ngoc Duy Date: Sun, 02 Sep 2012 10:41:21 GMT Subject: Re: [PATCH 9/9] Add git-check-ignores Message-ID: In-Reply-To: <1346544731-938-10-git-send-email-git@adamspiers.org> On Sun, Sep 2, 2012 at 7:12 AM, Adam Spiers wrote: > This works in a similar manner to git-check-attr. Some code > was reused from add.c by refactoring out into pathspec.c. Thanks, comments from a quick glance. First of all, can we make it work (or share code) with .gitattributes? We may need to debug .gitattributes as well as .gitignore. A common command would be nice. > +SYNOPSIS > +-------- > +[verse] > +'git check-ignore' pathname... > +'git check-ignore' --stdin [-z] < Also --quiet option, where check-ignore returns 0 if the given path is ignored, 1 otherwise? > +OUTPUT > +------ > + > +The output is a series of lines of the form: > + > + COLON SP SP SP SP LF > + > + is the path of a file being queried, is either > +'excluded' or 'included' (for patterns prefixed with '!'), > +is the matching pattern, is the pattern's source file (either > +as an absolute path or relative to the repository root), and > + is the position of the pattern within that source. I think we should have a few levels of verbosity. - The --quiet I already mention above. - If many paths are given, then perhaps we could print ignored paths (no extra info). - Going to the next level, we could print path and the the location of the final exclude/include rule (file and line number). - For debugging, given one path, we print all the rules that are applied to it, which may help understand how/why it goes wrong. > @@ -338,6 +338,7 @@ static void handle_internal_command(int argc, const char **argv) > { "bundle", cmd_bundle, RUN_SETUP_GENTLY }, > { "cat-file", cmd_cat_file, RUN_SETUP }, > { "check-attr", cmd_check_attr, RUN_SETUP }, > + { "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE }, > { "check-ref-format", cmd_check_ref_format }, > { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE }, > { "checkout-index", cmd_checkout_index, I don't think we really need NEED_WORK_TREE here. .gitignore can be read from index only. -- Duy