grep: recurse in-process using 'struct repository'
[gitweb.git] / builtin / for-each-ref.c
index 4e9f6c29bf1e0c1cc7b44548f49077c2e4a81ec8..52be99cbacdd84f60e5b9f2efd1f1d50f602cdb8 100644 (file)
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "cache.h"
+#include "config.h"
 #include "refs.h"
 #include "object.h"
 #include "parse-options.h"
@@ -8,8 +9,8 @@
 static char const * const for_each_ref_usage[] = {
        N_("git for-each-ref [<options>] [<pattern>]"),
        N_("git for-each-ref [--points-at <object>]"),
-       N_("git for-each-ref [(--merged | --no-merged) [<object>]]"),
-       N_("git for-each-ref [--contains [<object>]]"),
+       N_("git for-each-ref [(--merged | --no-merged) [<commit>]]"),
+       N_("git for-each-ref [--contains [<commit>]] [--no-contains [<commit>]]"),
        NULL
 };
 
@@ -18,7 +19,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
        int i;
        const char *format = "%(objectname) %(objecttype)\t%(refname)";
        struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
-       int maxcount = 0, quote_style = 0;
+       int maxcount = 0, quote_style = 0, icase = 0;
        struct ref_array array;
        struct ref_filter filter;
 
@@ -43,6 +44,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                OPT_MERGED(&filter, N_("print only refs that are merged")),
                OPT_NO_MERGED(&filter, N_("print only refs that are not merged")),
                OPT_CONTAINS(&filter.with_commit, N_("print only refs which contain the commit")),
+               OPT_NO_CONTAINS(&filter.no_commit, N_("print only refs which don't contain the commit")),
+               OPT_BOOL(0, "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_END(),
        };
 
@@ -63,6 +66,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
 
        if (!sorting)
                sorting = ref_default_sorting();
+       sorting->ignore_case = icase;
+       filter.ignore_case = icase;
 
        /* for warn_ambiguous_refs */
        git_config(git_default_config, NULL);