diff options
Diffstat (limited to 'builtin/remote.c')
-rw-r--r-- | builtin/remote.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index 42702d78ba..d9632df87e 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -147,6 +147,7 @@ static int add(int argc, const char **argv) const char *master = NULL; struct remote *remote; struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT; + struct strbuf err = STRBUF_INIT; const char *name, *url; int i; @@ -230,8 +231,12 @@ static int add(int argc, const char **argv) strbuf_reset(&buf2); strbuf_addf(&buf2, "refs/remotes/%s/%s", name, master); - if (create_symref(buf.buf, buf2.buf, "remote add")) - return error(_("Could not setup master '%s'"), master); + if (create_symref(buf.buf, buf2.buf, "remote add", &err)) { + error(_("Could not setup master '%s'. %s"), + master, err.buf); + strbuf_release(&err); + return -1; + } } strbuf_release(&buf); @@ -617,8 +622,8 @@ static int mv(int argc, const char **argv) OPT_END() }; struct remote *oldremote, *newremote; - struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT, - old_remote_context = STRBUF_INIT; + struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT; + struct strbuf old_remote_context = STRBUF_INIT, err = STRBUF_INIT; struct string_list remote_branches = STRING_LIST_INIT_NODUP; struct rename_info rename; int i, refspec_updated = 0; @@ -742,8 +747,8 @@ static int mv(int argc, const char **argv) strbuf_reset(&buf3); strbuf_addf(&buf3, "remote: renamed %s to %s", item->string, buf.buf); - if (create_symref(buf.buf, buf2.buf, buf3.buf)) - die(_("creating '%s' failed"), buf.buf); + if (create_symref(buf.buf, buf2.buf, buf3.buf, &err)) + die(_("creating '%s' failed. %s"), buf.buf, err.buf); } return 0; } @@ -1260,6 +1265,7 @@ static int set_head(int argc, const char **argv) { int i, opt_a = 0, opt_d = 0, result = 0; struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT; + struct strbuf err = STRBUF_INIT; char *head_name = NULL; struct option options[] = { @@ -1302,8 +1308,12 @@ static int set_head(int argc, const char **argv) /* make sure it's valid */ if (!ref_exists(buf2.buf)) result |= error(_("Not a valid ref: %s"), buf2.buf); - else if (create_symref(buf.buf, buf2.buf, "remote set-head")) - result |= error(_("Could not setup %s"), buf.buf); + else if (create_symref(buf.buf, buf2.buf, "remote set-head", + &err)) { + error(_("Could not setup %s. %s"), buf.buf, err.buf); + strbuf_release(&err); + result = -1; + } if (opt_a) printf("%s/HEAD set to %s\n", argv[0], head_name); free(head_name); |