mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-17 19:04:43 +00:00
git_revision -> git_revspec
This commit is contained in:
parent
36c2dfed69
commit
cbda09d00b
@ -53,7 +53,7 @@ typedef struct {
|
||||
git_object *from;
|
||||
git_object *to;
|
||||
unsigned int flags;
|
||||
} git_revision;
|
||||
} git_revspec;
|
||||
|
||||
/**
|
||||
* Parse a revision string for left, right, and intent. See `man gitrevisions` or
|
||||
@ -72,7 +72,7 @@ typedef struct {
|
||||
* @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_revparse(
|
||||
git_revision *revision,
|
||||
git_revspec *revspec,
|
||||
git_repository *repo,
|
||||
const char *spec);
|
||||
|
||||
|
@ -870,41 +870,41 @@ cleanup:
|
||||
|
||||
|
||||
int git_revparse(
|
||||
git_revision *revision,
|
||||
git_revspec *revspec,
|
||||
git_repository *repo,
|
||||
const char *spec)
|
||||
{
|
||||
const char *dotdot;
|
||||
int error = 0;
|
||||
|
||||
assert(revision && repo && spec);
|
||||
assert(revspec && repo && spec);
|
||||
|
||||
memset(revision, 0x0, sizeof(*revision));
|
||||
memset(revspec, 0x0, sizeof(*revspec));
|
||||
|
||||
if ((dotdot = strstr(spec, "..")) != NULL) {
|
||||
char *lstr;
|
||||
const char *rstr;
|
||||
revision->flags = GIT_REVPARSE_RANGE;
|
||||
revspec->flags = GIT_REVPARSE_RANGE;
|
||||
|
||||
lstr = git__substrdup(spec, dotdot - spec);
|
||||
rstr = dotdot + 2;
|
||||
if (dotdot[2] == '.') {
|
||||
revision->flags |= GIT_REVPARSE_MERGE_BASE;
|
||||
revspec->flags |= GIT_REVPARSE_MERGE_BASE;
|
||||
rstr++;
|
||||
}
|
||||
|
||||
if ((error = git_revparse_single(&revision->from, repo, lstr)) < 0) {
|
||||
if ((error = git_revparse_single(&revspec->from, repo, lstr)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if ((error = git_revparse_single(&revision->to, repo, rstr)) < 0) {
|
||||
if ((error = git_revparse_single(&revspec->to, repo, rstr)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
git__free((void*)lstr);
|
||||
} else {
|
||||
revision->flags = GIT_REVPARSE_SINGLE;
|
||||
error = git_revparse_single(&revision->from, repo, spec);
|
||||
revspec->flags = GIT_REVPARSE_SINGLE;
|
||||
error = git_revparse_single(&revspec->from, repo, spec);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
@ -231,26 +231,26 @@ int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
|
||||
|
||||
int git_revwalk_push_range(git_revwalk *walk, const char *range)
|
||||
{
|
||||
git_revision revision;
|
||||
git_revspec revspec;
|
||||
int error = 0;
|
||||
|
||||
if ((error = git_revparse(&revision, walk->repo, range)))
|
||||
if ((error = git_revparse(&revspec, walk->repo, range)))
|
||||
return error;
|
||||
|
||||
if (revision.flags & GIT_REVPARSE_MERGE_BASE) {
|
||||
if (revspec.flags & 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(revision.from), 1)))
|
||||
if ((error = push_commit(walk, git_object_id(revspec.from), 1)))
|
||||
goto out;
|
||||
|
||||
error = push_commit(walk, git_object_id(revision.to), 0);
|
||||
error = push_commit(walk, git_object_id(revspec.to), 0);
|
||||
|
||||
out:
|
||||
git_object_free(revision.from);
|
||||
git_object_free(revision.to);
|
||||
git_object_free(revspec.from);
|
||||
git_object_free(revspec.to);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -34,28 +34,28 @@ static void test_id_inrepo(
|
||||
git_revparse_mode_t expected_flags,
|
||||
git_repository *repo)
|
||||
{
|
||||
git_revision revision;
|
||||
int error = git_revparse(&revision, repo, spec);
|
||||
git_revspec revspec;
|
||||
int error = git_revparse(&revspec, repo, spec);
|
||||
|
||||
if (expected_left) {
|
||||
char str[64] = {0};
|
||||
cl_assert_equal_i(0, error);
|
||||
git_oid_fmt(str, git_object_id(revision.from));
|
||||
git_oid_fmt(str, git_object_id(revspec.from));
|
||||
cl_assert_equal_s(str, expected_left);
|
||||
git_object_free(revision.from);
|
||||
git_object_free(revspec.from);
|
||||
} else {
|
||||
cl_assert_equal_i(GIT_ENOTFOUND, error);
|
||||
}
|
||||
|
||||
if (expected_right) {
|
||||
char str[64] = {0};
|
||||
git_oid_fmt(str, git_object_id(revision.to));
|
||||
git_oid_fmt(str, git_object_id(revspec.to));
|
||||
cl_assert_equal_s(str, expected_right);
|
||||
git_object_free(revision.to);
|
||||
git_object_free(revspec.to);
|
||||
}
|
||||
|
||||
if (expected_flags)
|
||||
cl_assert_equal_i(expected_flags, revision.flags);
|
||||
cl_assert_equal_i(expected_flags, revspec.flags);
|
||||
}
|
||||
|
||||
static void test_object(const char *spec, const char *expected_oid)
|
||||
@ -69,23 +69,23 @@ static void test_rangelike(const char *rangelike,
|
||||
git_revparse_mode_t expected_revparseflags)
|
||||
{
|
||||
char objstr[64] = {0};
|
||||
git_revision revision;
|
||||
git_revspec revspec;
|
||||
int error;
|
||||
|
||||
error = git_revparse(&revision, g_repo, rangelike);
|
||||
error = git_revparse(&revspec, g_repo, rangelike);
|
||||
|
||||
if (expected_left != NULL) {
|
||||
cl_assert_equal_i(0, error);
|
||||
cl_assert_equal_i(revision.flags, expected_revparseflags);
|
||||
git_oid_fmt(objstr, git_object_id(revision.from));
|
||||
cl_assert_equal_i(revspec.flags, expected_revparseflags);
|
||||
git_oid_fmt(objstr, git_object_id(revspec.from));
|
||||
cl_assert_equal_s(objstr, expected_left);
|
||||
git_oid_fmt(objstr, git_object_id(revision.to));
|
||||
git_oid_fmt(objstr, git_object_id(revspec.to));
|
||||
cl_assert_equal_s(objstr, expected_right);
|
||||
} else
|
||||
cl_assert(error != 0);
|
||||
|
||||
git_object_free(revision.from);
|
||||
git_object_free(revision.to);
|
||||
git_object_free(revspec.from);
|
||||
git_object_free(revspec.to);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user