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
b7c93a66
Commit
b7c93a66
authored
Nov 21, 2011
by
schu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_reflog_rename() and git_reflog_delete()
Signed-off-by: schu <schu-github@schulog.org>
parent
64093ce5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
include/git2/reflog.h
+17
-0
src/reflog.c
+26
-0
No files found.
include/git2/reflog.h
View file @
b7c93a66
...
...
@@ -51,6 +51,23 @@ GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
GIT_EXTERN
(
int
)
git_reflog_write
(
git_reference
*
ref
,
const
git_oid
*
oid_old
,
const
git_signature
*
committer
,
const
char
*
msg
);
/**
* Rename the reflog for the given reference
*
* @param ref the reference
* @param new_name the new name of the reference
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN
(
int
)
git_reflog_rename
(
git_reference
*
ref
,
const
char
*
new_name
);
/**
* Delete the reflog for the given reference
*
* @param ref the reference
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN
(
int
)
git_reflog_delete
(
git_reference
*
ref
);
/**
* Get the number of log entries in a reflog
*
* @param reflog the previously loaded reflog
...
...
src/reflog.c
View file @
b7c93a66
...
...
@@ -255,6 +255,32 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
return
reflog_write
(
log_path
,
old
,
new
,
committer
,
msg
);
}
int
git_reflog_rename
(
git_reference
*
ref
,
const
char
*
new_name
)
{
char
old_path
[
GIT_PATH_MAX
];
char
new_path
[
GIT_PATH_MAX
];
git_path_join_n
(
old_path
,
3
,
ref
->
owner
->
path_repository
,
GIT_REFLOG_DIR
,
ref
->
name
);
git_path_join_n
(
new_path
,
3
,
ref
->
owner
->
path_repository
,
GIT_REFLOG_DIR
,
new_name
);
return
p_rename
(
old_path
,
new_path
);
}
int
git_reflog_delete
(
git_reference
*
ref
)
{
char
path
[
GIT_PATH_MAX
];
git_path_join_n
(
path
,
3
,
ref
->
owner
->
path_repository
,
GIT_REFLOG_DIR
,
ref
->
name
);
if
(
git_futils_exists
(
path
))
return
GIT_SUCCESS
;
return
p_unlink
(
path
);
}
unsigned
int
git_reflog_entrycount
(
git_reflog
*
reflog
)
{
assert
(
reflog
);
...
...
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