Splitting rev-list into revisions lib, end of beginning.
This makes the rewrite easier to validate in that revision flag parsing and warlking part are now all in rev_info structure. Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Feb 27, 2006 at 08:54 UTC
d9a83684c473e04c61f0060c4926d20f8183f7b6
3 files changed
+22
-22
rev-list.c
+5
-20
@@ -41,7 +41,6 @@ static const char rev_list_usage[] =
41
42
struct rev_info revs;
43
44
-static int unpacked = 0;
44
static int bisect_list = 0;
45
static int verbose_header = 0;
46
static int abbrev = DEFAULT_ABBREV;
@@ -572,7 +571,7 @@ static struct commit_list *limit_list(struct commit_list *list)
571
572
if (revs.max_age != -1 && (commit->date < revs.max_age))
573
obj->flags |= UNINTERESTING;
575
- if (unpacked && has_sha1_pack(obj->sha1))
574
+ if (revs.unpacked && has_sha1_pack(obj->sha1))
575
obj->flags |= UNINTERESTING;
576
add_parents_to_list(commit, &list);
577
if (obj->flags & UNINTERESTING) {
@@ -595,7 +594,7 @@ static struct commit_list *limit_list(struct commit_list *list)
594
int main(int argc, const char **argv)
595
{
596
struct commit_list *list;
598
- int i, limited = 0;
597
+ int i;
598
599
argc = setup_revisions(argc, argv, &revs);
600
@@ -655,11 +654,6 @@ int main(int argc, const char **argv)
654
bisect_list = 1;
655
continue;
656
}
658
- if (!strcmp(arg, "--unpacked")) {
659
- unpacked = 1;
660
- limited = 1;
661
- continue;
662
- }
657
if (!strcmp(arg, "--merge-order")) {
658
merge_order = 1;
659
continue;
@@ -673,34 +667,25 @@ int main(int argc, const char **argv)
667
}
668
669
list = revs.commits;
676
- if (list)
677
- limited = 1;
678
-
679
- if (revs.topo_order)
680
- limited = 1;
670
671
if (!list &&
672
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && !revs.pending_objects))
673
usage(rev_list_usage);
674
686
- if (revs.paths) {
687
- limited = 1;
675
+ if (revs.paths)
676
diff_tree_setup_paths(revs.paths);
689
- }
690
- if (revs.max_age != -1 || revs.min_age != -1)
691
- limited = 1;
677
678
save_commit_buffer = verbose_header;
679
track_object_refs = 0;
680
681
if (!merge_order) {
682
sort_by_date(&list);
698
- if (list && !limited && revs.max_count == 1 &&
683
+ if (list && !revs.limited && revs.max_count == 1 &&
684
!revs.tag_objects && !revs.tree_objects && !revs.blob_objects) {
685
show_commit(list->item);
686
return 0;
687
}
703
- if (limited)
688
+ if (revs.limited)
689
list = limit_list(list);
690
if (revs.topo_order)
691
sort_in_topological_order(&list, revs.lifo);
revision.c
+14
-1
@@ -143,8 +143,10 @@ static struct commit *get_commit_reference(struct rev_info *revs, const char *na
143
object->flags |= flags;
144
if (parse_commit(commit) < 0)
145
die("unable to parse commit %s", name);
146
- if (flags & UNINTERESTING)
146
+ if (flags & UNINTERESTING) {
147
mark_parents_uninteresting(commit);
148
+ revs->limited = 1;
149
+ }
150
return commit;
151
}
152
@@ -255,10 +257,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
257
}
258
if (!strncmp(arg, "--max-age=", 10)) {
259
revs->max_age = atoi(arg + 10);
260
+ revs->limited = 1;
261
continue;
262
}
263
if (!strncmp(arg, "--min-age=", 10)) {
264
revs->min_age = atoi(arg + 10);
265
+ revs->limited = 1;
266
continue;
267
}
268
if (!strcmp(arg, "--all")) {
@@ -277,11 +281,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
281
}
282
if (!strcmp(arg, "--topo-order")) {
283
revs->topo_order = 1;
284
+ revs->limited = 1;
285
continue;
286
}
287
if (!strcmp(arg, "--date-order")) {
288
revs->lifo = 0;
289
revs->topo_order = 1;
290
+ revs->limited = 1;
291
continue;
292
}
293
if (!strcmp(arg, "--dense")) {
@@ -309,6 +315,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
315
revs->edge_hint = 1;
316
continue;
317
}
318
+ if (!strcmp(arg, "--unpacked")) {
319
+ revs->unpacked = 1;
320
+ revs->limited = 1;
321
+ continue;
322
+ }
323
*unrecognized++ = arg;
324
left++;
325
continue;
@@ -365,6 +376,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
376
commit = get_commit_reference(revs, def, sha1, 0);
377
add_one_commit(commit, revs);
378
}
379
+ if (revs->paths)
380
+ revs->limited = 1;
381
*unrecognized = NULL;
382
return left;
383
}
revision.h
+3
-1
@@ -21,7 +21,9 @@ struct rev_info {
21
tag_objects:1,
22
tree_objects:1,
23
blob_objects:1,
24
- edge_hint:1;
24
+ edge_hint:1,
25
+ limited:1,
26
+ unpacked:1;
27
28
/* special limits */
29
int max_count;