@@ -1725,8 +1725,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
17251725 revs -> max_count = atoi (argv [1 ]);
17261726 revs -> no_walk = 0 ;
17271727 return 2 ;
1728- } else if (starts_with (arg , "-n" )) {
1729- revs -> max_count = atoi (arg + 2 );
1728+ } else if (skip_prefix (arg , "-n" , & optarg )) {
1729+ revs -> max_count = atoi (optarg );
17301730 revs -> no_walk = 0 ;
17311731 } else if ((argcount = parse_long_opt ("max-age" , argv , & optarg ))) {
17321732 revs -> max_age = atoi (optarg );
@@ -1785,16 +1785,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
17851785 } else if (!strcmp (arg , "--author-date-order" )) {
17861786 revs -> sort_order = REV_SORT_BY_AUTHOR_DATE ;
17871787 revs -> topo_order = 1 ;
1788- } else if (starts_with (arg , "--early-output" )) {
1789- int count = 100 ;
1790- switch (arg [14 ]) {
1791- case '=' :
1792- count = atoi (arg + 15 );
1793- /* Fallthrough */
1794- case 0 :
1795- revs -> topo_order = 1 ;
1796- revs -> early_output = count ;
1797- }
1788+ } else if (!strcmp (arg , "--early-output" )) {
1789+ revs -> early_output = 100 ;
1790+ revs -> topo_order = 1 ;
1791+ } else if (skip_prefix (arg , "--early-output=" , & optarg )) {
1792+ if (strtoul_ui (optarg , 10 , & revs -> early_output ) < 0 )
1793+ die ("'%s': not a non-negative integer" , optarg );
1794+ revs -> topo_order = 1 ;
17981795 } else if (!strcmp (arg , "--parents" )) {
17991796 revs -> rewrite_parents = 1 ;
18001797 revs -> print_parents = 1 ;
@@ -1810,13 +1807,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
18101807 revs -> min_parents = 2 ;
18111808 } else if (!strcmp (arg , "--no-merges" )) {
18121809 revs -> max_parents = 1 ;
1813- } else if (starts_with (arg , "--min-parents=" )) {
1814- revs -> min_parents = atoi (arg + 14 );
1815- } else if (starts_with (arg , "--no-min-parents" )) {
1810+ } else if (skip_prefix (arg , "--min-parents=" , & optarg )) {
1811+ revs -> min_parents = atoi (optarg );
1812+ } else if (! strcmp (arg , "--no-min-parents" )) {
18161813 revs -> min_parents = 0 ;
1817- } else if (starts_with (arg , "--max-parents=" )) {
1818- revs -> max_parents = atoi (arg + 14 );
1819- } else if (starts_with (arg , "--no-max-parents" )) {
1814+ } else if (skip_prefix (arg , "--max-parents=" , & optarg )) {
1815+ revs -> max_parents = atoi (optarg );
1816+ } else if (! strcmp (arg , "--no-max-parents" )) {
18201817 revs -> max_parents = -1 ;
18211818 } else if (!strcmp (arg , "--boundary" )) {
18221819 revs -> boundary = 1 ;
@@ -1897,14 +1894,15 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
18971894 revs -> verbose_header = 1 ;
18981895 revs -> pretty_given = 1 ;
18991896 get_commit_format (NULL , revs );
1900- } else if (starts_with (arg , "--pretty=" ) || starts_with (arg , "--format=" )) {
1897+ } else if (skip_prefix (arg , "--pretty=" , & optarg ) ||
1898+ skip_prefix (arg , "--format=" , & optarg )) {
19011899 /*
19021900 * Detached form ("--pretty X" as opposed to "--pretty=X")
19031901 * not allowed, since the argument is optional.
19041902 */
19051903 revs -> verbose_header = 1 ;
19061904 revs -> pretty_given = 1 ;
1907- get_commit_format (arg + 9 , revs );
1905+ get_commit_format (optarg , revs );
19081906 } else if (!strcmp (arg , "--expand-tabs" )) {
19091907 revs -> expand_tabs_in_log = 8 ;
19101908 } else if (!strcmp (arg , "--no-expand-tabs" )) {
@@ -1922,26 +1920,23 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
19221920 revs -> show_signature = 1 ;
19231921 } else if (!strcmp (arg , "--no-show-signature" )) {
19241922 revs -> show_signature = 0 ;
1925- } else if (!strcmp (arg , "--show-linear-break" ) ||
1926- starts_with (arg , "--show-linear-break=" )) {
1927- if (starts_with (arg , "--show-linear-break=" ))
1928- revs -> break_bar = xstrdup (arg + 20 );
1929- else
1930- revs -> break_bar = " .........." ;
1923+ } else if (!strcmp (arg , "--show-linear-break" )) {
1924+ revs -> break_bar = " .........." ;
19311925 revs -> track_linear = 1 ;
19321926 revs -> track_first_time = 1 ;
1933- } else if (starts_with (arg , "--show-notes=" ) ||
1934- starts_with (arg , "--notes=" )) {
1927+ } else if (skip_prefix (arg , "--show-linear-break=" , & optarg )) {
1928+ revs -> break_bar = xstrdup (optarg );
1929+ revs -> track_linear = 1 ;
1930+ revs -> track_first_time = 1 ;
1931+ } else if (skip_prefix (arg , "--show-notes=" , & optarg ) ||
1932+ skip_prefix (arg , "--notes=" , & optarg )) {
19351933 struct strbuf buf = STRBUF_INIT ;
19361934 revs -> show_notes = 1 ;
19371935 revs -> show_notes_given = 1 ;
1938- if (starts_with (arg , "--show-notes" )) {
1939- if (revs -> notes_opt .use_default_notes < 0 )
1940- revs -> notes_opt .use_default_notes = 1 ;
1941- strbuf_addstr (& buf , arg + 13 );
1942- }
1943- else
1944- strbuf_addstr (& buf , arg + 8 );
1936+ if (starts_with (arg , "--show-notes=" ) &&
1937+ revs -> notes_opt .use_default_notes < 0 )
1938+ revs -> notes_opt .use_default_notes = 1 ;
1939+ strbuf_addstr (& buf , optarg );
19451940 expand_notes_ref (& buf );
19461941 string_list_append (& revs -> notes_opt .extra_notes_refs ,
19471942 strbuf_detach (& buf , NULL ));
@@ -1978,8 +1973,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
19781973 revs -> abbrev = 0 ;
19791974 } else if (!strcmp (arg , "--abbrev" )) {
19801975 revs -> abbrev = DEFAULT_ABBREV ;
1981- } else if (starts_with (arg , "--abbrev=" )) {
1982- revs -> abbrev = strtoul (arg + 9 , NULL , 10 );
1976+ } else if (skip_prefix (arg , "--abbrev=" , & optarg )) {
1977+ revs -> abbrev = strtoul (optarg , NULL , 10 );
19831978 if (revs -> abbrev < MINIMUM_ABBREV )
19841979 revs -> abbrev = MINIMUM_ABBREV ;
19851980 else if (revs -> abbrev > 40 )
@@ -2139,20 +2134,20 @@ static int handle_revision_pseudo_opt(const char *submodule,
21392134 } else if ((argcount = parse_long_opt ("exclude" , argv , & optarg ))) {
21402135 add_ref_exclusion (& revs -> ref_excludes , optarg );
21412136 return argcount ;
2142- } else if (starts_with (arg , "--branches=" )) {
2137+ } else if (skip_prefix (arg , "--branches=" , & optarg )) {
21432138 struct all_refs_cb cb ;
21442139 init_all_refs_cb (& cb , revs , * flags );
2145- for_each_glob_ref_in (handle_one_ref , arg + 11 , "refs/heads/" , & cb );
2140+ for_each_glob_ref_in (handle_one_ref , optarg , "refs/heads/" , & cb );
21462141 clear_ref_exclusion (& revs -> ref_excludes );
2147- } else if (starts_with (arg , "--tags=" )) {
2142+ } else if (skip_prefix (arg , "--tags=" , & optarg )) {
21482143 struct all_refs_cb cb ;
21492144 init_all_refs_cb (& cb , revs , * flags );
2150- for_each_glob_ref_in (handle_one_ref , arg + 7 , "refs/tags/" , & cb );
2145+ for_each_glob_ref_in (handle_one_ref , optarg , "refs/tags/" , & cb );
21512146 clear_ref_exclusion (& revs -> ref_excludes );
2152- } else if (starts_with (arg , "--remotes=" )) {
2147+ } else if (skip_prefix (arg , "--remotes=" , & optarg )) {
21532148 struct all_refs_cb cb ;
21542149 init_all_refs_cb (& cb , revs , * flags );
2155- for_each_glob_ref_in (handle_one_ref , arg + 10 , "refs/remotes/" , & cb );
2150+ for_each_glob_ref_in (handle_one_ref , optarg , "refs/remotes/" , & cb );
21562151 clear_ref_exclusion (& revs -> ref_excludes );
21572152 } else if (!strcmp (arg , "--reflog" )) {
21582153 add_reflogs_to_pending (revs , * flags );
@@ -2162,14 +2157,14 @@ static int handle_revision_pseudo_opt(const char *submodule,
21622157 * flags ^= UNINTERESTING | BOTTOM ;
21632158 } else if (!strcmp (arg , "--no-walk" )) {
21642159 revs -> no_walk = REVISION_WALK_NO_WALK_SORTED ;
2165- } else if (starts_with (arg , "--no-walk=" )) {
2160+ } else if (skip_prefix (arg , "--no-walk=" , & optarg )) {
21662161 /*
21672162 * Detached form ("--no-walk X" as opposed to "--no-walk=X")
21682163 * not allowed, since the argument is optional.
21692164 */
2170- if (!strcmp (arg + 10 , "sorted" ))
2165+ if (!strcmp (optarg , "sorted" ))
21712166 revs -> no_walk = REVISION_WALK_NO_WALK_SORTED ;
2172- else if (!strcmp (arg + 10 , "unsorted" ))
2167+ else if (!strcmp (optarg , "unsorted" ))
21732168 revs -> no_walk = REVISION_WALK_NO_WALK_UNSORTED ;
21742169 else
21752170 return error ("invalid argument to --no-walk" );
0 commit comments