diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-02-12 00:43:01 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-02-12 00:43:01 +0100 |
commit | 8e29ae7310a731e3a4dc8f952ae2245f83960673 (patch) | |
tree | 56d8f09db063c8a16b56846db707896ac43ab7ab /src | |
parent | e07c1e1a157b28c99378806aac8b6af9c65c6c52 (diff) | |
parent | 1589a93aa6c7239423201465ceaddf461e98ac26 (diff) | |
download | libgit2-8e29ae7310a731e3a4dc8f952ae2245f83960673.tar.gz |
Merge pull request #2862 from jeffhostetler/jeffhostetler/bug/branch_create_after_namespace
Remove stale reflog namespace directory before branch creation
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: |