* [PATCH next] branch.c: if remote is not config'd for branch, don't try delete push config
@ 2009-07-16 21:26 Brandon Casey
2009-07-17 22:04 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Brandon Casey @ 2009-07-16 21:26 UTC (permalink / raw)
To: gitster; +Cc: git, Brandon Casey, bonzini
From: Brandon Casey <drafnel@gmail.com>
If a remote is not configured for the branch configuration being deleted,
then don't try to delete the remote.<remote>.push configuration for the
branch. When the remote is not configured, branch->remote_name is not
filled in. When this NULL branch->remote_name is passed to strbuf_addf()
it will result in an attempt to remove a bogus configuration statement in
the best case (i.e. "remote.(null).push" for platforms which guard against
supplying NULL to a %s conversion spec) and a segfault in the worst case.
So check whether branch->remote_name is non-NULL before trying to use it.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
branch.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/branch.c b/branch.c
index dfde568..6dc9175 100644
--- a/branch.c
+++ b/branch.c
@@ -116,13 +116,16 @@ void delete_branch_config (const char *name)
/* git config --unset-all remote.foo.push ^\+?refs/heads/bar: */
branch = branch_get(name + 11);
- strbuf_addf(&buf, "remote.%s.push", branch->remote_name);
- strbuf_addstr(&push_re, "^\\+?");
- strbuf_addstr_escape_re(&push_re, name);
- strbuf_addch(&push_re, ':');
- if (git_config_set_multivar(buf.buf, NULL, push_re.buf, 1) < 0) {
- warning("Update of config-file failed");
- goto fail;
+ if (branch->remote_name) {
+ strbuf_addf(&buf, "remote.%s.push", branch->remote_name);
+ strbuf_addstr(&push_re, "^\\+?");
+ strbuf_addstr_escape_re(&push_re, name);
+ strbuf_addch(&push_re, ':');
+ if (git_config_set_multivar(buf.buf, NULL, push_re.buf, 1) < 0)
+ {
+ warning("Update of config-file failed");
+ goto fail;
+ }
}
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s", name + 11);
--
1.6.3.1.24.g152f4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH next] branch.c: if remote is not config'd for branch, don't try delete push config
2009-07-16 21:26 [PATCH next] branch.c: if remote is not config'd for branch, don't try delete push config Brandon Casey
@ 2009-07-17 22:04 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2009-07-17 22:04 UTC (permalink / raw)
To: Brandon Casey; +Cc: gitster, git, Brandon Casey, bonzini
On Thu, Jul 16, 2009 at 04:26:15PM -0500, Brandon Casey wrote:
> So check whether branch->remote_name is non-NULL before trying to use it.
Thanks, my Solaris autobuild detected this last night. I bisected it to
4f67cc0, and I can confirm that your patch fixes it.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-17 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 21:26 [PATCH next] branch.c: if remote is not config'd for branch, don't try delete push config Brandon Casey
2009-07-17 22:04 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).