diff options
author | Russell Belfer <rb@github.com> | 2013-12-04 21:22:57 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
commit | dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7 (patch) | |
tree | c7f4f4738dfb249b7534635226128d2e20dac6a5 /src/remote.c | |
parent | 96869a4edb2872934e0e167a726ab240f4270fea (diff) | |
download | libgit2-dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7.tar.gz |
Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper. As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.
Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up. A number of
those fixes are included in the this commit as well.
Diffstat (limited to 'src/remote.c')
-rw-r--r-- | src/remote.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/remote.c b/src/remote.c index e4bebe1c6..e9d079db5 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1370,46 +1370,43 @@ static int rename_fetch_refspecs( if (git_buf_printf(&base, "+refs/heads/*:refs/remotes/%s/*", remote->name) < 0) goto cleanup; + if ((error = git_repository_config__weakptr(&config, remote->repo)) < 0) + goto cleanup; + git_vector_foreach(&remote->refspecs, i, spec) { if (spec->push) continue; - /* Every refspec is a problem refspec for an in-memory remote */ - if (!remote->name) { - if (callback(spec->string, payload) < 0) { - error = GIT_EUSER; - goto cleanup; - } - - continue; - } + /* Every refspec is a problem refspec for an in-memory remote, OR */ + /* Does the dst part of the refspec follow the expected format? */ + if (!remote->name || + strcmp(git_buf_cstr(&base), spec->string)) { - /* Does the dst part of the refspec follow the extected standard format? */ - if (strcmp(git_buf_cstr(&base), spec->string)) { if (callback(spec->string, payload) < 0) { - error = GIT_EUSER; + error = giterr_user_cancel(); goto cleanup; } - continue; } /* If we do want to move it to the new section */ - if (git_buf_printf(&val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0) - goto cleanup; - if (git_buf_printf(&var, "remote.%s.fetch", new_name) < 0) - goto cleanup; + git_buf_clear(&val); + git_buf_clear(&var); - if (git_repository_config__weakptr(&config, remote->repo) < 0) + if (git_buf_printf( + &val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0 || + git_buf_printf(&var, "remote.%s.fetch", new_name) < 0) + { + error = -1; goto cleanup; + } - if (git_config_set_string(config, git_buf_cstr(&var), git_buf_cstr(&val)) < 0) + if ((error = git_config_set_string( + config, git_buf_cstr(&var), git_buf_cstr(&val))) < 0) goto cleanup; } - error = 0; - cleanup: git_buf_free(&base); git_buf_free(&var); @@ -1445,11 +1442,11 @@ int git_remote_rename( new_name, callback, payload)) < 0) - return error; + return error; remote->name = git__strdup(new_name); + GITERR_CHECK_ALLOC(remote->name); - if (!remote->name) return 0; return git_remote_save(remote); } @@ -1476,11 +1473,13 @@ int git_remote_rename( new_name, callback, payload)) < 0) - return error; + return error; } git__free(remote->name); + remote->name = git__strdup(new_name); + GITERR_CHECK_ALLOC(remote->name); return 0; } |