Commit af04b117 authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'jc/push-default-explicit' into maint

A lazy "git push" without refspec did not internally use a fully
specified refspec to perform 'current', 'simple', or 'upstream'
push, causing unnecessary "ambiguous ref" errors.

* jc/push-default-explicit:
  push: test pushing ambiguously named branches
  push: do not use potentially ambiguous default refspec
parents 943c9a7b b284495e
......@@ -194,15 +194,18 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
die_push_simple(branch, remote);
strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->merge[0]->src);
static void setup_push_current(struct remote *remote, struct branch *branch)
struct strbuf refspec = STRBUF_INIT;
if (!branch)
die(_(message_detached_head_die), remote->name);
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->refname);
static int is_workflow_triangular(struct remote *remote)
......@@ -98,6 +98,16 @@ test_expect_success 'push from/to new branch with upstream, matching and simple'
test_push_failure upstream
test_expect_success 'push ambiguously named branch with upstream, matching and simple' '
git checkout -b ambiguous &&
test_config branch.ambiguous.remote parent1 &&
test_config branch.ambiguous.merge refs/heads/ambiguous &&
git tag ambiguous &&
test_push_success simple ambiguous &&
test_push_success matching ambiguous &&
test_push_success upstream ambiguous
test_expect_success 'push from/to new branch with current creates remote branch' '
test_config repo1 &&
git checkout new-branch &&
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment