Skip to content

Commit d9a8368

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
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 <[email protected]>
1 parent d9cfb96 commit d9a8368

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

rev-list.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static const char rev_list_usage[] =
4141

4242
struct rev_info revs;
4343

44-
static int unpacked = 0;
4544
static int bisect_list = 0;
4645
static int verbose_header = 0;
4746
static int abbrev = DEFAULT_ABBREV;
@@ -572,7 +571,7 @@ static struct commit_list *limit_list(struct commit_list *list)
572571

573572
if (revs.max_age != -1 && (commit->date < revs.max_age))
574573
obj->flags |= UNINTERESTING;
575-
if (unpacked && has_sha1_pack(obj->sha1))
574+
if (revs.unpacked && has_sha1_pack(obj->sha1))
576575
obj->flags |= UNINTERESTING;
577576
add_parents_to_list(commit, &list);
578577
if (obj->flags & UNINTERESTING) {
@@ -595,7 +594,7 @@ static struct commit_list *limit_list(struct commit_list *list)
595594
int main(int argc, const char **argv)
596595
{
597596
struct commit_list *list;
598-
int i, limited = 0;
597+
int i;
599598

600599
argc = setup_revisions(argc, argv, &revs);
601600

@@ -655,11 +654,6 @@ int main(int argc, const char **argv)
655654
bisect_list = 1;
656655
continue;
657656
}
658-
if (!strcmp(arg, "--unpacked")) {
659-
unpacked = 1;
660-
limited = 1;
661-
continue;
662-
}
663657
if (!strcmp(arg, "--merge-order")) {
664658
merge_order = 1;
665659
continue;
@@ -673,34 +667,25 @@ int main(int argc, const char **argv)
673667
}
674668

675669
list = revs.commits;
676-
if (list)
677-
limited = 1;
678-
679-
if (revs.topo_order)
680-
limited = 1;
681670

682671
if (!list &&
683672
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && !revs.pending_objects))
684673
usage(rev_list_usage);
685674

686-
if (revs.paths) {
687-
limited = 1;
675+
if (revs.paths)
688676
diff_tree_setup_paths(revs.paths);
689-
}
690-
if (revs.max_age != -1 || revs.min_age != -1)
691-
limited = 1;
692677

693678
save_commit_buffer = verbose_header;
694679
track_object_refs = 0;
695680

696681
if (!merge_order) {
697682
sort_by_date(&list);
698-
if (list && !limited && revs.max_count == 1 &&
683+
if (list && !revs.limited && revs.max_count == 1 &&
699684
!revs.tag_objects && !revs.tree_objects && !revs.blob_objects) {
700685
show_commit(list->item);
701686
return 0;
702687
}
703-
if (limited)
688+
if (revs.limited)
704689
list = limit_list(list);
705690
if (revs.topo_order)
706691
sort_in_topological_order(&list, revs.lifo);

revision.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ static struct commit *get_commit_reference(struct rev_info *revs, const char *na
143143
object->flags |= flags;
144144
if (parse_commit(commit) < 0)
145145
die("unable to parse commit %s", name);
146-
if (flags & UNINTERESTING)
146+
if (flags & UNINTERESTING) {
147147
mark_parents_uninteresting(commit);
148+
revs->limited = 1;
149+
}
148150
return commit;
149151
}
150152

@@ -255,10 +257,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
255257
}
256258
if (!strncmp(arg, "--max-age=", 10)) {
257259
revs->max_age = atoi(arg + 10);
260+
revs->limited = 1;
258261
continue;
259262
}
260263
if (!strncmp(arg, "--min-age=", 10)) {
261264
revs->min_age = atoi(arg + 10);
265+
revs->limited = 1;
262266
continue;
263267
}
264268
if (!strcmp(arg, "--all")) {
@@ -277,11 +281,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
277281
}
278282
if (!strcmp(arg, "--topo-order")) {
279283
revs->topo_order = 1;
284+
revs->limited = 1;
280285
continue;
281286
}
282287
if (!strcmp(arg, "--date-order")) {
283288
revs->lifo = 0;
284289
revs->topo_order = 1;
290+
revs->limited = 1;
285291
continue;
286292
}
287293
if (!strcmp(arg, "--dense")) {
@@ -309,6 +315,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
309315
revs->edge_hint = 1;
310316
continue;
311317
}
318+
if (!strcmp(arg, "--unpacked")) {
319+
revs->unpacked = 1;
320+
revs->limited = 1;
321+
continue;
322+
}
312323
*unrecognized++ = arg;
313324
left++;
314325
continue;
@@ -365,6 +376,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
365376
commit = get_commit_reference(revs, def, sha1, 0);
366377
add_one_commit(commit, revs);
367378
}
379+
if (revs->paths)
380+
revs->limited = 1;
368381
*unrecognized = NULL;
369382
return left;
370383
}

revision.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ struct rev_info {
2121
tag_objects:1,
2222
tree_objects:1,
2323
blob_objects:1,
24-
edge_hint:1;
24+
edge_hint:1,
25+
limited:1,
26+
unpacked:1;
2527

2628
/* special limits */
2729
int max_count;

0 commit comments

Comments
 (0)