summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlosmn@github.com>2018-04-11 17:52:51 -0700
committerCarlos Martín Nieto <carlosmn@github.com>2018-04-11 17:52:51 -0700
commitef6824107e983f0c4f0fc08b71d85e174864a9ce (patch)
treeb9549cf05771a9d27f61ccfe0fdc583a0aa2dc32
parent2a6d0956f0fb6e4c0b9ff2455b4449701bd8e6a2 (diff)
downloadlibgit2-ef6824107e983f0c4f0fc08b71d85e174864a9ce.tar.gz
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.
-rw-r--r--src/revwalk.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index d913987b7..22b043bcd 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -453,43 +453,28 @@ static int limit_list(git_commit_list **out, git_revwalk *walk, git_commit_list
return 0;
}
-static int get_one_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list)
-{
- int error;
- git_commit_list_node *commit;
-
- while(true) {
- commit = git_commit_list_pop(list);
- if (!commit) {
- giterr_clear();
- return GIT_ITEROVER;
- }
-
- /*
- * If we did not run limit_list and we must add parents to the
- * list ourselves.
- */
- if (!walk->limited) {
- if ((error = add_parents_to_list(walk, commit, list)) < 0)
- return error;
- }
-
- *out = commit;
- return 0;
- }
-}
-
static int get_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list)
{
int error;
git_commit_list_node *commit;
- if ((error = get_one_revision(&commit, walk, list)) < 0)
- return error;
-
- /* Here is where we would handle boundary commits if we implement that */
- *out = commit;
- return 0;
+ commit = git_commit_list_pop(list);
+ if (!commit) {
+ giterr_clear();
+ return GIT_ITEROVER;
+ }
+
+ /*
+ * If we did not run limit_list and we must add parents to the
+ * list ourselves.
+ */
+ if (!walk->limited) {
+ if ((error = add_parents_to_list(walk, commit, list)) < 0)
+ return error;
+ }
+
+ *out = commit;
+ return 0;
}
static int sort_in_topological_order(git_commit_list **out, git_revwalk *walk, git_commit_list *list)