Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
cbda09d0
Commit
cbda09d0
authored
Apr 15, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_revision -> git_revspec
parent
36c2dfed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
32 deletions
+32
-32
include/git2/revparse.h
+2
-2
src/revparse.c
+9
-9
src/revwalk.c
+7
-7
tests-clar/refs/revparse.c
+14
-14
No files found.
include/git2/revparse.h
View file @
cbda09d0
...
@@ -53,7 +53,7 @@ typedef struct {
...
@@ -53,7 +53,7 @@ typedef struct {
git_object
*
from
;
git_object
*
from
;
git_object
*
to
;
git_object
*
to
;
unsigned
int
flags
;
unsigned
int
flags
;
}
git_rev
ision
;
}
git_rev
spec
;
/**
/**
* Parse a revision string for left, right, and intent. See `man gitrevisions` or
* Parse a revision string for left, right, and intent. See `man gitrevisions` or
...
@@ -72,7 +72,7 @@ typedef struct {
...
@@ -72,7 +72,7 @@ typedef struct {
* @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code
* @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code
*/
*/
GIT_EXTERN
(
int
)
git_revparse
(
GIT_EXTERN
(
int
)
git_revparse
(
git_rev
ision
*
revision
,
git_rev
spec
*
revspec
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
spec
);
const
char
*
spec
);
...
...
src/revparse.c
View file @
cbda09d0
...
@@ -870,41 +870,41 @@ cleanup:
...
@@ -870,41 +870,41 @@ cleanup:
int
git_revparse
(
int
git_revparse
(
git_rev
ision
*
revision
,
git_rev
spec
*
revspec
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
spec
)
const
char
*
spec
)
{
{
const
char
*
dotdot
;
const
char
*
dotdot
;
int
error
=
0
;
int
error
=
0
;
assert
(
rev
ision
&&
repo
&&
spec
);
assert
(
rev
spec
&&
repo
&&
spec
);
memset
(
rev
ision
,
0x0
,
sizeof
(
*
revision
));
memset
(
rev
spec
,
0x0
,
sizeof
(
*
revspec
));
if
((
dotdot
=
strstr
(
spec
,
".."
))
!=
NULL
)
{
if
((
dotdot
=
strstr
(
spec
,
".."
))
!=
NULL
)
{
char
*
lstr
;
char
*
lstr
;
const
char
*
rstr
;
const
char
*
rstr
;
rev
ision
->
flags
=
GIT_REVPARSE_RANGE
;
rev
spec
->
flags
=
GIT_REVPARSE_RANGE
;
lstr
=
git__substrdup
(
spec
,
dotdot
-
spec
);
lstr
=
git__substrdup
(
spec
,
dotdot
-
spec
);
rstr
=
dotdot
+
2
;
rstr
=
dotdot
+
2
;
if
(
dotdot
[
2
]
==
'.'
)
{
if
(
dotdot
[
2
]
==
'.'
)
{
rev
ision
->
flags
|=
GIT_REVPARSE_MERGE_BASE
;
rev
spec
->
flags
|=
GIT_REVPARSE_MERGE_BASE
;
rstr
++
;
rstr
++
;
}
}
if
((
error
=
git_revparse_single
(
&
rev
ision
->
from
,
repo
,
lstr
))
<
0
)
{
if
((
error
=
git_revparse_single
(
&
rev
spec
->
from
,
repo
,
lstr
))
<
0
)
{
return
error
;
return
error
;
}
}
if
((
error
=
git_revparse_single
(
&
rev
ision
->
to
,
repo
,
rstr
))
<
0
)
{
if
((
error
=
git_revparse_single
(
&
rev
spec
->
to
,
repo
,
rstr
))
<
0
)
{
return
error
;
return
error
;
}
}
git__free
((
void
*
)
lstr
);
git__free
((
void
*
)
lstr
);
}
else
{
}
else
{
rev
ision
->
flags
=
GIT_REVPARSE_SINGLE
;
rev
spec
->
flags
=
GIT_REVPARSE_SINGLE
;
error
=
git_revparse_single
(
&
rev
ision
->
from
,
repo
,
spec
);
error
=
git_revparse_single
(
&
rev
spec
->
from
,
repo
,
spec
);
}
}
return
error
;
return
error
;
...
...
src/revwalk.c
View file @
cbda09d0
...
@@ -231,26 +231,26 @@ int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
...
@@ -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
)
int
git_revwalk_push_range
(
git_revwalk
*
walk
,
const
char
*
range
)
{
{
git_rev
ision
revision
;
git_rev
spec
revspec
;
int
error
=
0
;
int
error
=
0
;
if
((
error
=
git_revparse
(
&
rev
ision
,
walk
->
repo
,
range
)))
if
((
error
=
git_revparse
(
&
rev
spec
,
walk
->
repo
,
range
)))
return
error
;
return
error
;
if
(
rev
ision
.
flags
&
GIT_REVPARSE_MERGE_BASE
)
{
if
(
rev
spec
.
flags
&
GIT_REVPARSE_MERGE_BASE
)
{
/* TODO: support "<commit>...<commit>" */
/* TODO: support "<commit>...<commit>" */
giterr_set
(
GITERR_INVALID
,
"Symmetric differences not implemented in revwalk"
);
giterr_set
(
GITERR_INVALID
,
"Symmetric differences not implemented in revwalk"
);
return
GIT_EINVALIDSPEC
;
return
GIT_EINVALIDSPEC
;
}
}
if
((
error
=
push_commit
(
walk
,
git_object_id
(
rev
ision
.
from
),
1
)))
if
((
error
=
push_commit
(
walk
,
git_object_id
(
rev
spec
.
from
),
1
)))
goto
out
;
goto
out
;
error
=
push_commit
(
walk
,
git_object_id
(
rev
ision
.
to
),
0
);
error
=
push_commit
(
walk
,
git_object_id
(
rev
spec
.
to
),
0
);
out:
out:
git_object_free
(
rev
ision
.
from
);
git_object_free
(
rev
spec
.
from
);
git_object_free
(
rev
ision
.
to
);
git_object_free
(
rev
spec
.
to
);
return
error
;
return
error
;
}
}
...
...
tests-clar/refs/revparse.c
View file @
cbda09d0
...
@@ -34,28 +34,28 @@ static void test_id_inrepo(
...
@@ -34,28 +34,28 @@ static void test_id_inrepo(
git_revparse_mode_t
expected_flags
,
git_revparse_mode_t
expected_flags
,
git_repository
*
repo
)
git_repository
*
repo
)
{
{
git_rev
ision
revision
;
git_rev
spec
revspec
;
int
error
=
git_revparse
(
&
rev
ision
,
repo
,
spec
);
int
error
=
git_revparse
(
&
rev
spec
,
repo
,
spec
);
if
(
expected_left
)
{
if
(
expected_left
)
{
char
str
[
64
]
=
{
0
};
char
str
[
64
]
=
{
0
};
cl_assert_equal_i
(
0
,
error
);
cl_assert_equal_i
(
0
,
error
);
git_oid_fmt
(
str
,
git_object_id
(
rev
ision
.
from
));
git_oid_fmt
(
str
,
git_object_id
(
rev
spec
.
from
));
cl_assert_equal_s
(
str
,
expected_left
);
cl_assert_equal_s
(
str
,
expected_left
);
git_object_free
(
rev
ision
.
from
);
git_object_free
(
rev
spec
.
from
);
}
else
{
}
else
{
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
}
}
if
(
expected_right
)
{
if
(
expected_right
)
{
char
str
[
64
]
=
{
0
};
char
str
[
64
]
=
{
0
};
git_oid_fmt
(
str
,
git_object_id
(
rev
ision
.
to
));
git_oid_fmt
(
str
,
git_object_id
(
rev
spec
.
to
));
cl_assert_equal_s
(
str
,
expected_right
);
cl_assert_equal_s
(
str
,
expected_right
);
git_object_free
(
rev
ision
.
to
);
git_object_free
(
rev
spec
.
to
);
}
}
if
(
expected_flags
)
if
(
expected_flags
)
cl_assert_equal_i
(
expected_flags
,
rev
ision
.
flags
);
cl_assert_equal_i
(
expected_flags
,
rev
spec
.
flags
);
}
}
static
void
test_object
(
const
char
*
spec
,
const
char
*
expected_oid
)
static
void
test_object
(
const
char
*
spec
,
const
char
*
expected_oid
)
...
@@ -69,23 +69,23 @@ static void test_rangelike(const char *rangelike,
...
@@ -69,23 +69,23 @@ static void test_rangelike(const char *rangelike,
git_revparse_mode_t
expected_revparseflags
)
git_revparse_mode_t
expected_revparseflags
)
{
{
char
objstr
[
64
]
=
{
0
};
char
objstr
[
64
]
=
{
0
};
git_rev
ision
revision
;
git_rev
spec
revspec
;
int
error
;
int
error
;
error
=
git_revparse
(
&
rev
ision
,
g_repo
,
rangelike
);
error
=
git_revparse
(
&
rev
spec
,
g_repo
,
rangelike
);
if
(
expected_left
!=
NULL
)
{
if
(
expected_left
!=
NULL
)
{
cl_assert_equal_i
(
0
,
error
);
cl_assert_equal_i
(
0
,
error
);
cl_assert_equal_i
(
rev
ision
.
flags
,
expected_revparseflags
);
cl_assert_equal_i
(
rev
spec
.
flags
,
expected_revparseflags
);
git_oid_fmt
(
objstr
,
git_object_id
(
rev
ision
.
from
));
git_oid_fmt
(
objstr
,
git_object_id
(
rev
spec
.
from
));
cl_assert_equal_s
(
objstr
,
expected_left
);
cl_assert_equal_s
(
objstr
,
expected_left
);
git_oid_fmt
(
objstr
,
git_object_id
(
rev
ision
.
to
));
git_oid_fmt
(
objstr
,
git_object_id
(
rev
spec
.
to
));
cl_assert_equal_s
(
objstr
,
expected_right
);
cl_assert_equal_s
(
objstr
,
expected_right
);
}
else
}
else
cl_assert
(
error
!=
0
);
cl_assert
(
error
!=
0
);
git_object_free
(
rev
ision
.
from
);
git_object_free
(
rev
spec
.
from
);
git_object_free
(
rev
ision
.
to
);
git_object_free
(
rev
spec
.
to
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment