diff options
author | schu <schu-github@schulog.org> | 2011-11-21 13:01:40 +0100 |
---|---|---|
committer | schu <schu-github@schulog.org> | 2011-11-21 13:15:56 +0100 |
commit | b7c93a66e2410298fe846b9ed18a70b4d0ace45e (patch) | |
tree | c1b6c9b806beb7d8be9a3fe65427edf86ae806ec /src/reflog.c | |
parent | 64093ce51879b5f9f6015b94fce095499c14159c (diff) | |
download | libgit2-b7c93a66e2410298fe846b9ed18a70b4d0ace45e.tar.gz |
Add git_reflog_rename() and git_reflog_delete()
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'src/reflog.c')
-rw-r--r-- | src/reflog.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/reflog.c b/src/reflog.c index e0fa7a060..f52ae585f 100644 --- a/src/reflog.c +++ b/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); } +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); |