@@ -1148,6 +1148,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1148
1148
int * unkc , const char * * unkv )
1149
1149
{
1150
1150
const char * arg = argv [0 ];
1151
+ const char * optarg ;
1152
+ int argcount ;
1151
1153
1152
1154
/* pseudo revision arguments */
1153
1155
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
1160
1162
return 1 ;
1161
1163
}
1162
1164
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 );
1165
1167
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 ;
1168
1172
} else if ((* arg == '-' ) && isdigit (arg [1 ])) {
1169
1173
/* accept -<digit>, like traditional "head" */
1170
1174
revs -> max_count = atoi (arg + 1 );
@@ -1178,18 +1182,24 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1178
1182
} else if (!prefixcmp (arg , "-n" )) {
1179
1183
revs -> max_count = atoi (arg + 2 );
1180
1184
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 ;
1193
1203
} else if (!strcmp (arg , "--first-parent" )) {
1194
1204
revs -> first_parent_only = 1 ;
1195
1205
} else if (!strcmp (arg , "--ancestry-path" )) {
@@ -1295,6 +1305,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1295
1305
revs -> pretty_given = 1 ;
1296
1306
get_commit_format (arg + 8 , revs );
1297
1307
} 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
+ */
1298
1312
revs -> verbose_header = 1 ;
1299
1313
revs -> pretty_given = 1 ;
1300
1314
get_commit_format (arg + 9 , revs );
@@ -1359,21 +1373,25 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1359
1373
} else if (!strcmp (arg , "--relative-date" )) {
1360
1374
revs -> date_mode = DATE_RELATIVE ;
1361
1375
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 );
1364
1378
revs -> date_mode_explicit = 1 ;
1379
+ return argcount ;
1365
1380
} else if (!strcmp (arg , "--log-size" )) {
1366
1381
revs -> show_log_size = 1 ;
1367
1382
}
1368
1383
/*
1369
1384
* Grepping the commit log
1370
1385
*/
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 ;
1377
1395
} else if (!strcmp (arg , "--extended-regexp" ) || !strcmp (arg , "-E" )) {
1378
1396
revs -> grep_filter .regflags |= REG_EXTENDED ;
1379
1397
} 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
1382
1400
revs -> grep_filter .fixed = 1 ;
1383
1401
} else if (!strcmp (arg , "--all-match" )) {
1384
1402
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 );
1389
1406
else
1390
1407
git_log_output_encoding = "" ;
1408
+ return argcount ;
1391
1409
} else if (!strcmp (arg , "--reverse" )) {
1392
1410
revs -> reverse ^= 1 ;
1393
1411
} else if (!strcmp (arg , "--children" )) {
0 commit comments