diff options
author | Vicent Martà <tanoku@gmail.com> | 2011-11-26 09:30:08 +0400 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2011-11-26 09:30:08 +0400 |
commit | e42ea1f488ae50655f31b8f09413a543b0fab9b7 (patch) | |
tree | 7697099dd809bb1e2e9fb28b4c1127853b5801ba /src/reflog.c | |
parent | 2869f404fd1fb345bfe86471dbcfba85abaa9f10 (diff) | |
parent | a5cd086dffbc07ad839f3a9c320dda6970594126 (diff) |
Merge pull request #491 from schu/refs-cleanup
reference_rename() cleanup
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 c136987b1..fbaaaea67 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); |