Skip to content

Commit ef68241

Browse files
committed
revwalk: remove one useless layer of functions
We don't currently need to have anything that's different between `get_revision` and `get_one_revision` so let's just remove the inner function and make the code more straightforward.
1 parent 2a6d095 commit ef68241

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

src/revwalk.c

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -453,43 +453,28 @@ static int limit_list(git_commit_list **out, git_revwalk *walk, git_commit_list
453453
return 0;
454454
}
455455

456-
static int get_one_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list)
457-
{
458-
int error;
459-
git_commit_list_node *commit;
460-
461-
while(true) {
462-
commit = git_commit_list_pop(list);
463-
if (!commit) {
464-
giterr_clear();
465-
return GIT_ITEROVER;
466-
}
467-
468-
/*
469-
* If we did not run limit_list and we must add parents to the
470-
* list ourselves.
471-
*/
472-
if (!walk->limited) {
473-
if ((error = add_parents_to_list(walk, commit, list)) < 0)
474-
return error;
475-
}
476-
477-
*out = commit;
478-
return 0;
479-
}
480-
}
481-
482456
static int get_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list)
483457
{
484458
int error;
485459
git_commit_list_node *commit;
486460

487-
if ((error = get_one_revision(&commit, walk, list)) < 0)
488-
return error;
489-
490-
/* Here is where we would handle boundary commits if we implement that */
491-
*out = commit;
492-
return 0;
461+
commit = git_commit_list_pop(list);
462+
if (!commit) {
463+
giterr_clear();
464+
return GIT_ITEROVER;
465+
}
466+
467+
/*
468+
* If we did not run limit_list and we must add parents to the
469+
* list ourselves.
470+
*/
471+
if (!walk->limited) {
472+
if ((error = add_parents_to_list(walk, commit, list)) < 0)
473+
return error;
474+
}
475+
476+
*out = commit;
477+
return 0;
493478
}
494479

495480
static int sort_in_topological_order(git_commit_list **out, git_revwalk *walk, git_commit_list *list)

0 commit comments

Comments
 (0)