Thread (47 messages) flat view 47 messages, 6 authors, 2016-06-15

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

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:54:37

On Sun, Sep 2, 2012 at 7:12 AM, Adam Spiers [off-list ref] 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] < <list-of-paths>
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:
+
+<path> COLON SP <type> SP <pattern> SP <source> SP <position> LF
+
+<path> is the path of a file being queried, <type> is either
+'excluded' or 'included' (for patterns prefixed with '!'), <pattern>
+is the matching pattern, <source> is the pattern's source file (either
+as an absolute path or relative to the repository root), and
+<position> 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.
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help