@@ -405,8 +405,12 @@ int send_pack(struct send_pack_args *args,
}
if (!remote_refs) {
+ char *branch_name = git_main_branch_name();
+
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
- "Perhaps you should specify a branch such as 'master'.\n");
+ "Perhaps you should specify a branch such as '%s'.\n",
+ branch_name);
+ free(branch_name);
return 0;
}
if (args->atomic && !atomic_supported)
@@ -98,6 +98,13 @@ test_expect_success 'push from/to new branch with upstream, matching and simple'
test_push_failure upstream
'
+test_expect_success '"matching" fails if none match' '
+ git init --bare empty &&
+ test_must_fail git -c core.mainBranch=unmatch push empty : 2>actual &&
+ needle="Perhaps you should specify a branch such as '\''unmatch'\''" &&
+ test_i18ngrep "$needle" actual
+'
+
test_expect_success 'push ambiguously named branch with upstream, matching and simple' '
git checkout -b ambiguous &&
test_config branch.ambiguous.remote parent1 &&
@@ -1044,9 +1044,13 @@ static int push_refs(struct transport *transport,
}
if (!remote_refs) {
+ char *branch_name = git_main_branch_name();
+
fprintf(stderr,
_("No refs in common and none specified; doing nothing.\n"
- "Perhaps you should specify a branch such as 'master'.\n"));
+ "Perhaps you should specify a branch such as '%s'.\n"),
+ branch_name);
+ free(branch_name);
return 0;
}