diff options
author | Tao Klerks <tao@klerks.biz> | 2022-04-29 09:56:46 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-29 11:20:55 -0700 |
commit | 05d57750c66e4b58233787954c06b8f714bbee75 (patch) | |
tree | 5205a9e18538dfa9e205b3fee4f8806f74b10e2d /t/t5528-push-default.sh | |
parent | 8a649be7e8010085a8a3f1c9126da5c02324350e (diff) | |
download | git-05d57750c66e4b58233787954c06b8f714bbee75.tar.gz |
push: new config option "push.autoSetupRemote" supports "simple" push
In some "simple" centralized workflows, users expect remote tracking
branch names to match local branch names. "git push" pushes to the
remote version/instance of the branch, and "git pull" pulls any changes
to the remote branch (changes made by the same user in another place, or
by other users).
This expectation is supported by the push.default default option "simple"
which refuses a default push for a mismatching tracking branch name, and
by the new branch.autosetupmerge option, "simple", which only sets up
remote tracking for same-name remote branches.
When a new branch has been created by the user and has not yet been
pushed (and push.default is not set to "current"), the user is prompted
with a "The current branch %s has no upstream branch" error, and
instructions on how to push and add tracking.
This error is helpful in that following the advice once per branch
"resolves" the issue for that branch forever, but inconvenient in that
for the "simple" centralized workflow, this is always the right thing to
do, so it would be better to just do it.
Support this workflow with a new config setting, push.autoSetupRemote,
which will cause a default push, when there is no remote tracking branch
configured, to push to the same-name on the remote and --set-upstream.
Also add a hint offering this new option when the "The current branch %s
has no upstream branch" error is encountered, and add corresponding tests.
Signed-off-by: Tao Klerks <tao@klerks.biz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5528-push-default.sh')
-rwxr-xr-x | t/t5528-push-default.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index 0d6c9869ed..284e20fefd 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -162,6 +162,20 @@ test_expect_success 'push from/to branch with tracking fails with nothing ' ' test_push_failure nothing ' +test_expect_success 'push from/to new branch succeeds with upstream if push.autoSetupRemote' ' + git checkout -b new-branch-a && + test_config push.autoSetupRemote true && + test_config branch.new-branch-a.remote parent1 && + test_push_success upstream new-branch-a +' + +test_expect_success 'push from/to new branch succeeds with simple if push.autoSetupRemote' ' + git checkout -b new-branch-c && + test_config push.autoSetupRemote true && + test_config branch.new-branch-c.remote parent1 && + test_push_success simple new-branch-c +' + test_expect_success '"matching" fails if none match' ' git init --bare empty && test_must_fail git push empty : 2>actual && |