Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-07-28 19:45:21 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-28 19:45:21 +0300
commit3085f949bf4aafe04dac7441308bb769ccf9c351 (patch)
treebf95004a4a6f7c1836c455231d93282dce5f8f51 /builtin/describe.c
parentc8a33b44c5a56c7b2c7778506acdc71e5365ec1f (diff)
parentc95ae3ff9cdcbe6229dc3aa4cd7aa14b1354759a (diff)
Merge branch 'rs/describe-parseopt-fix'
Command line parser fix. * rs/describe-parseopt-fix: describe: fix --no-exact-match
Diffstat (limited to 'builtin/describe.c')
-rw-r--r--builtin/describe.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 7ce23e1b8e..b28a4a1f82 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -25,6 +25,7 @@
#include "wildmatch.h"
#define MAX_TAGS (FLAG_BITS - 1)
+#define DEFAULT_CANDIDATES 10
define_commit_slab(commit_names, struct commit_name *);
@@ -41,7 +42,7 @@ static int tags; /* Allow lightweight tags */
static int longformat;
static int first_parent;
static int abbrev = -1; /* unspecified */
-static int max_candidates = 10;
+static int max_candidates = DEFAULT_CANDIDATES;
static struct hashmap names;
static int have_util;
static struct string_list patterns = STRING_LIST_INIT_NODUP;
@@ -557,6 +558,15 @@ static void describe(const char *arg, int last_one)
strbuf_release(&sb);
}
+static int option_parse_exact_match(const struct option *opt, const char *arg,
+ int unset)
+{
+ BUG_ON_OPT_ARG(arg);
+
+ max_candidates = unset ? DEFAULT_CANDIDATES : 0;
+ return 0;
+}
+
int cmd_describe(int argc, const char **argv, const char *prefix)
{
int contains = 0;
@@ -568,8 +578,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "long", &longformat, N_("always use long format")),
OPT_BOOL(0, "first-parent", &first_parent, N_("only follow first parent")),
OPT__ABBREV(&abbrev),
- OPT_SET_INT(0, "exact-match", &max_candidates,
- N_("only output exact matches"), 0),
+ OPT_CALLBACK_F(0, "exact-match", NULL, NULL,
+ N_("only output exact matches"),
+ PARSE_OPT_NOARG, option_parse_exact_match),
OPT_INTEGER(0, "candidates", &max_candidates,
N_("consider <n> most recent tags (default: 10)")),
OPT_STRING_LIST(0, "match", &patterns, N_("pattern"),