25
25
#include "wildmatch.h"
26
26
27
27
#define MAX_TAGS (FLAG_BITS - 1)
28
+ #define DEFAULT_CANDIDATES 10
28
29
29
30
define_commit_slab (commit_names , struct commit_name * );
30
31
@@ -41,7 +42,7 @@ static int tags; /* Allow lightweight tags */
41
42
static int longformat ;
42
43
static int first_parent ;
43
44
static int abbrev = -1 ; /* unspecified */
44
- static int max_candidates = 10 ;
45
+ static int max_candidates = DEFAULT_CANDIDATES ;
45
46
static struct hashmap names ;
46
47
static int have_util ;
47
48
static struct string_list patterns = STRING_LIST_INIT_NODUP ;
@@ -557,6 +558,15 @@ static void describe(const char *arg, int last_one)
557
558
strbuf_release (& sb );
558
559
}
559
560
561
+ static int option_parse_exact_match (const struct option * opt , const char * arg ,
562
+ int unset )
563
+ {
564
+ BUG_ON_OPT_ARG (arg );
565
+
566
+ max_candidates = unset ? DEFAULT_CANDIDATES : 0 ;
567
+ return 0 ;
568
+ }
569
+
560
570
int cmd_describe (int argc , const char * * argv , const char * prefix )
561
571
{
562
572
int contains = 0 ;
@@ -568,8 +578,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
568
578
OPT_BOOL (0 , "long" , & longformat , N_ ("always use long format" )),
569
579
OPT_BOOL (0 , "first-parent" , & first_parent , N_ ("only follow first parent" )),
570
580
OPT__ABBREV (& abbrev ),
571
- OPT_SET_INT (0 , "exact-match" , & max_candidates ,
572
- N_ ("only output exact matches" ), 0 ),
581
+ OPT_CALLBACK_F (0 , "exact-match" , NULL , NULL ,
582
+ N_ ("only output exact matches" ),
583
+ PARSE_OPT_NOARG , option_parse_exact_match ),
573
584
OPT_INTEGER (0 , "candidates" , & max_candidates ,
574
585
N_ ("consider <n> most recent tags (default: 10)" )),
575
586
OPT_STRING_LIST (0 , "match" , & patterns , N_ ("pattern" ),
0 commit comments