diff options
author | Jeff Hostetler <jeffhost@microsoft.com> | 2015-02-02 16:50:10 -0500 |
---|---|---|
committer | Jeff Hostetler <jeffhost@microsoft.com> | 2015-02-03 10:33:04 -0500 |
commit | 1589a93aa6c7239423201465ceaddf461e98ac26 (patch) | |
tree | 3d85e32f11c8492160d0015b889a9b7091c38240 /src | |
parent | f83c19c87d6f484b72c24125aaac98bdc365c4b5 (diff) | |
download | libgit2-1589a93aa6c7239423201465ceaddf461e98ac26.tar.gz |
Fix branch creation when branch name matches namespace of previously deleted branch
Diffstat (limited to 'src')
-rw-r--r-- | src/refdb_fs.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index fc41a95d7..5cd2112fc 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -1771,6 +1771,15 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co goto cleanup; } + /* If the new branch matches part of the namespace of a previously deleted branch, + * there maybe an obsolete/unused directory (or directory hierarchy) in the way. + */ + if (git_path_isdir(git_buf_cstr(&path)) && + (git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) { + error = -1; + goto cleanup; + } + error = git_futils_writebuffer(&buf, git_buf_cstr(&path), O_WRONLY|O_CREAT|O_APPEND, GIT_REFLOG_FILE_MODE); cleanup: |