git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remote.<name>.push without dst doesn't behave as documented
@ 2024-12-16 16:47 Yuri Kanivetsky
  2024-12-16 18:12 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Kanivetsky @ 2024-12-16 16:47 UTC (permalink / raw)
  To: Git Mailing List

Hi,

> If git push [<repository>] without any <refspec> argument is set to update some ref at the destination with <src> with remote.<repository>.push configuration variable, :<dst> part can be omitted—such a push will update a ref that <src> normally updates without any <refspec> on the command line. Otherwise, missing :<dst> means to update the same ref as the <src>.

https://git-scm.com/docs/git-push#Documentation/git-push.txt-ltrefspecgt82308203

The only case I can think of where refspec is not passed via command
line and it updates a non-matching branch is when push.default =
upstream. But with remote.<repository>.push without dst it starts
updating a matching branch. Either I don't understand what's meant, or
it doesn't behave as documented.

The second test fails:

@test "normally a non-matching ref updates" {
    start_cloned_repo
    git config push.default upstream
    git checkout -b bb
    git branch -u origin/ba
    git commit --allow-empty -m b

    git push

    assert_equal_refs origin/ba bb
}

@test "with remote.<name>.push without dst happens what happens normally" {
    start_cloned_repo
    git config push.default upstream
    git config remote.origin.push 'refs/heads/*'
    git checkout -b bb
    git branch -u origin/ba
    git commit --allow-empty -m b

    git push

    assert_equal_refs origin/ba bb
}

start_cloned_repo() {
    (mkrepo)
    cd "$BATS_TEST_TMPDIR"
    git clone --bare a a.git
    git clone a.git b
    cd b
    git config push.default upstream
    git config user.email you@example.com
    git config user.name "Your Name"
}

mkrepo() {
    cd "$BATS_TEST_TMPDIR"
    mkdir a
    (cd a
    git init
    git branch -m ba
    git config user.email you@example.com
    git config user.name "Your Name"
    git commit --allow-empty -m a)
}

More details in a gist:
https://gist.github.com/x-yuri/943fd13704b38551da36c8363d7852e1

Regards,
Yuri

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-19  3:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-16 16:47 remote.<name>.push without dst doesn't behave as documented Yuri Kanivetsky
2024-12-16 18:12 ` Junio C Hamano
2024-12-17  8:12   ` Yuri Kanivetsky
2024-12-19  3:48     ` Yuri Kanivetsky

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).