Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-04-09 05:03:51 +0400
committerBen Straub <bs@github.com>2013-04-09 05:07:04 +0400
commit1aa21fe3b87a1e601023f49c41fab3ce76c189ac (patch)
treeb25c258e7d360cb9dd7d278094ff12b490a0e61e /src
parent8480eef7ee0c8e52a8bf3ea12e5626009a966164 (diff)
Deprecate git_revparse_single and _rangelike
Diffstat (limited to 'src')
-rw-r--r--src/push.c23
-rw-r--r--src/revparse.c27
-rw-r--r--src/revwalk.c14
-rw-r--r--src/transports/local.c7
4 files changed, 20 insertions, 51 deletions
diff --git a/src/push.c b/src/push.c
index 37f641812..dcd8122d1 100644
--- a/src/push.c
+++ b/src/push.c
@@ -96,21 +96,18 @@ static int check_rref(char *ref)
static int check_lref(git_push *push, char *ref)
{
/* lref must be resolvable to an existing object */
- git_object *obj;
- int error = git_revparse_single(&obj, push->repo, ref);
-
- if (error) {
- if (error == GIT_ENOTFOUND)
- giterr_set(GITERR_REFERENCE,
- "src refspec '%s' does not match any existing object", ref);
- else
- giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref);
+ git_oid oid;
+ int error = git_revparse(&oid, NULL, NULL, push->repo, ref);
- return -1;
- } else
- git_object_free(obj);
+ if (!error)
+ return 0;
- return 0;
+ if (error == GIT_ENOTFOUND)
+ giterr_set(GITERR_REFERENCE,
+ "src refspec '%s' does not match any existing object", ref);
+ else
+ giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref);
+ return -1;
}
static int parse_refspec(git_push *push, push_spec **spec, const char *str)
diff --git a/src/revparse.c b/src/revparse.c
index 2ba42d8e3..7842c49b7 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -722,7 +722,7 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_
return GIT_EINVALIDSPEC;
}
-int git_revparse_single(git_object **out, git_repository *repo, const char *spec)
+static int git_revparse_single(git_object **out, git_repository *repo, const char *spec)
{
size_t pos = 0, identifier_len = 0;
int error = -1, n;
@@ -868,31 +868,6 @@ cleanup:
return error;
}
-int git_revparse_rangelike(git_object **left, git_object **right, int *threedots, git_repository *repo, const char *rangelike)
-{
- int error = 0;
- const char *p, *q;
- char *revspec;
-
- p = strstr(rangelike, "..");
- if (!p) {
- giterr_set(GITERR_INVALID, "Malformed range (or rangelike syntax): %s", rangelike);
- return GIT_EINVALIDSPEC;
- } else if (p[2] == '.') {
- *threedots = 1;
- q = p + 3;
- } else {
- *threedots = 0;
- q = p + 2;
- }
-
- revspec = git__substrdup(rangelike, p - rangelike);
- error = (git_revparse_single(left, repo, revspec)
- || git_revparse_single(right, repo, q));
- git__free(revspec);
- return error;
-}
-
int git_revparse(
git_oid *left,
diff --git a/src/revwalk.c b/src/revwalk.c
index c1071843b..b22fef07f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -231,25 +231,23 @@ int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
int git_revwalk_push_range(git_revwalk *walk, const char *range)
{
- git_object *left, *right;
- int threedots;
+ git_oid left, right;
+ git_revparse_flag_t revparseflags;
int error = 0;
- if ((error = git_revparse_rangelike(&left, &right, &threedots, walk->repo, range)))
+ if ((error = git_revparse(&left, &right, &revparseflags, walk->repo, range)))
return error;
- if (threedots) {
+ if (revparseflags & GIT_REVPARSE_MERGE_BASE) {
/* TODO: support "<commit>...<commit>" */
giterr_set(GITERR_INVALID, "Symmetric differences not implemented in revwalk");
return GIT_EINVALIDSPEC;
}
- if ((error = push_commit(walk, git_object_id(left), 1)))
+ if ((error = push_commit(walk, &left, 1)))
goto out;
- error = push_commit(walk, git_object_id(right), 0);
+ error = push_commit(walk, &right, 0);
out:
- git_object_free(left);
- git_object_free(right);
return error;
}
diff --git a/src/transports/local.c b/src/transports/local.c
index ce89bb213..1e27fc38c 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -236,14 +236,13 @@ static int local_negotiate_fetch(
/* Fill in the loids */
git_vector_foreach(&t->refs, i, rhead) {
- git_object *obj;
+ git_oid oid;
- int error = git_revparse_single(&obj, repo, rhead->name);
+ int error = git_revparse(&oid, NULL, NULL, repo, rhead->name);
if (!error)
- git_oid_cpy(&rhead->loid, git_object_id(obj));
+ git_oid_cpy(&rhead->loid, &oid);
else if (error != GIT_ENOTFOUND)
return error;
- git_object_free(obj);
giterr_clear();
}