path: root/builtin/check-ignore.c
diff options
authorJunio C Hamano <>2013-09-20 19:37:32 (GMT)
committerJunio C Hamano <>2013-09-20 19:37:32 (GMT)
commit005a1de380733477382c50e2e44ed8042c401fed (patch)
tree16d8b71bca9dd50d0c46b14948920b374f88c634 /builtin/check-ignore.c
parentb4980c63acad8457fb3606b9bd8b74d5e7cba8dd (diff)
parent8231fa6ae1ef92be73bec5cf0a533a4d8b71d536 (diff)
Merge branch 'dw/check-ignore-sans-index'
"git check-ignore" follows the same rule as "git add" and "git status" in that the ignore/exclude mechanism does not take effect on paths that are already tracked. With "--no-index" option, it can be used to diagnose which paths that should have been ignored have been mistakenly added to the index. * dw/check-ignore-sans-index: check-ignore: Add option to ignore index contents
Diffstat (limited to 'builtin/check-ignore.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index e2a1cef..594463a 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -5,7 +5,7 @@
#include "pathspec.h"
#include "parse-options.h"
-static int quiet, verbose, stdin_paths, show_non_matching;
+static int quiet, verbose, stdin_paths, show_non_matching, no_index;
static const char * const check_ignore_usage[] = {
"git check-ignore [options] pathname...",
"git check-ignore [options] --stdin < <list-of-paths>",
@@ -24,6 +24,8 @@ static const struct option check_ignore_options[] = {
N_("terminate input and output records by a NUL character")),
OPT_BOOL('n', "non-matching", &show_non_matching,
N_("show non-matching input paths")),
+ OPT_BOOL(0, "no-index", &no_index,
+ N_("ignore index when checking")),
@@ -166,7 +168,7 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)
die(_("--non-matching is only valid with --verbose"));
/* read_cache() is only necessary so we can watch out for submodules. */
- if (read_cache() < 0)
+ if (!no_index && read_cache() < 0)
die(_("index file corrupt"));
memset(&dir, 0, sizeof(dir));