remote: handle pushremote config in any order
commit98b406f3ad6a6989a5b11c2a2582a9f539d66263
authorJeff King <peff@peff.net>
Mon, 24 Feb 2014 08:59:03 +0000 (24 03:59 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2014 20:53:28 +0000 (24 12:53 -0800)
treeea03420878d55379efbf4c3bb0a82ec1d43c4521
parent7bbc4e8fdb33e0a8e42e77cc05460d4c4f615f4d
remote: handle pushremote config in any order

The remote we push can be defined either by
remote.pushdefault or by branch.*.pushremote for the current
branch. The order in which they appear in the config file
should not matter to precedence (which should be to prefer
the branch-specific config).

The current code parses the config linearly and uses a
single string to store both values, overwriting any
previous value. Thus, config like:

  [branch "master"]
  pushremote = foo
  [remote]
  pushdefault = bar

erroneously ends up pushing to "bar" from the master branch.

We can fix this by storing both values and resolving the
correct value after all config is read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c
t/t5516-fetch-push.sh