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
976634c4
Commit
976634c4
authored
Mar 30, 2014
by
Edward Thomson
Committed by
Edward Thomson
Mar 31, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce git_merge_head_id
parent
7b445c21
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
include/git2/merge.h
+9
-0
src/merge.c
+8
-0
tests/merge/workdir/setup.c
+27
-0
No files found.
include/git2/merge.h
View file @
976634c4
...
...
@@ -376,6 +376,15 @@ GIT_EXTERN(int) git_merge_head_from_id(
const
git_oid
*
id
);
/**
* Gets the commit ID that the given `git_merge_head` refers to.
*
* @param id pointer to commit id to be filled in
* @param head the given merge head
*/
GIT_EXTERN
(
const
git_oid
*
)
git_merge_head_id
(
const
git_merge_head
*
head
);
/**
* Frees a `git_merge_head`.
*
* @param head merge head to free
...
...
src/merge.c
View file @
976634c4
...
...
@@ -2736,6 +2736,14 @@ int git_merge_head_from_fetchhead(
return
merge_head_init
(
out
,
repo
,
branch_name
,
remote_url
,
oid
);
}
const
git_oid
*
git_merge_head_id
(
const
git_merge_head
*
head
)
{
assert
(
head
);
return
&
head
->
oid
;
}
void
git_merge_head_free
(
git_merge_head
*
head
)
{
if
(
head
==
NULL
)
...
...
tests/merge/workdir/setup.c
View file @
976634c4
...
...
@@ -881,6 +881,33 @@ void test_merge_workdir_setup__two_remotes(void)
git_merge_head_free
(
their_heads
[
3
]);
}
void
test_merge_workdir_setup__id_from_head
(
void
)
{
git_oid
expected_id
;
const
git_oid
*
id
;
git_reference
*
ref
;
git_merge_head
*
heads
[
3
];
cl_git_pass
(
git_oid_fromstr
(
&
expected_id
,
OCTO1_OID
));
cl_git_pass
(
git_merge_head_from_fetchhead
(
&
heads
[
0
],
repo
,
GIT_REFS_HEADS_DIR
OCTO1_BRANCH
,
"http://remote.url/repo.git"
,
&
expected_id
));
id
=
git_merge_head_id
(
heads
[
0
]);
cl_assert_equal_i
(
1
,
git_oid_equal
(
id
,
&
expected_id
));
cl_git_pass
(
git_merge_head_from_id
(
&
heads
[
1
],
repo
,
&
expected_id
));
id
=
git_merge_head_id
(
heads
[
1
]);
cl_assert_equal_i
(
1
,
git_oid_equal
(
id
,
&
expected_id
));
cl_git_pass
(
git_reference_lookup
(
&
ref
,
repo
,
GIT_REFS_HEADS_DIR
OCTO1_BRANCH
));
cl_git_pass
(
git_merge_head_from_ref
(
&
heads
[
2
],
repo
,
ref
));
id
=
git_merge_head_id
(
heads
[
2
]);
cl_assert_equal_i
(
1
,
git_oid_equal
(
id
,
&
expected_id
));
git_reference_free
(
ref
);
git_merge_head_free
(
heads
[
0
]);
git_merge_head_free
(
heads
[
1
]);
git_merge_head_free
(
heads
[
2
]);
}
struct
merge_head_cb_data
{
const
char
**
oid_str
;
unsigned
int
len
;
...
...
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