git/t/t5515
Shawn O. Pearce 85682c1903 Correct handling of branch.$name.merge in builtin-fetch
My prior bug fix for git-push titled "Don't configure remote "." to
fetch everything to itself" actually broke t5520 as we were unable
to evaluate a branch configuration of:

  [branch "copy"]
    remote = .
    merge = refs/heads/master

as remote "." did not have a "remote...fetch" configuration entry to
offer up refs/heads/master as a possible candidate available to be
fetched and merged.  In shell script git-fetch and prior to the above
mentioned commit this was hardcoded for a url of "." to be the set of
local branches.

Chasing down this bug led me to the conclusion that our prior behavior
with regards to branch.$name.merge was incorrect.  In the shell script
based git-fetch implementation we only fetched and merged a branch if
it appeared both in branch.$name.merge *and* in remote.$r.fetch, where
$r = branch.$name.remote.  In other words in the following config file:

  [remote "origin"]
    url = git://git.kernel.org/pub/scm/git/git.git
    fetch = refs/heads/master:refs/remotes/origin/master
  [branch "master"]
    remote = origin
    merge = refs/heads/master
  [branch "pu"]
    remote = origin
    merge = refs/heads/pu

Attempting to run `git pull` while on branch "pu" would always give
the user "Already up-to-date" as git-fetch did not fetch pu and thus
did not mark it for merge in .git/FETCH_HEAD.  The configured merge
would always be ignored and the user would be left scratching her
confused head wondering why merge did not work on "pu" but worked
fine on "master".

If we are using the "default fetch" specification for the current
branch and the current branch has a branch.$name.merge configured
we now union it with the list of refs in remote.$r.fetch.  This
way the above configuration does what the user expects it to do,
which is to fetch only "master" by default but when on "pu" to
fetch both "master" and "pu".

This uncovered some breakage in the test suite where old-style Cogito
branches (.git/branches/$r) did not fetch the branches listed in
.git/config for merging and thus did not actually merge them if the
user tried to use `git pull` on that branch.  Junio and I discussed
it on list and felt that the union approach here makes more sense to
DWIM for the end-user than silently ignoring their configured request
so the test vectors for t5515 have been updated to include for-merge
lines in .git/FETCH_HEAD where they have been configured for-merge
in .git/config.

Since we are now performing a union of the fetch specification and
the merge specification and we cannot allow a branch to be listed
twice (otherwise it comes out twice in .git/FETCH_HEAD) we need to
perform a double loop here over all of the branch.$name.merge lines
and try to set their merge flag if we have already schedule that
branch for fetching by remote.$r.fetch.  If no match is found then
we must add new specifications to fetch the branch but not store it
as no local tracking branch has been designated.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-19 03:22:31 -07:00
..
fetch.br-branches-default t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-branches-default-merge Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-default-merge_branches-default Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-default-octopus Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-default-octopus_branches-default Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-default_branches-default t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-branches-one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-branches-one-merge Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-one-merge_branches-one Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-one-octopus Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-one-octopus_branches-one Correct handling of branch.$name.merge in builtin-fetch 2007-09-19 03:22:31 -07:00
fetch.br-branches-one_branches-one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit-merge t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit-merge_config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit-octopus t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit-octopus_config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-explicit_config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-glob-merge t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-glob-merge_config-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-config-glob-octopus Make fetch a builtin 2007-09-19 03:22:30 -07:00
fetch.br-config-glob-octopus_config-glob Make fetch a builtin 2007-09-19 03:22:30 -07:00
fetch.br-config-glob_config-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit-merge t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit-merge_remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit-octopus t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit-octopus_remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-explicit_remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-glob-merge t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-glob-merge_remote-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-remote-glob-octopus Make fetch a builtin 2007-09-19 03:22:30 -07:00
fetch.br-remote-glob-octopus_remote-glob Make fetch a builtin 2007-09-19 03:22:30 -07:00
fetch.br-remote-glob_remote-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_--tags_.._.git t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_.._.git t/t5515-fetch-merge-logic.sh: Add two more tests 2007-03-07 10:22:44 -08:00
fetch.br-unconfig_.._.git_one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_.._.git_one_two t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_.._.git_tag_tag-one_tag_tag-three t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_branches-default t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_branches-one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_config-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.br-unconfig_remote-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_--tags_.._.git t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_.._.git t/t5515-fetch-merge-logic.sh: Add two more tests 2007-03-07 10:22:44 -08:00
fetch.master_.._.git_one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_.._.git_one_tag_tag-one_tag_tag-three-file t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_.._.git_one_two t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_.._.git_tag_tag-one-tree_tag_tag-three-file t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_.._.git_tag_tag-one_tag_tag-three t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_branches-default t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_branches-one t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_config-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_config-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_remote-explicit t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00
fetch.master_remote-glob t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch 2007-03-05 00:27:37 -08:00