Commit 2bab8f23c6cf7e448895c3469a140f7f11bfb3e2

Tracey Emery 2020-01-15T22:10:31

mv func to lib

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index e9bf111..dc7a1df 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -181,10 +181,6 @@ static const struct got_error*	 gw_apply_unveil(const char *, const char *);
 static const struct got_error*	 cmp_tags(void *, int *,
 				    struct got_reference *,
 				    struct got_reference *);
-
-/* got_repo_resolve_commit_arg */
-static const struct got_error*	 resolve_commit_arg(struct got_object_id **,
-				    const char *, struct got_repository *);
 static const struct got_error*	 match_object_id(struct got_object_id **,
 				    char **, const char *r, int, int,
 				    struct got_repository *);
@@ -319,39 +315,6 @@ done:
 }
 
 static const struct got_error *
-resolve_commit_arg(struct got_object_id **commit_id,
-    const char *commit_id_arg, struct got_repository *repo)
-{
-	const struct got_error *err;
-	struct got_reference *ref;
-	struct got_tag_object *tag;
-
-	err = got_repo_object_match_tag(&tag, commit_id_arg,
-	    GOT_OBJ_TYPE_COMMIT, repo);
-	if (err == NULL) {
-		*commit_id = got_object_id_dup(
-		    got_object_tag_get_object_id(tag));
-		if (*commit_id == NULL)
-			err = got_error_from_errno("got_object_id_dup");
-		got_object_tag_close(tag);
-		return err;
-	} else if (err->code != GOT_ERR_NO_OBJ)
-		return err;
-
-	err = got_ref_open(&ref, repo, commit_id_arg, 0);
-	if (err == NULL) {
-		err = got_ref_resolve(commit_id, repo, ref);
-		got_ref_close(ref);
-	} else {
-		if (err->code != GOT_ERR_NOT_REF)
-			return err;
-		err = got_repo_match_object_id_prefix(commit_id,
-		    commit_id_arg, GOT_OBJ_TYPE_COMMIT, repo);
-	}
-	return err;
-}
-
-static const struct got_error *
 match_object_id(struct got_object_id **id, char **label,
     const char *id_str, int obj_type, int resolve_tags,
     struct got_repository *repo)
@@ -2428,7 +2391,7 @@ gw_get_file_blame(struct gw_trans *gw_trans, char *commit_str)
 	if (error)
 		goto done;
 
-	error = resolve_commit_arg(&commit_id, commit_str, repo);
+	error = got_repo_resolve_commit_arg(&commit_id, commit_str, repo);
 	if (error)
 		goto done;
 
@@ -2565,7 +2528,8 @@ gw_get_repo_tree(struct gw_trans *gw_trans, char *commit_str)
 		got_ref_close(head_ref);
 
 	} else
-		error = resolve_commit_arg(&commit_id, commit_str, repo);
+		error = got_repo_resolve_commit_arg(&commit_id, commit_str,
+		    repo);
 	if (error)
 		goto done;