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>
This commit is contained in:
parent
d9cfb964c7
commit
d9a83684c4
25
rev-list.c
25
rev-list.c
@ -41,7 +41,6 @@ static const char rev_list_usage[] =
|
|||||||
|
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
|
|
||||||
static int unpacked = 0;
|
|
||||||
static int bisect_list = 0;
|
static int bisect_list = 0;
|
||||||
static int verbose_header = 0;
|
static int verbose_header = 0;
|
||||||
static int abbrev = DEFAULT_ABBREV;
|
static int abbrev = DEFAULT_ABBREV;
|
||||||
@ -572,7 +571,7 @@ static struct commit_list *limit_list(struct commit_list *list)
|
|||||||
|
|
||||||
if (revs.max_age != -1 && (commit->date < revs.max_age))
|
if (revs.max_age != -1 && (commit->date < revs.max_age))
|
||||||
obj->flags |= UNINTERESTING;
|
obj->flags |= UNINTERESTING;
|
||||||
if (unpacked && has_sha1_pack(obj->sha1))
|
if (revs.unpacked && has_sha1_pack(obj->sha1))
|
||||||
obj->flags |= UNINTERESTING;
|
obj->flags |= UNINTERESTING;
|
||||||
add_parents_to_list(commit, &list);
|
add_parents_to_list(commit, &list);
|
||||||
if (obj->flags & UNINTERESTING) {
|
if (obj->flags & UNINTERESTING) {
|
||||||
@ -595,7 +594,7 @@ static struct commit_list *limit_list(struct commit_list *list)
|
|||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct commit_list *list;
|
struct commit_list *list;
|
||||||
int i, limited = 0;
|
int i;
|
||||||
|
|
||||||
argc = setup_revisions(argc, argv, &revs);
|
argc = setup_revisions(argc, argv, &revs);
|
||||||
|
|
||||||
@ -655,11 +654,6 @@ int main(int argc, const char **argv)
|
|||||||
bisect_list = 1;
|
bisect_list = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--unpacked")) {
|
|
||||||
unpacked = 1;
|
|
||||||
limited = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(arg, "--merge-order")) {
|
if (!strcmp(arg, "--merge-order")) {
|
||||||
merge_order = 1;
|
merge_order = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -673,34 +667,25 @@ int main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list = revs.commits;
|
list = revs.commits;
|
||||||
if (list)
|
|
||||||
limited = 1;
|
|
||||||
|
|
||||||
if (revs.topo_order)
|
|
||||||
limited = 1;
|
|
||||||
|
|
||||||
if (!list &&
|
if (!list &&
|
||||||
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && !revs.pending_objects))
|
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && !revs.pending_objects))
|
||||||
usage(rev_list_usage);
|
usage(rev_list_usage);
|
||||||
|
|
||||||
if (revs.paths) {
|
if (revs.paths)
|
||||||
limited = 1;
|
|
||||||
diff_tree_setup_paths(revs.paths);
|
diff_tree_setup_paths(revs.paths);
|
||||||
}
|
|
||||||
if (revs.max_age != -1 || revs.min_age != -1)
|
|
||||||
limited = 1;
|
|
||||||
|
|
||||||
save_commit_buffer = verbose_header;
|
save_commit_buffer = verbose_header;
|
||||||
track_object_refs = 0;
|
track_object_refs = 0;
|
||||||
|
|
||||||
if (!merge_order) {
|
if (!merge_order) {
|
||||||
sort_by_date(&list);
|
sort_by_date(&list);
|
||||||
if (list && !limited && revs.max_count == 1 &&
|
if (list && !revs.limited && revs.max_count == 1 &&
|
||||||
!revs.tag_objects && !revs.tree_objects && !revs.blob_objects) {
|
!revs.tag_objects && !revs.tree_objects && !revs.blob_objects) {
|
||||||
show_commit(list->item);
|
show_commit(list->item);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (limited)
|
if (revs.limited)
|
||||||
list = limit_list(list);
|
list = limit_list(list);
|
||||||
if (revs.topo_order)
|
if (revs.topo_order)
|
||||||
sort_in_topological_order(&list, revs.lifo);
|
sort_in_topological_order(&list, revs.lifo);
|
||||||
|
15
revision.c
15
revision.c
@ -143,8 +143,10 @@ static struct commit *get_commit_reference(struct rev_info *revs, const char *na
|
|||||||
object->flags |= flags;
|
object->flags |= flags;
|
||||||
if (parse_commit(commit) < 0)
|
if (parse_commit(commit) < 0)
|
||||||
die("unable to parse commit %s", name);
|
die("unable to parse commit %s", name);
|
||||||
if (flags & UNINTERESTING)
|
if (flags & UNINTERESTING) {
|
||||||
mark_parents_uninteresting(commit);
|
mark_parents_uninteresting(commit);
|
||||||
|
revs->limited = 1;
|
||||||
|
}
|
||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,10 +257,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
|
|||||||
}
|
}
|
||||||
if (!strncmp(arg, "--max-age=", 10)) {
|
if (!strncmp(arg, "--max-age=", 10)) {
|
||||||
revs->max_age = atoi(arg + 10);
|
revs->max_age = atoi(arg + 10);
|
||||||
|
revs->limited = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strncmp(arg, "--min-age=", 10)) {
|
if (!strncmp(arg, "--min-age=", 10)) {
|
||||||
revs->min_age = atoi(arg + 10);
|
revs->min_age = atoi(arg + 10);
|
||||||
|
revs->limited = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--all")) {
|
if (!strcmp(arg, "--all")) {
|
||||||
@ -277,11 +281,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
|
|||||||
}
|
}
|
||||||
if (!strcmp(arg, "--topo-order")) {
|
if (!strcmp(arg, "--topo-order")) {
|
||||||
revs->topo_order = 1;
|
revs->topo_order = 1;
|
||||||
|
revs->limited = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--date-order")) {
|
if (!strcmp(arg, "--date-order")) {
|
||||||
revs->lifo = 0;
|
revs->lifo = 0;
|
||||||
revs->topo_order = 1;
|
revs->topo_order = 1;
|
||||||
|
revs->limited = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--dense")) {
|
if (!strcmp(arg, "--dense")) {
|
||||||
@ -309,6 +315,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
|
|||||||
revs->edge_hint = 1;
|
revs->edge_hint = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--unpacked")) {
|
||||||
|
revs->unpacked = 1;
|
||||||
|
revs->limited = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*unrecognized++ = arg;
|
*unrecognized++ = arg;
|
||||||
left++;
|
left++;
|
||||||
continue;
|
continue;
|
||||||
@ -365,6 +376,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs)
|
|||||||
commit = get_commit_reference(revs, def, sha1, 0);
|
commit = get_commit_reference(revs, def, sha1, 0);
|
||||||
add_one_commit(commit, revs);
|
add_one_commit(commit, revs);
|
||||||
}
|
}
|
||||||
|
if (revs->paths)
|
||||||
|
revs->limited = 1;
|
||||||
*unrecognized = NULL;
|
*unrecognized = NULL;
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,9 @@ struct rev_info {
|
|||||||
tag_objects:1,
|
tag_objects:1,
|
||||||
tree_objects:1,
|
tree_objects:1,
|
||||||
blob_objects:1,
|
blob_objects:1,
|
||||||
edge_hint:1;
|
edge_hint:1,
|
||||||
|
limited:1,
|
||||||
|
unpacked:1;
|
||||||
|
|
||||||
/* special limits */
|
/* special limits */
|
||||||
int max_count;
|
int max_count;
|
||||||
|
Loading…
Reference in New Issue
Block a user