Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-11-12 19:49:29 +0400
committernulltoken <emeric.fermas@gmail.com>2012-12-01 11:34:27 +0400
commit80212ecb1c2ce3e27d1a4ffe053e36260ee06c01 (patch)
treef838a0c4d622c1ff4748d59e8c6c3710ea9475be /src/reflog.c
parente4aa7f58fefc7455b5527d410ad3f9c2c4032820 (diff)
reflog: Deploy EINVALIDSPEC usage
Diffstat (limited to 'src/reflog.c')
-rw-r--r--src/reflog.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/reflog.c b/src/reflog.c
index ac481fb81..df799b113 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -340,21 +340,29 @@ cleanup:
int git_reflog_rename(git_reference *ref, const char *new_name)
{
- int error = -1, fd;
+ int error, fd;
git_buf old_path = GIT_BUF_INIT;
git_buf new_path = GIT_BUF_INIT;
git_buf temp_path = GIT_BUF_INIT;
+ git_buf normalized = GIT_BUF_INIT;
assert(ref && new_name);
+ if ((error = git_reference__normalize_name(
+ &normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0)
+ goto cleanup;
+
+ error = -1;
+
if (git_buf_joinpath(&temp_path, git_reference_owner(ref)->path_repository, GIT_REFLOG_DIR) < 0)
return -1;
if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), ref->name) < 0)
goto cleanup;
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), new_name) < 0)
- goto cleanup;
+ if (git_buf_joinpath(&new_path,
+ git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
+ goto cleanup;
/*
* Move the reflog to a temporary place. This two-phase renaming is required
@@ -386,6 +394,7 @@ cleanup:
git_buf_free(&temp_path);
git_buf_free(&old_path);
git_buf_free(&new_path);
+ git_buf_free(&normalized);
return error;
}