revisions: split handle_revision_opt() from setup_revisions()
Add two fields to struct rev_info: - .def to store --default argument; and - .show_merge 1-bit field. handle_revision_opt() is able to deal with any revision option, and consumes them, and leaves revision arguments or pseudo arguments (like --all, --not, ...) in place. For now setup_revisions() does a pass of handle_revision_opt() again so that code not using it in a parse-opt parser still work the same. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pierre Habouzit committed
Jul 8, 2008 at 15:19 UTC
02e542206f26cf06817ec2e9ffecf4f416e8e332
2 files changed
+226
-326
revision.c
+222
-326
@@ -957,6 +957,212 @@ static void add_ignore_packed(struct rev_info *revs, const char *name)
957
revs->ignore_packed[num] = NULL;
958
}
959
960
+int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
961
+ int *unkc, const char **unkv)
962
+{
963
+ const char *arg = argv[0];
964
+
965
+ /* pseudo revision arguments */
966
+ if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") ||
967
+ !strcmp(arg, "--tags") || !strcmp(arg, "--remotes") ||
968
+ !strcmp(arg, "--reflog") || !strcmp(arg, "--not") ||
969
+ !strcmp(arg, "--no-walk") || !strcmp(arg, "--do-walk"))
970
+ {
971
+ unkv[(*unkc)++] = arg;
972
+ return 0;
973
+ }
974
+
975
+ if (!prefixcmp(arg, "--max-count=")) {
976
+ revs->max_count = atoi(arg + 12);
977
+ } else if (!prefixcmp(arg, "--skip=")) {
978
+ revs->skip_count = atoi(arg + 7);
979
+ } else if ((*arg == '-') && isdigit(arg[1])) {
980
+ /* accept -<digit>, like traditional "head" */
981
+ revs->max_count = atoi(arg + 1);
982
+ } else if (!strcmp(arg, "-n")) {
983
+ if (argc <= 1)
984
+ return error("-n requires an argument");
985
+ revs->max_count = atoi(argv[1]);
986
+ return 2;
987
+ } else if (!prefixcmp(arg, "-n")) {
988
+ revs->max_count = atoi(arg + 2);
989
+ } else if (!prefixcmp(arg, "--max-age=")) {
990
+ revs->max_age = atoi(arg + 10);
991
+ } else if (!prefixcmp(arg, "--since=")) {
992
+ revs->max_age = approxidate(arg + 8);
993
+ } else if (!prefixcmp(arg, "--after=")) {
994
+ revs->max_age = approxidate(arg + 8);
995
+ } else if (!prefixcmp(arg, "--min-age=")) {
996
+ revs->min_age = atoi(arg + 10);
997
+ } else if (!prefixcmp(arg, "--before=")) {
998
+ revs->min_age = approxidate(arg + 9);
999
+ } else if (!prefixcmp(arg, "--until=")) {
1000
+ revs->min_age = approxidate(arg + 8);
1001
+ } else if (!strcmp(arg, "--first-parent")) {
1002
+ revs->first_parent_only = 1;
1003
+ } else if (!strcmp(arg, "-g") || !strcmp(arg, "--walk-reflogs")) {
1004
+ init_reflog_walk(&revs->reflog_info);
1005
+ } else if (!strcmp(arg, "--default")) {
1006
+ if (argc <= 1)
1007
+ return error("bad --default argument");
1008
+ revs->def = argv[1];
1009
+ return 2;
1010
+ } else if (!strcmp(arg, "--merge")) {
1011
+ revs->show_merge = 1;
1012
+ } else if (!strcmp(arg, "--topo-order")) {
1013
+ revs->lifo = 1;
1014
+ revs->topo_order = 1;
1015
+ } else if (!strcmp(arg, "--date-order")) {
1016
+ revs->lifo = 0;
1017
+ revs->topo_order = 1;
1018
+ } else if (!prefixcmp(arg, "--early-output")) {
1019
+ int count = 100;
1020
+ switch (arg[14]) {
1021
+ case '=':
1022
+ count = atoi(arg+15);
1023
+ /* Fallthrough */
1024
+ case 0:
1025
+ revs->topo_order = 1;
1026
+ revs->early_output = count;
1027
+ }
1028
+ } else if (!strcmp(arg, "--parents")) {
1029
+ revs->rewrite_parents = 1;
1030
+ revs->print_parents = 1;
1031
+ } else if (!strcmp(arg, "--dense")) {
1032
+ revs->dense = 1;
1033
+ } else if (!strcmp(arg, "--sparse")) {
1034
+ revs->dense = 0;
1035
+ } else if (!strcmp(arg, "--show-all")) {
1036
+ revs->show_all = 1;
1037
+ } else if (!strcmp(arg, "--remove-empty")) {
1038
+ revs->remove_empty_trees = 1;
1039
+ } else if (!strcmp(arg, "--no-merges")) {
1040
+ revs->no_merges = 1;
1041
+ } else if (!strcmp(arg, "--boundary")) {
1042
+ revs->boundary = 1;
1043
+ } else if (!strcmp(arg, "--left-right")) {
1044
+ revs->left_right = 1;
1045
+ } else if (!strcmp(arg, "--cherry-pick")) {
1046
+ revs->cherry_pick = 1;
1047
+ revs->limited = 1;
1048
+ } else if (!strcmp(arg, "--objects")) {
1049
+ revs->tag_objects = 1;
1050
+ revs->tree_objects = 1;
1051
+ revs->blob_objects = 1;
1052
+ } else if (!strcmp(arg, "--objects-edge")) {
1053
+ revs->tag_objects = 1;
1054
+ revs->tree_objects = 1;
1055
+ revs->blob_objects = 1;
1056
+ revs->edge_hint = 1;
1057
+ } else if (!strcmp(arg, "--unpacked")) {
1058
+ revs->unpacked = 1;
1059
+ free(revs->ignore_packed);
1060
+ revs->ignore_packed = NULL;
1061
+ revs->num_ignore_packed = 0;
1062
+ } else if (!prefixcmp(arg, "--unpacked=")) {
1063
+ revs->unpacked = 1;
1064
+ add_ignore_packed(revs, arg+11);
1065
+ } else if (!strcmp(arg, "-r")) {
1066
+ revs->diff = 1;
1067
+ DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1068
+ } else if (!strcmp(arg, "-t")) {
1069
+ revs->diff = 1;
1070
+ DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1071
+ DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
1072
+ } else if (!strcmp(arg, "-m")) {
1073
+ revs->ignore_merges = 0;
1074
+ } else if (!strcmp(arg, "-c")) {
1075
+ revs->diff = 1;
1076
+ revs->dense_combined_merges = 0;
1077
+ revs->combine_merges = 1;
1078
+ } else if (!strcmp(arg, "--cc")) {
1079
+ revs->diff = 1;
1080
+ revs->dense_combined_merges = 1;
1081
+ revs->combine_merges = 1;
1082
+ } else if (!strcmp(arg, "-v")) {
1083
+ revs->verbose_header = 1;
1084
+ } else if (!strcmp(arg, "--pretty")) {
1085
+ revs->verbose_header = 1;
1086
+ get_commit_format(arg+8, revs);
1087
+ } else if (!prefixcmp(arg, "--pretty=")) {
1088
+ revs->verbose_header = 1;
1089
+ get_commit_format(arg+9, revs);
1090
+ } else if (!strcmp(arg, "--graph")) {
1091
+ revs->topo_order = 1;
1092
+ revs->rewrite_parents = 1;
1093
+ revs->graph = graph_init(revs);
1094
+ } else if (!strcmp(arg, "--root")) {
1095
+ revs->show_root_diff = 1;
1096
+ } else if (!strcmp(arg, "--no-commit-id")) {
1097
+ revs->no_commit_id = 1;
1098
+ } else if (!strcmp(arg, "--always")) {
1099
+ revs->always_show_header = 1;
1100
+ } else if (!strcmp(arg, "--no-abbrev")) {
1101
+ revs->abbrev = 0;
1102
+ } else if (!strcmp(arg, "--abbrev")) {
1103
+ revs->abbrev = DEFAULT_ABBREV;
1104
+ } else if (!prefixcmp(arg, "--abbrev=")) {
1105
+ revs->abbrev = strtoul(arg + 9, NULL, 10);
1106
+ if (revs->abbrev < MINIMUM_ABBREV)
1107
+ revs->abbrev = MINIMUM_ABBREV;
1108
+ else if (revs->abbrev > 40)
1109
+ revs->abbrev = 40;
1110
+ } else if (!strcmp(arg, "--abbrev-commit")) {
1111
+ revs->abbrev_commit = 1;
1112
+ } else if (!strcmp(arg, "--full-diff")) {
1113
+ revs->diff = 1;
1114
+ revs->full_diff = 1;
1115
+ } else if (!strcmp(arg, "--full-history")) {
1116
+ revs->simplify_history = 0;
1117
+ } else if (!strcmp(arg, "--relative-date")) {
1118
+ revs->date_mode = DATE_RELATIVE;
1119
+ } else if (!strncmp(arg, "--date=", 7)) {
1120
+ revs->date_mode = parse_date_format(arg + 7);
1121
+ } else if (!strcmp(arg, "--log-size")) {
1122
+ revs->show_log_size = 1;
1123
+ }
1124
+ /*
1125
+ * Grepping the commit log
1126
+ */
1127
+ else if (!prefixcmp(arg, "--author=")) {
1128
+ add_header_grep(revs, "author", arg+9);
1129
+ } else if (!prefixcmp(arg, "--committer=")) {
1130
+ add_header_grep(revs, "committer", arg+12);
1131
+ } else if (!prefixcmp(arg, "--grep=")) {
1132
+ add_message_grep(revs, arg+7);
1133
+ } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
1134
+ if (revs->grep_filter)
1135
+ revs->grep_filter->regflags |= REG_EXTENDED;
1136
+ } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
1137
+ if (revs->grep_filter)
1138
+ revs->grep_filter->regflags |= REG_ICASE;
1139
+ } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
1140
+ if (revs->grep_filter)
1141
+ revs->grep_filter->fixed = 1;
1142
+ } else if (!strcmp(arg, "--all-match")) {
1143
+ if (revs->grep_filter)
1144
+ revs->grep_filter->all_match = 1;
1145
+ } else if (!prefixcmp(arg, "--encoding=")) {
1146
+ arg += 11;
1147
+ if (strcmp(arg, "none"))
1148
+ git_log_output_encoding = xstrdup(arg);
1149
+ else
1150
+ git_log_output_encoding = "";
1151
+ } else if (!strcmp(arg, "--reverse")) {
1152
+ revs->reverse ^= 1;
1153
+ } else if (!strcmp(arg, "--children")) {
1154
+ revs->children.name = "children";
1155
+ revs->limited = 1;
1156
+ } else {
1157
+ int opts = diff_opt_parse(&revs->diffopt, argv, argc);
1158
+ if (!opts)
1159
+ unkv[(*unkc)++] = arg;
1160
+ return opts;
1161
+ }
1162
+
1163
+ return 1;
1164
+}
1165
+
1166
/*
1167
* Parse revision information, filling in the "rev_info" structure,
1168
* and removing the used arguments from the argument list.
@@ -966,12 +1172,7 @@ static void add_ignore_packed(struct rev_info *revs, const char *name)
1172
*/
1173
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
1174
{
969
- int i, flags, seen_dashdash, show_merge;
970
- const char **unrecognized = argv + 1;
971
- int left = 1;
972
- int all_match = 0;
973
- int regflags = 0;
974
- int fixed = 0;
1175
+ int i, flags, left, seen_dashdash;
1176
1177
/* First, search for "--" */
1178
seen_dashdash = 0;
@@ -987,58 +1188,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1188
break;
1189
}
1190
990
- flags = show_merge = 0;
991
- for (i = 1; i < argc; i++) {
1191
+ /* Second, deal with arguments and options */
1192
+ flags = 0;
1193
+ for (left = i = 1; i < argc; i++) {
1194
const char *arg = argv[i];
1195
if (*arg == '-') {
1196
int opts;
995
- if (!prefixcmp(arg, "--max-count=")) {
996
- revs->max_count = atoi(arg + 12);
997
- continue;
998
- }
999
- if (!prefixcmp(arg, "--skip=")) {
1000
- revs->skip_count = atoi(arg + 7);
1001
- continue;
1002
- }
1003
- /* accept -<digit>, like traditional "head" */
1004
- if ((*arg == '-') && isdigit(arg[1])) {
1005
- revs->max_count = atoi(arg + 1);
1006
- continue;
1007
- }
1008
- if (!strcmp(arg, "-n")) {
1009
- if (argc <= i + 1)
1010
- die("-n requires an argument");
1011
- revs->max_count = atoi(argv[++i]);
1012
- continue;
1013
- }
1014
- if (!prefixcmp(arg, "-n")) {
1015
- revs->max_count = atoi(arg + 2);
1016
- continue;
1017
- }
1018
- if (!prefixcmp(arg, "--max-age=")) {
1019
- revs->max_age = atoi(arg + 10);
1020
- continue;
1021
- }
1022
- if (!prefixcmp(arg, "--since=")) {
1023
- revs->max_age = approxidate(arg + 8);
1024
- continue;
1025
- }
1026
- if (!prefixcmp(arg, "--after=")) {
1027
- revs->max_age = approxidate(arg + 8);
1028
- continue;
1029
- }
1030
- if (!prefixcmp(arg, "--min-age=")) {
1031
- revs->min_age = atoi(arg + 10);
1032
- continue;
1033
- }
1034
- if (!prefixcmp(arg, "--before=")) {
1035
- revs->min_age = approxidate(arg + 9);
1036
- continue;
1037
- }
1038
- if (!prefixcmp(arg, "--until=")) {
1039
- revs->min_age = approxidate(arg + 8);
1040
- continue;
1041
- }
1197
+
1198
if (!strcmp(arg, "--all")) {
1199
handle_refs(revs, flags, for_each_ref);
1200
continue;
@@ -1055,265 +1211,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1211
handle_refs(revs, flags, for_each_remote_ref);
1212
continue;
1213
}
1058
- if (!strcmp(arg, "--first-parent")) {
1059
- revs->first_parent_only = 1;
1060
- continue;
1061
- }
1214
if (!strcmp(arg, "--reflog")) {
1215
handle_reflog(revs, flags);
1216
continue;
1217
}
1066
- if (!strcmp(arg, "-g") ||
1067
- !strcmp(arg, "--walk-reflogs")) {
1068
- init_reflog_walk(&revs->reflog_info);
1069
- continue;
1070
- }
1218
if (!strcmp(arg, "--not")) {
1219
flags ^= UNINTERESTING;
1220
continue;
1221
}
1075
- if (!strcmp(arg, "--default")) {
1076
- if (++i >= argc)
1077
- die("bad --default argument");
1078
- def = argv[i];
1079
- continue;
1080
- }
1081
- if (!strcmp(arg, "--merge")) {
1082
- show_merge = 1;
1083
- continue;
1084
- }
1085
- if (!strcmp(arg, "--topo-order")) {
1086
- revs->lifo = 1;
1087
- revs->topo_order = 1;
1088
- continue;
1089
- }
1090
- if (!strcmp(arg, "--date-order")) {
1091
- revs->lifo = 0;
1092
- revs->topo_order = 1;
1093
- continue;
1094
- }
1095
- if (!prefixcmp(arg, "--early-output")) {
1096
- int count = 100;
1097
- switch (arg[14]) {
1098
- case '=':
1099
- count = atoi(arg+15);
1100
- /* Fallthrough */
1101
- case 0:
1102
- revs->topo_order = 1;
1103
- revs->early_output = count;
1104
- continue;
1105
- }
1106
- }
1107
- if (!strcmp(arg, "--parents")) {
1108
- revs->rewrite_parents = 1;
1109
- revs->print_parents = 1;
1110
- continue;
1111
- }
1112
- if (!strcmp(arg, "--dense")) {
1113
- revs->dense = 1;
1114
- continue;
1115
- }
1116
- if (!strcmp(arg, "--sparse")) {
1117
- revs->dense = 0;
1118
- continue;
1119
- }
1120
- if (!strcmp(arg, "--show-all")) {
1121
- revs->show_all = 1;
1122
- continue;
1123
- }
1124
- if (!strcmp(arg, "--remove-empty")) {
1125
- revs->remove_empty_trees = 1;
1126
- continue;
1127
- }
1128
- if (!strcmp(arg, "--no-merges")) {
1129
- revs->no_merges = 1;
1130
- continue;
1131
- }
1132
- if (!strcmp(arg, "--boundary")) {
1133
- revs->boundary = 1;
1134
- continue;
1135
- }
1136
- if (!strcmp(arg, "--left-right")) {
1137
- revs->left_right = 1;
1138
- continue;
1139
- }
1140
- if (!strcmp(arg, "--cherry-pick")) {
1141
- revs->cherry_pick = 1;
1142
- revs->limited = 1;
1143
- continue;
1144
- }
1145
- if (!strcmp(arg, "--objects")) {
1146
- revs->tag_objects = 1;
1147
- revs->tree_objects = 1;
1148
- revs->blob_objects = 1;
1149
- continue;
1150
- }
1151
- if (!strcmp(arg, "--objects-edge")) {
1152
- revs->tag_objects = 1;
1153
- revs->tree_objects = 1;
1154
- revs->blob_objects = 1;
1155
- revs->edge_hint = 1;
1156
- continue;
1157
- }
1158
- if (!strcmp(arg, "--unpacked")) {
1159
- revs->unpacked = 1;
1160
- free(revs->ignore_packed);
1161
- revs->ignore_packed = NULL;
1162
- revs->num_ignore_packed = 0;
1163
- continue;
1164
- }
1165
- if (!prefixcmp(arg, "--unpacked=")) {
1166
- revs->unpacked = 1;
1167
- add_ignore_packed(revs, arg+11);
1168
- continue;
1169
- }
1170
- if (!strcmp(arg, "-r")) {
1171
- revs->diff = 1;
1172
- DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1173
- continue;
1174
- }
1175
- if (!strcmp(arg, "-t")) {
1176
- revs->diff = 1;
1177
- DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1178
- DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
1179
- continue;
1180
- }
1181
- if (!strcmp(arg, "-m")) {
1182
- revs->ignore_merges = 0;
1183
- continue;
1184
- }
1185
- if (!strcmp(arg, "-c")) {
1186
- revs->diff = 1;
1187
- revs->dense_combined_merges = 0;
1188
- revs->combine_merges = 1;
1189
- continue;
1190
- }
1191
- if (!strcmp(arg, "--cc")) {
1192
- revs->diff = 1;
1193
- revs->dense_combined_merges = 1;
1194
- revs->combine_merges = 1;
1195
- continue;
1196
- }
1197
- if (!strcmp(arg, "-v")) {
1198
- revs->verbose_header = 1;
1199
- continue;
1200
- }
1201
- if (!strcmp(arg, "--pretty")) {
1202
- revs->verbose_header = 1;
1203
- get_commit_format(arg+8, revs);
1204
- continue;
1205
- }
1206
- if (!prefixcmp(arg, "--pretty=")) {
1207
- revs->verbose_header = 1;
1208
- get_commit_format(arg+9, revs);
1209
- continue;
1210
- }
1211
- if (!strcmp(arg, "--graph")) {
1212
- revs->topo_order = 1;
1213
- revs->rewrite_parents = 1;
1214
- revs->graph = graph_init(revs);
1215
- continue;
1216
- }
1217
- if (!strcmp(arg, "--root")) {
1218
- revs->show_root_diff = 1;
1219
- continue;
1220
- }
1221
- if (!strcmp(arg, "--no-commit-id")) {
1222
- revs->no_commit_id = 1;
1223
- continue;
1224
- }
1225
- if (!strcmp(arg, "--always")) {
1226
- revs->always_show_header = 1;
1227
- continue;
1228
- }
1229
- if (!strcmp(arg, "--no-abbrev")) {
1230
- revs->abbrev = 0;
1231
- continue;
1232
- }
1233
- if (!strcmp(arg, "--abbrev")) {
1234
- revs->abbrev = DEFAULT_ABBREV;
1235
- continue;
1236
- }
1237
- if (!prefixcmp(arg, "--abbrev=")) {
1238
- revs->abbrev = strtoul(arg + 9, NULL, 10);
1239
- if (revs->abbrev < MINIMUM_ABBREV)
1240
- revs->abbrev = MINIMUM_ABBREV;
1241
- else if (revs->abbrev > 40)
1242
- revs->abbrev = 40;
1243
- continue;
1244
- }
1245
- if (!strcmp(arg, "--abbrev-commit")) {
1246
- revs->abbrev_commit = 1;
1247
- continue;
1248
- }
1249
- if (!strcmp(arg, "--full-diff")) {
1250
- revs->diff = 1;
1251
- revs->full_diff = 1;
1252
- continue;
1253
- }
1254
- if (!strcmp(arg, "--full-history")) {
1255
- revs->simplify_history = 0;
1256
- continue;
1257
- }
1258
- if (!strcmp(arg, "--relative-date")) {
1259
- revs->date_mode = DATE_RELATIVE;
1260
- continue;
1261
- }
1262
- if (!strncmp(arg, "--date=", 7)) {
1263
- revs->date_mode = parse_date_format(arg + 7);
1264
- continue;
1265
- }
1266
- if (!strcmp(arg, "--log-size")) {
1267
- revs->show_log_size = 1;
1268
- continue;
1269
- }
1270
-
1271
- /*
1272
- * Grepping the commit log
1273
- */
1274
- if (!prefixcmp(arg, "--author=")) {
1275
- add_header_grep(revs, "author", arg+9);
1276
- continue;
1277
- }
1278
- if (!prefixcmp(arg, "--committer=")) {
1279
- add_header_grep(revs, "committer", arg+12);
1280
- continue;
1281
- }
1282
- if (!prefixcmp(arg, "--grep=")) {
1283
- add_message_grep(revs, arg+7);
1284
- continue;
1285
- }
1286
- if (!strcmp(arg, "--extended-regexp") ||
1287
- !strcmp(arg, "-E")) {
1288
- regflags |= REG_EXTENDED;
1289
- continue;
1290
- }
1291
- if (!strcmp(arg, "--regexp-ignore-case") ||
1292
- !strcmp(arg, "-i")) {
1293
- regflags |= REG_ICASE;
1294
- continue;
1295
- }
1296
- if (!strcmp(arg, "--fixed-strings") ||
1297
- !strcmp(arg, "-F")) {
1298
- fixed = 1;
1299
- continue;
1300
- }
1301
- if (!strcmp(arg, "--all-match")) {
1302
- all_match = 1;
1303
- continue;
1304
- }
1305
- if (!prefixcmp(arg, "--encoding=")) {
1306
- arg += 11;
1307
- if (strcmp(arg, "none"))
1308
- git_log_output_encoding = xstrdup(arg);
1309
- else
1310
- git_log_output_encoding = "";
1311
- continue;
1312
- }
1313
- if (!strcmp(arg, "--reverse")) {
1314
- revs->reverse ^= 1;
1315
- continue;
1316
- }
1222
if (!strcmp(arg, "--no-walk")) {
1223
revs->no_walk = 1;
1224
continue;
@@ -1322,19 +1227,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1227
revs->no_walk = 0;
1228
continue;
1229
}
1325
- if (!strcmp(arg, "--children")) {
1326
- revs->children.name = "children";
1327
- revs->limited = 1;
1328
- continue;
1329
- }
1230
1331
- opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
1231
+ opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
1232
if (opts > 0) {
1233
i += opts - 1;
1234
continue;
1235
}
1336
- *unrecognized++ = arg;
1337
- left++;
1236
+ if (opts < 0)
1237
+ exit(128);
1238
continue;
1239
}
1240
@@ -1358,21 +1258,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1258
}
1259
}
1260
1361
- if (revs->grep_filter) {
1362
- revs->grep_filter->regflags |= regflags;
1363
- revs->grep_filter->fixed = fixed;
1364
- }
1365
-
1366
- if (show_merge)
1261
+ if (revs->def == NULL)
1262
+ revs->def = def;
1263
+ if (revs->show_merge)
1264
prepare_show_merge(revs);
1368
- if (def && !revs->pending.nr) {
1265
+ if (revs->def && !revs->pending.nr) {
1266
unsigned char sha1[20];
1267
struct object *object;
1268
unsigned mode;
1372
- if (get_sha1_with_mode(def, sha1, &mode))
1373
- die("bad default revision '%s'", def);
1374
- object = get_reference(revs, def, sha1, 0);
1375
- add_pending_object_with_mode(revs, object, def, mode);
1269
+ if (get_sha1_with_mode(revs->def, sha1, &mode))
1270
+ die("bad default revision '%s'", revs->def);
1271
+ object = get_reference(revs, revs->def, sha1, 0);
1272
+ add_pending_object_with_mode(revs, object, revs->def, mode);
1273
}
1274
1275
/* Did the user ask for any diff output? Run the diff! */
@@ -1406,7 +1303,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1303
die("diff_setup_done failed");
1304
1305
if (revs->grep_filter) {
1409
- revs->grep_filter->all_match = all_match;
1306
compile_grep_patterns(revs->grep_filter);
1307
}
1308
revision.h
+4
@@ -25,6 +25,7 @@ struct rev_info {
25
26
/* Basic information */
27
const char *prefix;
28
+ const char *def;
29
void *prune_data;
30
unsigned int early_output;
31
@@ -65,6 +66,7 @@ struct rev_info {
66
67
/* Format info */
68
unsigned int shown_one:1,
69
+ show_merge:1,
70
abbrev_commit:1,
71
use_terminator:1,
72
missing_newline:1;
@@ -117,6 +119,8 @@ volatile show_early_output_fn_t show_early_output;
119
120
extern void init_revisions(struct rev_info *revs, const char *prefix);
121
extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
122
+extern int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
123
+ int *unkc, const char **unkv);
124
extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
125
126
extern int prepare_revision_walk(struct rev_info *revs);