mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 17:20:22 +00:00
Add git_reflog_rename() and git_reflog_delete()
Signed-off-by: schu <schu-github@schulog.org>
This commit is contained in:
parent
64093ce518
commit
b7c93a66e2
@ -50,6 +50,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);
|
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
|
* Get the number of log entries in a reflog
|
||||||
*
|
*
|
||||||
|
26
src/reflog.c
26
src/reflog.c
@ -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);
|
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)
|
unsigned int git_reflog_entrycount(git_reflog *reflog)
|
||||||
{
|
{
|
||||||
assert(reflog);
|
assert(reflog);
|
||||||
|
Loading…
Reference in New Issue
Block a user