diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-22 12:24:09 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-22 12:31:39 +0200 |
| commit | 5014fe95f5691ec9c48e1bb33fa03d925a4159f0 (patch) | |
| tree | 2d2e55a094f98cd660b02e6b3c9f82ca029f74d9 /src | |
| parent | 7cd4ba1b17d579134ac6cc172fc858021d4aa407 (diff) | |
| download | libgit2-5014fe95f5691ec9c48e1bb33fa03d925a4159f0.tar.gz | |
branch: error out if we cannot find the remotecmn/upstream-matching-push
When we look for which remote corresponds to a remote-tracking branch,
we look in the refspecs to see which ones matches. If none do, we should
abort. We currently ignore the error message from this operation, so
let's not do that anymore.
As part of the test we're writing, let's test for the expected behaviour
if we cannot find a refspec which tells us what the remote-tracking
branch for a remote would look like.
Diffstat (limited to 'src')
| -rw-r--r-- | src/branch.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/branch.c b/src/branch.c index 10be6f70c..791d55106 100644 --- a/src/branch.c +++ b/src/branch.c @@ -551,7 +551,7 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name) git_remote *remote = NULL; git_config *config; const char *name, *shortname; - int local; + int local, error; const git_refspec *fetchspec; name = git_reference_name(branch); @@ -586,9 +586,12 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name) * that. */ if (local) - git_buf_puts(&value, "."); + error = git_buf_puts(&value, "."); else - git_branch_remote_name(&value, repo, git_reference_name(upstream)); + error = git_branch_remote_name(&value, repo, git_reference_name(upstream)); + + if (error < 0) + goto on_error; if (git_buf_printf(&key, "branch.%s.remote", shortname) < 0) goto on_error; |
