checkout,clone: check return value of create_symref
[gitweb.git] / builtin / for-each-ref.c
index ae5419e0de74f9cfe38dc281dca79a06c3ed041b..4e9f6c29bf1e0c1cc7b44548f49077c2e4a81ec8 100644 (file)
@@ -8,6 +8,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>]]"),
        NULL
 };
 
@@ -38,6 +40,9 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                OPT_CALLBACK(0, "points-at", &filter.points_at,
                             N_("object"), N_("print only refs which points at the given object"),
                             parse_opt_object_name),
+               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_END(),
        };
 
@@ -63,6 +68,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
        git_config(git_default_config, NULL);
 
        filter.name_patterns = argv;
+       filter.match_as_path = 1;
        filter_refs(&array, &filter, FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN);
        ref_array_sort(sorting, &array);