summaryrefslogtreecommitdiff
path: root/src/push.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-01 15:01:47 -0700
committerRussell Belfer <rb@github.com>2013-05-01 15:01:47 -0700
commit62caf3f38fa25537b5f824329d8f88875ee837f2 (patch)
treede9bab3da3847c3a1c6290217e89e30381331e1c /src/push.c
parentf063f578981bfb7f88880e9bdfbfd0a370dfefea (diff)
downloadlibgit2-62caf3f38fa25537b5f824329d8f88875ee837f2.tar.gz
Report some errors returnable by push
Diffstat (limited to 'src/push.c')
-rw-r--r--src/push.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/push.c b/src/push.c
index 9b1e78c8e..0499d8648 100644
--- a/src/push.c
+++ b/src/push.c
@@ -303,7 +303,7 @@ static int revwalk(git_vector *commits, git_push *push)
continue;
if (!git_odb_exists(push->repo->_odb, &spec->roid)) {
- giterr_clear();
+ giterr_set(GITERR_REFERENCE, "Cannot push missing reference");
error = GIT_ENONFASTFORWARD;
goto on_error;
}
@@ -313,7 +313,8 @@ static int revwalk(git_vector *commits, git_push *push)
if (error == GIT_ENOTFOUND ||
(!error && !git_oid_equal(&base, &spec->roid))) {
- giterr_clear();
+ giterr_set(GITERR_REFERENCE,
+ "Cannot push non-fastforwardable reference");
error = GIT_ENONFASTFORWARD;
goto on_error;
}
@@ -333,12 +334,13 @@ static int revwalk(git_vector *commits, git_push *push)
while ((error = git_revwalk_next(&oid, rw)) == 0) {
git_oid *o = git__malloc(GIT_OID_RAWSZ);
- GITERR_CHECK_ALLOC(o);
- git_oid_cpy(o, &oid);
- if (git_vector_insert(commits, o) < 0) {
+ if (!o) {
error = -1;
goto on_error;
}
+ git_oid_cpy(o, &oid);
+ if ((error = git_vector_insert(commits, o)) < 0)
+ goto on_error;
}
on_error:
@@ -519,7 +521,7 @@ static int calculate_work(git_push *push)
/* This is a create or update. Local ref must exist. */
if (git_reference_name_to_id(
&spec->loid, push->repo, spec->lref) < 0) {
- giterr_set(GIT_ENOTFOUND, "No such reference '%s'", spec->lref);
+ giterr_set(GITERR_REFERENCE, "No such reference '%s'", spec->lref);
return -1;
}
}