summaryrefslogtreecommitdiff
path: root/src/refs.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-04-11 03:43:30 -0700
committerVicent Martí <tanoku@gmail.com>2012-04-11 03:43:30 -0700
commit0a20eee9536e8db0ab8d91f426f971f7151aaefa (patch)
tree7b57890c272e66c0f47ed64753eb5cec31f2bffa /src/refs.c
parentb78fb64d2f5c1b9e2e834e05e042271147c8d188 (diff)
parent4615f0f71ba849adef08f7a677842af3e0ee3d53 (diff)
downloadlibgit2-0a20eee9536e8db0ab8d91f426f971f7151aaefa.tar.gz
Merge pull request #619 from nulltoken/topic/branches
Basic branch management API
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index ed364cf90..fb23a0ef8 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -287,6 +287,15 @@ static int loose_write(git_reference *ref)
if (git_buf_joinpath(&ref_path, ref->owner->path_repository, ref->name) < 0)
return -1;
+ /* Remove a possibly existing empty directory hierarchy
+ * which name would collide with the reference name
+ */
+ if (git_path_isdir(git_buf_cstr(&ref_path)) &&
+ (git_futils_rmdir_r(git_buf_cstr(&ref_path), GIT_DIRREMOVAL_ONLY_EMPTY_DIRS) < 0)) {
+ git_buf_free(&ref_path);
+ return -1;
+ }
+
if (git_filebuf_open(&file, ref_path.ptr, GIT_FILEBUF_FORCE) < 0) {
git_buf_free(&ref_path);
return -1;