push: default to single remote even when not named origin
commit8a649be7e8010085a8a3f1c9126da5c02324350e
authorTao Klerks <tao@klerks.biz>
Fri, 29 Apr 2022 09:56:45 +0000 (29 09:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2022 18:20:55 +0000 (29 11:20 -0700)
treeee31880869adbf2497d38ffe263340bd7a9833fd
parentbdaf1dfae71fdf120fc7253e713ccf0a06cc5558
push: default to single remote even when not named origin

With "push.default=current" configured, a simple "git push" will push to
the same-name branch on the current branch's branch.<name>.pushRemote, or
remote.pushDefault, or origin. If none of these are defined, the push will
fail with error "fatal: No configured push destination".

The same "default to origin if no config" behavior applies with
"push.default=matching".

Other commands use "origin" as a default when there are multiple options,
but default to the single remote when there is only one - for example,
"git checkout <something>". This "assume the single remote if there is
only one" behavior is more friendly/useful than a defaulting behavior
that only uses the name "origin" no matter what.

Update "git push" to also default to the single remote (and finally fall
back to "origin" as default if there are several), for
"push.default=current" and for other current and future remote-defaulting
push behaviors.

This change also modifies the behavior of ls-remote in a consistent way,
so defaulting not only supplies 'origin', but any single configured remote
also.

Document the change in behavior, correct incorrect assumptions in related
tests, and add test cases reflecting this new single-remote-defaulting
behavior.

Signed-off-by: Tao Klerks <tao@klerks.biz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/branch.txt
remote.c
t/t5512-ls-remote.sh
t/t5528-push-default.sh