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
8a629afe
Commit
8a629afe
authored
Jan 31, 2018
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: move refish resolution function in common
parent
698b4463
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
23 deletions
+29
-23
examples/common.c
+24
-0
examples/common.h
+5
-0
examples/merge.c
+0
-23
No files found.
examples/common.c
View file @
8a629afe
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>.
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
*/
#include <assert.h>
#include "common.h"
#include "common.h"
void
check_lg2
(
int
error
,
const
char
*
message
,
const
char
*
extra
)
void
check_lg2
(
int
error
,
const
char
*
message
,
const
char
*
extra
)
...
@@ -245,3 +247,25 @@ void *xrealloc(void *oldp, size_t newsz)
...
@@ -245,3 +247,25 @@ void *xrealloc(void *oldp, size_t newsz)
return
p
;
return
p
;
}
}
int
resolve_refish
(
git_annotated_commit
**
commit
,
git_repository
*
repo
,
const
char
*
refish
)
{
git_reference
*
ref
;
int
err
=
0
;
git_oid
oid
;
assert
(
commit
!=
NULL
);
err
=
git_reference_dwim
(
&
ref
,
repo
,
refish
);
if
(
err
==
GIT_OK
)
{
git_annotated_commit_from_ref
(
commit
,
repo
,
ref
);
git_reference_free
(
ref
);
return
0
;
}
err
=
git_oid_fromstr
(
&
oid
,
refish
);
if
(
err
==
GIT_OK
)
{
err
=
git_annotated_commit_lookup
(
commit
,
repo
,
&
oid
);
}
return
err
;
}
examples/common.h
View file @
8a629afe
...
@@ -108,3 +108,8 @@ extern void treeish_to_tree(
...
@@ -108,3 +108,8 @@ extern void treeish_to_tree(
* A realloc that exits on failure
* A realloc that exits on failure
*/
*/
extern
void
*
xrealloc
(
void
*
oldp
,
size_t
newsz
);
extern
void
*
xrealloc
(
void
*
oldp
,
size_t
newsz
);
/**
* Convert a refish to an annotated commit.
*/
extern
int
resolve_refish
(
git_annotated_commit
**
commit
,
git_repository
*
repo
,
const
char
*
refish
);
examples/merge.c
View file @
8a629afe
...
@@ -87,29 +87,6 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
...
@@ -87,29 +87,6 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
}
}
}
}
static
int
resolve_refish
(
git_annotated_commit
**
commit
,
git_repository
*
repo
,
const
char
*
refish
)
{
git_reference
*
ref
;
int
err
=
0
;
git_oid
oid
;
assert
(
commit
!=
NULL
);
err
=
git_reference_dwim
(
&
ref
,
repo
,
refish
);
if
(
err
==
GIT_OK
)
{
git_annotated_commit_from_ref
(
commit
,
repo
,
ref
);
git_reference_free
(
ref
);
return
0
;
}
err
=
git_oid_fromstr
(
&
oid
,
refish
);
if
(
err
==
GIT_OK
)
{
err
=
git_annotated_commit_lookup
(
commit
,
repo
,
&
oid
);
}
return
err
;
}
static
int
resolve_heads
(
git_repository
*
repo
,
merge_options
*
opts
)
static
int
resolve_heads
(
git_repository
*
repo
,
merge_options
*
opts
)
{
{
git_annotated_commit
**
annotated
=
calloc
(
opts
->
heads_count
,
sizeof
(
git_annotated_commit
*
));
git_annotated_commit
**
annotated
=
calloc
(
opts
->
heads_count
,
sizeof
(
git_annotated_commit
*
));
...
...
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