summaryrefslogtreecommitdiff
path: root/src/revparse.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-07 07:22:38 +0200
committerVicent Marti <tanoku@gmail.com>2013-04-07 07:22:38 +0200
commitd9ecaf8c6f2d2d538319174e42e5c98585c902e5 (patch)
treeae3d0bee5061af1bf35fbda34f2afc2757365ee2 /src/revparse.c
parent2274483727b62ae155d7206668713d5346756de6 (diff)
parent2e2332857d26c7dbed3e4b940bb571da348bb5c7 (diff)
downloadlibgit2-d9ecaf8c6f2d2d538319174e42e5c98585c902e5.tar.gz
Merge remote-tracking branch 'gnprice/revwalk' into development
Diffstat (limited to 'src/revparse.c')
-rw-r--r--src/revparse.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/revparse.c b/src/revparse.c
index 1518a7c3c..2ba29383e 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -867,3 +867,28 @@ cleanup:
git_buf_free(&buf);
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;
+}