Revert "Merge branch 'ps/contains-id-error-message' into next"
authorJunio C Hamano <gitster@pobox.com>
Tue, 6 Mar 2018 21:29:32 +0000 (13:29 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Mar 2018 21:29:37 +0000 (13:29 -0800)
This reverts commit 9623d6817b680fa341cf7f37172995286db177a8, reversing
changes made to 565a3141ceb4e3c738fb5c1752bb8a7d638bc3a9.

builtin/branch.c
builtin/for-each-ref.c
builtin/tag.c
parse-options.h
ref-filter.c
ref-filter.h
t/tcontains.sh [deleted file]
index 925a192dde0cdb79f422a99ff0850b374c2e5bed..6d0cea9d4bcc4eb866280d6424a6dec32b5f9c87 100644 (file)
@@ -596,10 +596,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                OPT__COLOR(&branch_use_color, N_("use colored output")),
                OPT_SET_INT('r', "remotes",     &filter.kind, N_("act on remote-tracking branches"),
                        FILTER_REFS_REMOTES),
-               OPT_CONTAINS(&filter.with_commit_strs, N_("print only branches that contain the commit")),
-               OPT_NO_CONTAINS(&filter.no_commit_strs, N_("print only branches that don't contain the commit")),
-               OPT_WITH(&filter.with_commit_strs, N_("print only branches that contain the commit")),
-               OPT_WITHOUT(&filter.no_commit_strs, N_("print only branches that don't contain the commit")),
+               OPT_CONTAINS(&filter.with_commit, N_("print only branches that contain the commit")),
+               OPT_NO_CONTAINS(&filter.no_commit, N_("print only branches that don't contain the commit")),
+               OPT_WITH(&filter.with_commit, N_("print only branches that contain the commit")),
+               OPT_WITHOUT(&filter.no_commit, N_("print only branches that don't contain the commit")),
                OPT__ABBREV(&filter.abbrev),
 
                OPT_GROUP(N_("Specific git-branch actions:")),
@@ -657,8 +657,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        if (!delete && !rename && !copy && !edit_description && !new_upstream && !unset_upstream && argc == 0)
                list = 1;
 
-       if (filter.with_commit_strs.nr || filter.merge != REF_FILTER_MERGED_NONE || filter.points_at.nr ||
-           filter.no_commit_strs.nr)
+       if (filter.with_commit || filter.merge != REF_FILTER_MERGED_NONE || filter.points_at.nr ||
+           filter.no_commit)
                list = 1;
 
        if (!!delete + !!rename + !!copy + !!new_upstream +
index deb9a779a80c6b1647c244ba567dbd3129cda4d9..e931be9ce4d9f180de23d09d227e5a2f571f4f1a 100644 (file)
@@ -44,8 +44,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                             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_strs, N_("print only refs which contain the commit")),
-               OPT_NO_CONTAINS(&filter.no_commit_strs, N_("print only refs which don't contain the commit")),
+               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(),
        };
index ca9910ba5fc43a0a5e4e6a129e4cf8f40a23de07..da186691ed8853bc5848c4106c752b015756eda3 100644 (file)
@@ -402,10 +402,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
                OPT_GROUP(N_("Tag listing options")),
                OPT_COLUMN(0, "column", &colopts, N_("show tag list in columns")),
-               OPT_CONTAINS(&filter.with_commit_strs, N_("print only tags that contain the commit")),
-               OPT_NO_CONTAINS(&filter.no_commit_strs, N_("print only tags that don't contain the commit")),
-               OPT_WITH(&filter.with_commit_strs, N_("print only tags that contain the commit")),
-               OPT_WITHOUT(&filter.no_commit_strs, N_("print only tags that don't contain the commit")),
+               OPT_CONTAINS(&filter.with_commit, N_("print only tags that contain the commit")),
+               OPT_NO_CONTAINS(&filter.no_commit, N_("print only tags that don't contain the commit")),
+               OPT_WITH(&filter.with_commit, N_("print only tags that contain the commit")),
+               OPT_WITHOUT(&filter.no_commit, N_("print only tags that don't contain the commit")),
                OPT_MERGED(&filter, N_("print only tags that are merged")),
                OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
                OPT_CALLBACK(0 , "sort", sorting_tail, N_("key"),
@@ -441,8 +441,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        if (!cmdmode) {
                if (argc == 0)
                        cmdmode = 'l';
-               else if (filter.points_at.nr || filter.merge_commit ||
-                        filter.with_commit_strs.nr || filter.no_commit_strs.nr ||
+               else if (filter.with_commit || filter.no_commit ||
+                        filter.points_at.nr || filter.merge_commit ||
                         filter.lines != -1)
                        cmdmode = 'l';
        }
@@ -479,9 +479,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        }
        if (filter.lines != -1)
                die(_("-n option is only allowed in list mode"));
-       if (filter.with_commit_strs.nr)
+       if (filter.with_commit)
                die(_("--contains option is only allowed in list mode"));
-       if (filter.no_commit_strs.nr)
+       if (filter.no_commit)
                die(_("--no-contains option is only allowed in list mode"));
        if (filter.points_at.nr)
                die(_("--points-at option is only allowed in list mode"));
index 7258fe1c2d7cac07bc5a8aec03e88acc2d8a4cc9..0ba08691e650db0f519e5a67b647b89ef089a74f 100644 (file)
@@ -268,9 +268,8 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);
 #define _OPT_CONTAINS_OR_WITH(name, variable, help, flag) \
        { OPTION_CALLBACK, 0, name, (variable), N_("commit"), (help), \
          PARSE_OPT_LASTARG_DEFAULT | flag, \
-         parse_opt_string_list, (intptr_t) "HEAD" \
+         parse_opt_commits, (intptr_t) "HEAD" \
        }
-
 #define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH("contains", v, h, PARSE_OPT_NONEG)
 #define OPT_NO_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH("no-contains", v, h, PARSE_OPT_NONEG)
 #define OPT_WITH(v, h) _OPT_CONTAINS_OR_WITH("with", v, h, PARSE_OPT_HIDDEN | PARSE_OPT_NONEG)
index c4a98281fbdb2f5c37eadb0ff21c6fcded30daaf..45fc56216aaa8fd084a10514f6f4912878ab1627 100644 (file)
@@ -1997,25 +1997,6 @@ static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)
        free(to_clear);
 }
 
-int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
-{
-       struct object_id oid;
-       struct commit *commit;
-
-       if (get_oid(item->string, &oid)) {
-               error(_("malformed object name %s"), item->string);
-               exit(1);
-       }
-       commit = lookup_commit_reference(&oid);
-       if (!commit) {
-               error(_("no such commit %s"), item->string);
-               exit(1);
-       }
-       commit_list_insert(commit, commit_list);
-
-       return 0;
-}
-
 /*
  * API for filtering a set of refs. Based on the type of refs the user
  * has requested, we iterate through those refs and apply filters
@@ -2028,10 +2009,6 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
        int ret = 0;
        unsigned int broken = 0;
 
-       /* Convert string representation and add to commit list. */
-       for_each_string_list(&filter->with_commit_strs, add_str_to_commit_list, &filter->with_commit);
-       for_each_string_list(&filter->no_commit_strs, add_str_to_commit_list, &filter->no_commit);
-
        ref_cbdata.array = array;
        ref_cbdata.filter = filter;
 
index 62f37760fc33e30befb76deb262323e8e474ec8d..0d98342b343196387c0f4e2dcd5978a9361d8edb 100644 (file)
@@ -55,9 +55,6 @@ struct ref_filter {
        struct commit_list *with_commit;
        struct commit_list *no_commit;
 
-       struct string_list with_commit_strs;
-       struct string_list no_commit_strs;
-
        enum {
                REF_FILTER_MERGED_NONE = 0,
                REF_FILTER_MERGED_INCLUDE,
diff --git a/t/tcontains.sh b/t/tcontains.sh
deleted file mode 100755 (executable)
index 4856111..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/bin/sh
-
-test_description='Test "contains" argument behavior'
-
-. ./test-lib.sh
-
-test_expect_success 'setup ' '
-       git init . &&
-       echo "this is a test" >file &&
-       git add -A &&
-       git commit -am "tag test" &&
-       git tag "v1.0" &&
-       git tag "v1.1"
-'
-
-test_expect_success 'tag --contains <existent_tag>' '
-       git tag --contains "v1.0" >actual &&
-       grep "v1.0" actual &&
-       grep "v1.1" actual
-'
-
-test_expect_success 'tag --contains <inexistent_tag>' '
-       test_must_fail git tag --contains "notag" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'tag --no-contains <existent_tag>' '
-       git tag --no-contains "v1.1" >actual &&
-       test_line_count = 0 actual
-'
-
-test_expect_success 'tag --no-contains <inexistent_tag>' '
-       test_must_fail git tag --no-contains "notag" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'tag usage error' '
-       test_must_fail git tag --noopt 2>actual &&
-       test_i18ngrep "usage" actual
-'
-
-test_expect_success 'branch --contains <existent_commit>' '
-       git branch --contains "master" >actual &&
-       test_i18ngrep "master" actual
-'
-
-test_expect_success 'branch --contains <inexistent_commit>' '
-       test_must_fail git branch --no-contains "nocommit" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'branch --no-contains <existent_commit>' '
-       git branch --no-contains "master" >actual &&
-       test_line_count = 0 actual
-'
-
-test_expect_success 'branch --no-contains <inexistent_commit>' '
-       test_must_fail git branch --no-contains "nocommit" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'branch usage error' '
-       test_must_fail git branch --noopt 2>actual &&
-       test_i18ngrep "usage" actual
-'
-
-test_expect_success 'for-each-ref --contains <existent_object>' '
-       git for-each-ref --contains "master" >actual &&
-       test_line_count = 3 actual
-'
-
-test_expect_success 'for-each-ref --contains <inexistent_object>' '
-       test_must_fail git for-each-ref --no-contains "noobject" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'for-each-ref --no-contains <existent_object>' '
-       git for-each-ref --no-contains "master" >actual &&
-       test_line_count = 0 actual
-'
-
-test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
-       test_must_fail git for-each-ref --no-contains "noobject" 2>actual &&
-       test_i18ngrep "error" actual
-'
-
-test_expect_success 'for-each-ref usage error' '
-       test_must_fail git for-each-ref --noopt 2>actual &&
-       test_i18ngrep "usage" actual
-'
-
-test_done