@@ -1148,6 +1148,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
11481148 int * unkc , const char * * unkv )
11491149{
11501150 const char * arg = argv [0 ];
1151+ const char * optarg ;
1152+ int argcount ;
11511153
11521154 /* pseudo revision arguments */
11531155 if (!strcmp (arg , "--all" ) || !strcmp (arg , "--branches" ) ||
@@ -1160,11 +1162,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
11601162 return 1 ;
11611163 }
11621164
1163- if (! prefixcmp ( arg , "-- max-count=" )) {
1164- revs -> max_count = atoi (arg + 12 );
1165+ if (( argcount = parse_long_opt ( " max-count" , argv , & optarg ) )) {
1166+ revs -> max_count = atoi (optarg );
11651167 revs -> no_walk = 0 ;
1166- } else if (!prefixcmp (arg , "--skip=" )) {
1167- revs -> skip_count = atoi (arg + 7 );
1168+ return argcount ;
1169+ } else if ((argcount = parse_long_opt ("skip" , argv , & optarg ))) {
1170+ revs -> skip_count = atoi (optarg );
1171+ return argcount ;
11681172 } else if ((* arg == '-' ) && isdigit (arg [1 ])) {
11691173 /* accept -<digit>, like traditional "head" */
11701174 revs -> max_count = atoi (arg + 1 );
@@ -1178,18 +1182,24 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
11781182 } else if (!prefixcmp (arg , "-n" )) {
11791183 revs -> max_count = atoi (arg + 2 );
11801184 revs -> no_walk = 0 ;
1181- } else if (!prefixcmp (arg , "--max-age=" )) {
1182- revs -> max_age = atoi (arg + 10 );
1183- } else if (!prefixcmp (arg , "--since=" )) {
1184- revs -> max_age = approxidate (arg + 8 );
1185- } else if (!prefixcmp (arg , "--after=" )) {
1186- revs -> max_age = approxidate (arg + 8 );
1187- } else if (!prefixcmp (arg , "--min-age=" )) {
1188- revs -> min_age = atoi (arg + 10 );
1189- } else if (!prefixcmp (arg , "--before=" )) {
1190- revs -> min_age = approxidate (arg + 9 );
1191- } else if (!prefixcmp (arg , "--until=" )) {
1192- revs -> min_age = approxidate (arg + 8 );
1185+ } else if ((argcount = parse_long_opt ("max-age" , argv , & optarg ))) {
1186+ revs -> max_age = atoi (optarg );
1187+ return argcount ;
1188+ } else if ((argcount = parse_long_opt ("since" , argv , & optarg ))) {
1189+ revs -> max_age = approxidate (optarg );
1190+ return argcount ;
1191+ } else if ((argcount = parse_long_opt ("after" , argv , & optarg ))) {
1192+ revs -> max_age = approxidate (optarg );
1193+ return argcount ;
1194+ } else if ((argcount = parse_long_opt ("min-age" , argv , & optarg ))) {
1195+ revs -> min_age = atoi (optarg );
1196+ return argcount ;
1197+ } else if ((argcount = parse_long_opt ("before" , argv , & optarg ))) {
1198+ revs -> min_age = approxidate (optarg );
1199+ return argcount ;
1200+ } else if ((argcount = parse_long_opt ("until" , argv , & optarg ))) {
1201+ revs -> min_age = approxidate (optarg );
1202+ return argcount ;
11931203 } else if (!strcmp (arg , "--first-parent" )) {
11941204 revs -> first_parent_only = 1 ;
11951205 } else if (!strcmp (arg , "--ancestry-path" )) {
@@ -1295,6 +1305,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
12951305 revs -> pretty_given = 1 ;
12961306 get_commit_format (arg + 8 , revs );
12971307 } else if (!prefixcmp (arg , "--pretty=" ) || !prefixcmp (arg , "--format=" )) {
1308+ /*
1309+ * Detached form ("--pretty X" as opposed to "--pretty=X")
1310+ * not allowed, since the argument is optional.
1311+ */
12981312 revs -> verbose_header = 1 ;
12991313 revs -> pretty_given = 1 ;
13001314 get_commit_format (arg + 9 , revs );
@@ -1359,21 +1373,25 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
13591373 } else if (!strcmp (arg , "--relative-date" )) {
13601374 revs -> date_mode = DATE_RELATIVE ;
13611375 revs -> date_mode_explicit = 1 ;
1362- } else if (! strncmp ( arg , "-- date= " , 7 )) {
1363- revs -> date_mode = parse_date_format (arg + 7 );
1376+ } else if (( argcount = parse_long_opt ( " date" , argv , & optarg ) )) {
1377+ revs -> date_mode = parse_date_format (optarg );
13641378 revs -> date_mode_explicit = 1 ;
1379+ return argcount ;
13651380 } else if (!strcmp (arg , "--log-size" )) {
13661381 revs -> show_log_size = 1 ;
13671382 }
13681383 /*
13691384 * Grepping the commit log
13701385 */
1371- else if (!prefixcmp (arg , "--author=" )) {
1372- add_header_grep (revs , GREP_HEADER_AUTHOR , arg + 9 );
1373- } else if (!prefixcmp (arg , "--committer=" )) {
1374- add_header_grep (revs , GREP_HEADER_COMMITTER , arg + 12 );
1375- } else if (!prefixcmp (arg , "--grep=" )) {
1376- add_message_grep (revs , arg + 7 );
1386+ else if ((argcount = parse_long_opt ("author" , argv , & optarg ))) {
1387+ add_header_grep (revs , GREP_HEADER_AUTHOR , optarg );
1388+ return argcount ;
1389+ } else if ((argcount = parse_long_opt ("committer" , argv , & optarg ))) {
1390+ add_header_grep (revs , GREP_HEADER_COMMITTER , optarg );
1391+ return argcount ;
1392+ } else if ((argcount = parse_long_opt ("grep" , argv , & optarg ))) {
1393+ add_message_grep (revs , optarg );
1394+ return argcount ;
13771395 } else if (!strcmp (arg , "--extended-regexp" ) || !strcmp (arg , "-E" )) {
13781396 revs -> grep_filter .regflags |= REG_EXTENDED ;
13791397 } else if (!strcmp (arg , "--regexp-ignore-case" ) || !strcmp (arg , "-i" )) {
@@ -1382,12 +1400,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
13821400 revs -> grep_filter .fixed = 1 ;
13831401 } else if (!strcmp (arg , "--all-match" )) {
13841402 revs -> grep_filter .all_match = 1 ;
1385- } else if (!prefixcmp (arg , "--encoding=" )) {
1386- arg += 11 ;
1387- if (strcmp (arg , "none" ))
1388- git_log_output_encoding = xstrdup (arg );
1403+ } else if ((argcount = parse_long_opt ("encoding" , argv , & optarg ))) {
1404+ if (strcmp (optarg , "none" ))
1405+ git_log_output_encoding = xstrdup (optarg );
13891406 else
13901407 git_log_output_encoding = "" ;
1408+ return argcount ;
13911409 } else if (!strcmp (arg , "--reverse" )) {
13921410 revs -> reverse ^= 1 ;
13931411 } else if (!strcmp (arg , "--children" )) {
0 commit comments