{"thread":{"id":"34863","subject":"[PATCH 0/5] branch: Fix --track on a remote-tracking non-branch","startedAt":"2013-09-06T10:40:37Z","lastAt":"2013-09-08T20:58:15Z","messageCount":15,"participants":["Johan Herland","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"226923","messageId":"1378464042-17476-1-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":null,"subject":"[PATCH 0/5] branch: Fix --track on a remote-tracking non-branch","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:37Z","receivedAt":"2013-09-06T10:40:37Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Hi,\n\nPer Cederqvist alerted me to a change in v1.8.3.2 that broke his\nbuild/test infrastructure. Specifically, before 41c21f2 (branch.c:\nValidate tracking branches with refspecs instead of refs/remotes/*)\nGit allowed a local branch to --track anything within refs/remotes/*,\nand in 41c21f2, I changed the rules to require a configured remote\nwith a matching fetch refspec when setting up the upstream configuration\nvariables (so that there was no ambiguity on how to set\nbranch.<name>.remote and branch.<name>.merge).\n\nSo far so good.\n\nHowever, in addition to requiring a matching remote/refspec, I also\n(for reasons that are still unclear to me) added a requirement that\nthe resulting remote ref name (to be stored into branch.<name>.merge)\nmust start with \"refs/heads/\" (see the last line of\nbranch.c:check_tracking_branch()).\n\nAlthough it is typically the case that an upstream branch is a proper\n(refs/heads/*) branch in the remote repo (which explains why we have\nnot noticed this until now), I think it is _wrong_ of Git to _require_\nthis when configuring the upstream.\n\nPer's setup that triggered this series is described in more detail in\npatch #4/5 (which introduces a testcase illustrating the breakage),\nand the actual fix (which simply removes the extra refs/heads/*\nrequirement on the remote ref) is in patch #5/5.\n\nThe two first patches are unrelated trivial fixes that I encountered\nwhile working on this, and patch #3 is a small documentation update\nsuggested by Per.\n\n...Johan\n\n\nJohan Herland (4):\n  t2024: Fix inconsequential typos\n  t3200: Minor fix when preparing for tracking failure\n  Refer to branch.<name>.remote/merge when documenting --track\n  t3200: Add test demonstrating minor regression in 41c21f2\n\nPer Cederqvist (1):\n  branch.c: Relax unnecessary requirement on upstream's remote ref name\n\n Documentation/git-branch.txt |  6 ++++--\n branch.c                     |  3 +--\n t/t2024-checkout-dwim.sh     |  4 ++--\n t/t3200-branch.sh            | 37 ++++++++++++++++++++++++++++++++++++-\n 4 files changed, 43 insertions(+), 7 deletions(-)\n\n--\n1.8.3.GIT\n"},{"id":"226928","messageId":"1378464042-17476-2-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCH 1/5] t2024: Fix inconsequential typos","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:38Z","receivedAt":"2013-09-06T10:40:38Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Signed-off-by: Johan Herland <johan@herland.net>\n---\n t/t2024-checkout-dwim.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh\nindex dee55e4..6c78fba 100755\n--- a/t/t2024-checkout-dwim.sh\n+++ b/t/t2024-checkout-dwim.sh\n@@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '\n \t\tcd repo_d &&\n \t\ttest_commit d_master &&\n \t\tgit checkout -b baz &&\n-\t\ttest_commit f_baz\n+\t\ttest_commit d_baz\n \t\tgit checkout -b eggs &&\n-\t\ttest_commit c_eggs\n+\t\ttest_commit d_eggs\n \t) &&\n \tgit remote add repo_c repo_c &&\n \tgit config remote.repo_c.fetch \\\n-- \n1.8.3.GIT\n"},{"id":"226924","messageId":"1378464042-17476-3-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCH 2/5] t3200: Minor fix when preparing for tracking failure","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:39Z","receivedAt":"2013-09-06T10:40:39Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"We're testing that trying to --track a ref that is not covered by any remote\nrefspec should fail. For that, we want to have refs/remotes/local/master\npresent, but we also want the remote.local.fetch refspec to NOT match\nrefs/remotes/local/master (so that the tracking setup will fail, as intended).\nHowever, when doing \"git fetch local\" to ensure the existence of\nrefs/remotes/local/master, we must not already have changed remote.local.fetch\nso as to cause refs/remotes/local/master not to be fetched. Therefore, set\nremote.local.fetch to refs/heads/*:refs/remotes/local/* BEFORE we fetch, and\nthen reset it to refs/heads/s:refs/remotes/local/s AFTER we have fetched\n(but before we test --track).\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t3200-branch.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 44ec6a4..8f6ab8e 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -319,8 +319,9 @@ test_expect_success 'test tracking setup (non-wildcard, matching)' '\n \n test_expect_success 'tracking setup fails on non-matching refspec' '\n \tgit config remote.local.url . &&\n-\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n \ttest_must_fail git branch --track my5 local/master &&\n \ttest_must_fail git config branch.my5.remote &&\n \ttest_must_fail git config branch.my5.merge\n-- \n1.8.3.GIT\n"},{"id":"226926","messageId":"1378464042-17476-4-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCH 3/5] Refer to branch.<name>.remote/merge when documenting --track","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:40Z","receivedAt":"2013-09-06T10:40:40Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Make it easier for readers to find the actual config variables that\nimplement the \"upstream\" relationship.\n\nSuggested-by: Per Cederqvist <cederp@opera.com>\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n\nIn a private email exchange, Per noted that it was hard for someone reading\nthe git-branch docs to grasp what really happens when you use --track to\nestablish an \"upstream\" relationship. This adds a couple of references to\nthe config variables involved, and will hopefully make the upstream\nrelationship a little less \"magic\".\n\n...Johan\n\n Documentation/git-branch.txt | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex b7cb625..311b336 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -48,7 +48,8 @@ working tree to it; use \"git checkout <newbranch>\" to switch to the\n new branch.\n\n When a local branch is started off a remote-tracking branch, Git sets up the\n-branch so that 'git pull' will appropriately merge from\n+branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`\n+configuration entries) so that 'git pull' will appropriately merge from\n the remote-tracking branch. This behavior may be changed via the global\n `branch.autosetupmerge` configuration flag. That setting can be\n overridden by using the `--track` and `--no-track` options, and\n@@ -156,7 +157,8 @@ This option is only applicable in non-verbose mode.\n\n -t::\n --track::\n-\tWhen creating a new branch, set up configuration to mark the\n+\tWhen creating a new branch, set up `branch.<name>.remote` and\n+\t`branch.<name>.merge` configuration entries to mark the\n \tstart-point branch as \"upstream\" from the new branch. This\n \tconfiguration will tell git to show the relationship between the\n \ttwo branches in `git status` and `git branch -v`. Furthermore,\n--\n1.8.3.GIT\n"},{"id":"226925","messageId":"1378464042-17476-5-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCH 4/5] t3200: Add test demonstrating minor regression in 41c21f2","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:41Z","receivedAt":"2013-09-06T10:40:41Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"In 41c21f2 (branch.c: Validate tracking branches with refspecs instead of\nrefs/remotes/*), we changed the rules for what is considered a valid tracking\nbranch (a.k.a. upstream branch). We now use the configured remotes and their\nrefspecs to determine whether a proposed tracking branch is in fact within\nthe domain of a remote, and we then use that information to deduce the\nupstream configuration (branch.<name>.remote and branch.<name>.merge).\n\nHowever, with that change, we also check that - in addition to a matching\nrefspec - the result of mapping the tracking branch through that refspec\n(i.e. the corresponding ref name in the remote repo) happens to start with\n\"refs/heads/\". In other words, we require that a tracking branch refers to\na _branch_ in the remote repo.\n\nNow, consider that you are e.g. setting up an automated building/testing\ninfrastructure for a group of similar \"source\" repositories. The build/test\ninfrastructure consists of a central scheduler, and a number of build/test\n\"slave\" machines that perform the actual build/test work. The scheduler\nmonitors the group of similar repos for changes (e.g. with a periodic\n\"git fetch\"), and triggers builds/tests to be run on one or more slaves.\nGraphically the changes flow between the repos like this:\n\n  Source #1 -------v          ----> Slave #1\n                             /\n  Source #2 -----> Scheduler -----> Slave #2\n                             \\\n  Source #3 -------^          ----> Slave #3\n\n        ...                           ...\n\nThe scheduler maintains a single Git repo with each of the source repos set\nup as distinct remotes. The slaves also need access to all the changes from\nall of the source repos, so they pull from the scheduler repo, but using the\nfollowing custom refspec:\n\n  remote.origin.fetch = \"+refs/remotes/*:refs/remotes/*\"\n\nThis makes all of the scheduler's remote-tracking branches automatically\navailable as identical remote-tracking branches in each of the slaves.\n\nNow, consider what happens if a slave tries to create a local branch with\none of the remote-tracking branches as upstream:\n\n  git branch local_branch --track refs/remotes/source-1/some_branch\n\nGit now looks at the configured remotes (in this case there is only \"origin\",\npointing to the scheduler's repo) and sees refs/remotes/source-1/some_branch\nmatching origin's refspec. Mapping through that refspec we find that the\ncorresponding remote ref name is \"refs/remotes/source-1/some_branch\".\nHowever, since this remote ref name does not start with \"refs/heads/\", we\ndiscard it as a suitable upstream, and the whole command fails.\n\nThis patch adds a testcase demonstrating this failure by creating two\nsource repos (\"a\" and \"b\") that are forwarded through a scheduler (\"c\")\nto a slave repo (\"d\"), that then tries create a local branch with an\nupstream. See the next patch in this series for the exciting conclusion\nto this story...\n\nReported-by: Per Cederqvist <cederp@opera.com>\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n\nI was not sure where to place this, so I tacked it onto the end of t3200.\n\nAlso, I wouldn't mind dropping the whole build/test infrastructure story\nfrom the commit message if the rationale for this kind of setup (and this\npatch) can be expressed more concisely.\n\n...Johan\n\n t/t3200-branch.sh | 34 ++++++++++++++++++++++++++++++++++\n 1 file changed, 34 insertions(+)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 8f6ab8e..4031693 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -871,4 +871,38 @@ test_expect_success '--merged catches invalid object names' '\n \ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n '\n\n+test_expect_failure 'tracking with unexpected .fetch refspec' '\n+\tgit init a &&\n+\t(\n+\t\tcd a &&\n+\t\ttest_commit a\n+\t) &&\n+\tgit init b &&\n+\t(\n+\t\tcd b &&\n+\t\ttest_commit b\n+\t) &&\n+\tgit init c &&\n+\t(\n+\t\tcd c &&\n+\t\ttest_commit c &&\n+\t\tgit remote add a ../a &&\n+\t\tgit remote add b ../b &&\n+\t\tgit fetch --all\n+\t) &&\n+\tgit init d &&\n+\t(\n+\t\tcd d &&\n+\t\tgit remote add c ../c &&\n+\t\tgit config remote.c.fetch \"+refs/remotes/*:refs/remotes/*\" &&\n+\t\tgit fetch c &&\n+\t\tgit branch --track local/a/master remotes/a/master &&\n+\t\ttest \"$(git config branch.local/a/master.remote)\" = \"c\" &&\n+\t\ttest \"$(git config branch.local/a/master.merge)\" = \"refs/remotes/a/master\" &&\n+\t\tgit rev-parse --verify a >expect &&\n+\t\tgit rev-parse --verify local/a/master >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_done\n--\n1.8.3.GIT\n"},{"id":"226927","messageId":"1378464042-17476-6-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCH 5/5] branch.c: Relax unnecessary requirement on upstream's remote ref name","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T10:40:42Z","receivedAt":"2013-09-06T10:40:42Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"From: Per Cederqvist <cederp@opera.com>\n\nWhen creating an upstream relationship, we use the configured remotes and\ntheir refspecs to determine the upstream configuration settings\nbranch.<name>.remote and branch.<name>.merge. However, if the matching\nrefspec does not have refs/heads/<something> on the remote side, we end\nup rejecting the match, and failing the upstream configuration.\n\nIt could be argued that when we set up an branch's upstream, we want that\nupstream to also be a proper branch in the remote repo. Although this is\ntypically the common case, there are cases (as demonstrated by the previous\npatch in this series) where this requirement prevents a useful upstream\nrelationship from being formed. Furthermore:\n\n - We have fundamentally no say in how the remote repo have organized its\n   branches. The remote repo may put branches (or branch-like constructs\n   that are insteresting for downstreams to track) outside refs/heads/*.\n\n - The user may intentionally want to track a non-branch from a remote\n   repo, by using a branch and configured upstream in the local repo.\n\nRelaxing the checking to only require a matching remote/refspec allows the\ntestcase introduced in the previous patch to succeed, and has no negative\neffect on the rest of the test suite.\n\nThis patch fixes a behavior (arguably a regression) first introduced in\n41c21f2 (branch.c: Validate tracking branches with refspecs instead of\nrefs/remotes/*) on 2013-04-21 (released in >= v1.8.3.2).\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n\nFTR, Per made the original fix, and I supplied the commit message.\n\n...Johan\n\n branch.c          | 3 +--\n t/t3200-branch.sh | 2 +-\n 2 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex c5c6984..2d15c19 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -203,8 +203,7 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)\n \tstruct refspec query;\n \tmemset(&query, 0, sizeof(struct refspec));\n \tquery.dst = tracking_branch;\n-\treturn !(remote_find_tracking(remote, &query) ||\n-\t\t prefixcmp(query.src, \"refs/heads/\"));\n+\treturn !remote_find_tracking(remote, &query);\n }\n\n static int validate_remote_tracking_branch(char *ref)\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 4031693..f010303 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -871,7 +871,7 @@ test_expect_success '--merged catches invalid object names' '\n \ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n '\n\n-test_expect_failure 'tracking with unexpected .fetch refspec' '\n+test_expect_success 'tracking with unexpected .fetch refspec' '\n \tgit init a &&\n \t(\n \t\tcd a &&\n--\n1.8.3.GIT\n"},{"id":"226958","messageId":"xmqq1u51zwn5.fsf@gitster.dls.corp.google.com","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"Re: [PATCH 0/5] branch: Fix --track on a remote-tracking non-branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-06T17:29:34Z","receivedAt":"2013-09-06T17:29:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> However, in addition to requiring a matching remote/refspec, I also\n> (for reasons that are still unclear to me) added a requirement that\n> the resulting remote ref name (to be stored into branch.<name>.merge)\n> must start with \"refs/heads/\" (see the last line of\n> branch.c:check_tracking_branch()).\n>\n> Although it is typically the case that an upstream branch is a proper\n> (refs/heads/*) branch in the remote repo (which explains why we have\n> not noticed this until now), I think it is _wrong_ of Git to _require_\n> this when configuring the upstream.\n\nYeah, I agree.\n"},{"id":"226959","messageId":"xmqqwqmtyhxs.fsf@gitster.dls.corp.google.com","threadId":"34863","inReplyTo":"1378464042-17476-2-git-send-email-johan@herland.net","subject":"Re: [PATCH 1/5] t2024: Fix inconsequential typos","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-06T17:32:31Z","receivedAt":"2013-09-06T17:32:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> Signed-off-by: Johan Herland <johan@herland.net>\n> ---\n>  t/t2024-checkout-dwim.sh | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh\n> index dee55e4..6c78fba 100755\n> --- a/t/t2024-checkout-dwim.sh\n> +++ b/t/t2024-checkout-dwim.sh\n> @@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '\n>  \t\tcd repo_d &&\n>  \t\ttest_commit d_master &&\n>  \t\tgit checkout -b baz &&\n> -\t\ttest_commit f_baz\n> +\t\ttest_commit d_baz\n\nNot limited to this hunk but there seems to be a breakage in the &&\nchain here.\n\n>  \t\tgit checkout -b eggs &&\n> -\t\ttest_commit c_eggs\n> +\t\ttest_commit d_eggs\n>  \t) &&\n>  \tgit remote add repo_c repo_c &&\n>  \tgit config remote.repo_c.fetch \\\n"},{"id":"226986","messageId":"CALKQrgeyWzV_BxceHL9+NP9nnJXRbTYM1GuuW8aTPpZk-7MEJw@mail.gmail.com","threadId":"34863","inReplyTo":"xmqqwqmtyhxs.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/5] t2024: Fix inconsequential typos","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-06T20:53:04Z","receivedAt":"2013-09-06T20:53:04Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Fri, Sep 6, 2013 at 7:32 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Johan Herland <johan@herland.net> writes:\n>> diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh\n>> index dee55e4..6c78fba 100755\n>> --- a/t/t2024-checkout-dwim.sh\n>> +++ b/t/t2024-checkout-dwim.sh\n>> @@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '\n>>               cd repo_d &&\n>>               test_commit d_master &&\n>>               git checkout -b baz &&\n>> -             test_commit f_baz\n>> +             test_commit d_baz\n>\n> Not limited to this hunk but there seems to be a breakage in the &&\n> chain here.\n\nThanks, found 2 instances in the file (both in that test). Will be\nfixed in the next iteration.\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"227153","messageId":"1378673895-23127-1-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378464042-17476-1-git-send-email-johan@herland.net","subject":"[PATCHv2 0/5] branch: Fix --track on a remote-tracking non-branch","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:10Z","receivedAt":"2013-09-08T20:58:10Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Hi,\n\nHere is the second iteration of this series. Only one change from the\nfirst iteration: The first patch now also fixes some missing &&-chaining\nnoticed by Junio in t2024.\n\n...Johan\n\n\nJohan Herland (4):\n  t2024: Fix &&-chaining and a couple of typos\n  t3200: Minor fix when preparing for tracking failure\n  Refer to branch.<name>.remote/merge when documenting --track\n  t3200: Add test demonstrating minor regression in 41c21f2\n\nPer Cederqvist (1):\n  branch.c: Relax unnecessary requirement on upstream's remote ref name\n\n Documentation/git-branch.txt |  6 ++++--\n branch.c                     |  3 +--\n t/t2024-checkout-dwim.sh     |  6 +++---\n t/t3200-branch.sh            | 37 ++++++++++++++++++++++++++++++++++++-\n 4 files changed, 44 insertions(+), 8 deletions(-)\n\n-- \n1.8.3.GIT\n"},{"id":"227152","messageId":"1378673895-23127-2-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378673895-23127-1-git-send-email-johan@herland.net","subject":"[PATCHv2 1/5] t2024: Fix &&-chaining and a couple of typos","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:11Z","receivedAt":"2013-09-08T20:58:11Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Improved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t2024-checkout-dwim.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh\nindex dee55e4..094b92e 100755\n--- a/t/t2024-checkout-dwim.sh\n+++ b/t/t2024-checkout-dwim.sh\n@@ -104,7 +104,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '\n \t\tcd repo_c &&\n \t\ttest_commit c_master &&\n \t\tgit checkout -b bar &&\n-\t\ttest_commit c_bar\n+\t\ttest_commit c_bar &&\n \t\tgit checkout -b spam &&\n \t\ttest_commit c_spam\n \t) &&\n@@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '\n \t\tcd repo_d &&\n \t\ttest_commit d_master &&\n \t\tgit checkout -b baz &&\n-\t\ttest_commit f_baz\n+\t\ttest_commit d_baz &&\n \t\tgit checkout -b eggs &&\n-\t\ttest_commit c_eggs\n+\t\ttest_commit d_eggs\n \t) &&\n \tgit remote add repo_c repo_c &&\n \tgit config remote.repo_c.fetch \\\n-- \n1.8.3.GIT\n"},{"id":"227156","messageId":"1378673895-23127-3-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378673895-23127-1-git-send-email-johan@herland.net","subject":"[PATCHv2 2/5] t3200: Minor fix when preparing for tracking failure","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:12Z","receivedAt":"2013-09-08T20:58:12Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"We're testing that trying to --track a ref that is not covered by any remote\nrefspec should fail. For that, we want to have refs/remotes/local/master\npresent, but we also want the remote.local.fetch refspec to NOT match\nrefs/remotes/local/master (so that the tracking setup will fail, as intended).\nHowever, when doing \"git fetch local\" to ensure the existence of\nrefs/remotes/local/master, we must not already have changed remote.local.fetch\nso as to cause refs/remotes/local/master not to be fetched. Therefore, set\nremote.local.fetch to refs/heads/*:refs/remotes/local/* BEFORE we fetch, and\nthen reset it to refs/heads/s:refs/remotes/local/s AFTER we have fetched\n(but before we test --track).\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t3200-branch.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 44ec6a4..8f6ab8e 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -319,8 +319,9 @@ test_expect_success 'test tracking setup (non-wildcard, matching)' '\n \n test_expect_success 'tracking setup fails on non-matching refspec' '\n \tgit config remote.local.url . &&\n-\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n \ttest_must_fail git branch --track my5 local/master &&\n \ttest_must_fail git config branch.my5.remote &&\n \ttest_must_fail git config branch.my5.merge\n-- \n1.8.3.GIT\n"},{"id":"227157","messageId":"1378673895-23127-4-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378673895-23127-1-git-send-email-johan@herland.net","subject":"[PATCHv2 3/5] Refer to branch.<name>.remote/merge when documenting --track","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:13Z","receivedAt":"2013-09-08T20:58:13Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Make it easier for readers to find the actual config variables that\nimplement the \"upstream\" relationship.\n\nSuggested-by: Per Cederqvist <cederp@opera.com>\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n Documentation/git-branch.txt | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex b7cb625..311b336 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -48,7 +48,8 @@ working tree to it; use \"git checkout <newbranch>\" to switch to the\n new branch.\n \n When a local branch is started off a remote-tracking branch, Git sets up the\n-branch so that 'git pull' will appropriately merge from\n+branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`\n+configuration entries) so that 'git pull' will appropriately merge from\n the remote-tracking branch. This behavior may be changed via the global\n `branch.autosetupmerge` configuration flag. That setting can be\n overridden by using the `--track` and `--no-track` options, and\n@@ -156,7 +157,8 @@ This option is only applicable in non-verbose mode.\n \n -t::\n --track::\n-\tWhen creating a new branch, set up configuration to mark the\n+\tWhen creating a new branch, set up `branch.<name>.remote` and\n+\t`branch.<name>.merge` configuration entries to mark the\n \tstart-point branch as \"upstream\" from the new branch. This\n \tconfiguration will tell git to show the relationship between the\n \ttwo branches in `git status` and `git branch -v`. Furthermore,\n-- \n1.8.3.GIT\n"},{"id":"227154","messageId":"1378673895-23127-5-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378673895-23127-1-git-send-email-johan@herland.net","subject":"[PATCHv2 4/5] t3200: Add test demonstrating minor regression in 41c21f2","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:14Z","receivedAt":"2013-09-08T20:58:14Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"In 41c21f2 (branch.c: Validate tracking branches with refspecs instead of\nrefs/remotes/*), we changed the rules for what is considered a valid tracking\nbranch (a.k.a. upstream branch). We now use the configured remotes and their\nrefspecs to determine whether a proposed tracking branch is in fact within\nthe domain of a remote, and we then use that information to deduce the\nupstream configuration (branch.<name>.remote and branch.<name>.merge).\n\nHowever, with that change, we also check that - in addition to a matching\nrefspec - the result of mapping the tracking branch through that refspec\n(i.e. the corresponding ref name in the remote repo) happens to start with\n\"refs/heads/\". In other words, we require that a tracking branch refers to\na _branch_ in the remote repo.\n\nNow, consider that you are e.g. setting up an automated building/testing\ninfrastructure for a group of similar \"source\" repositories. The build/test\ninfrastructure consists of a central scheduler, and a number of build/test\n\"slave\" machines that perform the actual build/test work. The scheduler\nmonitors the group of similar repos for changes (e.g. with a periodic\n\"git fetch\"), and triggers builds/tests to be run on one or more slaves.\nGraphically the changes flow between the repos like this:\n\n  Source #1 -------v          ----> Slave #1\n                             /\n  Source #2 -----> Scheduler -----> Slave #2\n                             \\\n  Source #3 -------^          ----> Slave #3\n\n        ...                           ...\n\nThe scheduler maintains a single Git repo with each of the source repos set\nup as distinct remotes. The slaves also need access to all the changes from\nall of the source repos, so they pull from the scheduler repo, but using the\nfollowing custom refspec:\n\n  remote.origin.fetch = \"+refs/remotes/*:refs/remotes/*\"\n\nThis makes all of the scheduler's remote-tracking branches automatically\navailable as identical remote-tracking branches in each of the slaves.\n\nNow, consider what happens if a slave tries to create a local branch with\none of the remote-tracking branches as upstream:\n\n  git branch local_branch --track refs/remotes/source-1/some_branch\n\nGit now looks at the configured remotes (in this case there is only \"origin\",\npointing to the scheduler's repo) and sees refs/remotes/source-1/some_branch\nmatching origin's refspec. Mapping through that refspec we find that the\ncorresponding remote ref name is \"refs/remotes/source-1/some_branch\".\nHowever, since this remote ref name does not start with \"refs/heads/\", we\ndiscard it as a suitable upstream, and the whole command fails.\n\nThis patch adds a testcase demonstrating this failure by creating two\nsource repos (\"a\" and \"b\") that are forwarded through a scheduler (\"c\")\nto a slave repo (\"d\"), that then tries create a local branch with an\nupstream. See the next patch in this series for the exciting conclusion\nto this story...\n\nReported-by: Per Cederqvist <cederp@opera.com>\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t3200-branch.sh | 34 ++++++++++++++++++++++++++++++++++\n 1 file changed, 34 insertions(+)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 8f6ab8e..4031693 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -871,4 +871,38 @@ test_expect_success '--merged catches invalid object names' '\n \ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n '\n \n+test_expect_failure 'tracking with unexpected .fetch refspec' '\n+\tgit init a &&\n+\t(\n+\t\tcd a &&\n+\t\ttest_commit a\n+\t) &&\n+\tgit init b &&\n+\t(\n+\t\tcd b &&\n+\t\ttest_commit b\n+\t) &&\n+\tgit init c &&\n+\t(\n+\t\tcd c &&\n+\t\ttest_commit c &&\n+\t\tgit remote add a ../a &&\n+\t\tgit remote add b ../b &&\n+\t\tgit fetch --all\n+\t) &&\n+\tgit init d &&\n+\t(\n+\t\tcd d &&\n+\t\tgit remote add c ../c &&\n+\t\tgit config remote.c.fetch \"+refs/remotes/*:refs/remotes/*\" &&\n+\t\tgit fetch c &&\n+\t\tgit branch --track local/a/master remotes/a/master &&\n+\t\ttest \"$(git config branch.local/a/master.remote)\" = \"c\" &&\n+\t\ttest \"$(git config branch.local/a/master.merge)\" = \"refs/remotes/a/master\" &&\n+\t\tgit rev-parse --verify a >expect &&\n+\t\tgit rev-parse --verify local/a/master >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_done\n-- \n1.8.3.GIT\n"},{"id":"227155","messageId":"1378673895-23127-6-git-send-email-johan@herland.net","threadId":"34863","inReplyTo":"1378673895-23127-1-git-send-email-johan@herland.net","subject":"[PATCHv2 5/5] branch.c: Relax unnecessary requirement on upstream's remote ref name","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-09-08T20:58:15Z","receivedAt":"2013-09-08T20:58:15Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"From: Per Cederqvist <cederp@opera.com>\n\nWhen creating an upstream relationship, we use the configured remotes and\ntheir refspecs to determine the upstream configuration settings\nbranch.<name>.remote and branch.<name>.merge. However, if the matching\nrefspec does not have refs/heads/<something> on the remote side, we end\nup rejecting the match, and failing the upstream configuration.\n\nIt could be argued that when we set up an branch's upstream, we want that\nupstream to also be a proper branch in the remote repo. Although this is\ntypically the common case, there are cases (as demonstrated by the previous\npatch in this series) where this requirement prevents a useful upstream\nrelationship from being formed. Furthermore:\n\n - We have fundamentally no say in how the remote repo have organized its\n   branches. The remote repo may put branches (or branch-like constructs\n   that are insteresting for downstreams to track) outside refs/heads/*.\n\n - The user may intentionally want to track a non-branch from a remote\n   repo, by using a branch and configured upstream in the local repo.\n\nRelaxing the checking to only require a matching remote/refspec allows the\ntestcase introduced in the previous patch to succeed, and has no negative\neffect on the rest of the test suite.\n\nThis patch fixes a behavior (arguably a regression) first introduced in\n41c21f2 (branch.c: Validate tracking branches with refspecs instead of\nrefs/remotes/*) on 2013-04-21 (released in >= v1.8.3.2).\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n branch.c          | 3 +--\n t/t3200-branch.sh | 2 +-\n 2 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex c5c6984..2d15c19 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -203,8 +203,7 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)\n \tstruct refspec query;\n \tmemset(&query, 0, sizeof(struct refspec));\n \tquery.dst = tracking_branch;\n-\treturn !(remote_find_tracking(remote, &query) ||\n-\t\t prefixcmp(query.src, \"refs/heads/\"));\n+\treturn !remote_find_tracking(remote, &query);\n }\n \n static int validate_remote_tracking_branch(char *ref)\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 4031693..f010303 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -871,7 +871,7 @@ test_expect_success '--merged catches invalid object names' '\n \ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n '\n \n-test_expect_failure 'tracking with unexpected .fetch refspec' '\n+test_expect_success 'tracking with unexpected .fetch refspec' '\n \tgit init a &&\n \t(\n \t\tcd a &&\n-- \n1.8.3.GIT\n"}]}