{"thread":{"id":"29249","subject":"FETCH_HEAD documentation vs reality","startedAt":"2011-12-25T17:39:01Z","lastAt":"2012-01-04T00:12:39Z","messageCount":7,"participants":["Joey Hess","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"181690","messageId":"20111225173901.GA668@gnu.kitenet.net","threadId":"29249","inReplyTo":null,"subject":"FETCH_HEAD documentation vs reality","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2011-12-25T17:39:01Z","receivedAt":"2011-12-25T17:39:01Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"While trying to find some documentation of the format of .git/FETCH_HEAD,\nI found this example in git-read-tree.txt, which I think will no longer\nwork. Probably when this was written, .git/FETCH_HEAD contained only a single\nSHA; it's much more complicated now.\n\n        $ JC=`git rev-parse --verify \"HEAD^0\"`\n        $ git checkout-index -f -u -a $JC\n        ...\n        $ git fetch git://.... linus\n        $ LT=`cat .git/FETCH_HEAD`\n        ...\n        $ git read-tree -m -u `git merge-base $JC $LT` $JC $LT\n\nIt's also common for the first line of .git/FETCH_HEAD to be an\narbitrary branch that was fetched (as part of an unqualified \"git\npull\"), marked not-for-merge. So using \"FETCH_HEAD\" as a refname will\nrefer to such a branch unintentionally. There are several places in the\ndocs that seem to expect FETCH_HEAD to always refer to the one that was\nfetched and will be merged (ie, master):\n\nrevisions.txt:\n\n\t'FETCH_HEAD' records the branch which you fetched from a remote repository\n\twith your last `git fetch` invocation.\n\ngit-pull.txt:\n\n\tIn its default mode, `git pull` is shorthand for\n\t`git fetch` followed by `git merge FETCH_HEAD`.\n\ngittutorial.txt:\n\n\talice$ git log -p HEAD..FETCH_HEAD\n\t$ gitk HEAD..FETCH_HEAD\n\nhowto/rebase-from-internal-branch.txt:\n\n\tYou fetch from upstream, but not merge.\n\t\n\t    $ git fetch upstream\n\t\n\tThis leaves the updated upstream head in .git/FETCH_HEAD but\n\tdoes not touch your .git/HEAD nor .git/refs/heads/master.\n\tYou run \"git rebase\" now.\n\t\n\t    $ git rebase FETCH_HEAD master\n\nAll this documentation could be changed, or resolve_ref_unsafe in refs.c\ncould be changed to have a special case parser for .git/FETCH_HEAD,\nthat finds the first branch that is marked for merge, where it now has\nthis minor special case for it:\n\n        /* Please note that FETCH_HEAD has a second line containing other data. */\n        if (get_sha1_hex(buffer, sha1) || (buffer[40] != '\\0' && !isspace(buffer[40]))) {\n\nOr yet another way to fix it would be to make git fetch always write the\nintended FETCH_HEAD first into .git/FETCH_HEAD. (When not in --append mode.)\nThis seems like perhaps the best fix, although it does mean that if a\nfetch is done of only not-for-merge refs, without --append, FETCH_HEAD\nwill still refer to one of them. \n\nI've attached a minimal proof-of-concept patch implementing this last\noption.\n\n-- \nsee shy jo\n\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 33ad3aa..e2f2c69 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -376,6 +376,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \tstruct strbuf note = STRBUF_INIT;\n \tconst char *what, *kind;\n \tstruct ref *rm;\n+\tint top = 1;\n \tchar *url, *filename = dry_run ? \"/dev/null\" : git_path(\"FETCH_HEAD\");\n \n \tfp = fopen(filename, \"a\");\n@@ -393,6 +394,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\tgoto abort;\n \t}\n \n+ write:\n \tfor (rm = ref_map; rm; rm = rm->next) {\n \t\tstruct ref *ref = NULL;\n \n@@ -408,6 +410,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\tif (!commit)\n \t\t\trm->merge = 0;\n \n+\t\tif (top != rm->merge)\n+\t\t\tcontinue;\n+\n \t\tif (!strcmp(rm->name, \"HEAD\")) {\n \t\t\tkind = \"\";\n \t\t\twhat = \"\";\n@@ -474,6 +479,11 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t}\n \t}\n \n+\tif (top) {\n+\t\ttop = 0;\n+\t\tgoto write;\n+\t}\n+\n \tif (rc & STORE_REF_ERROR_DF_CONFLICT)\n \t\terror(_(\"some local refs could not be updated; try running\\n\"\n \t\t      \" 'git remote prune %s' to remove any old, conflicting \"\n"},{"id":"181700","messageId":"7vd3bb929n.fsf@alter.siamese.dyndns.org","threadId":"29249","inReplyTo":"20111225173901.GA668@gnu.kitenet.net","subject":"Re: FETCH_HEAD documentation vs reality","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-26T08:16:04Z","receivedAt":"2011-12-26T08:16:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joey Hess <joey@kitenet.net> writes:\n\n> Or yet another way to fix it would be to make git fetch always write the\n> intended FETCH_HEAD first into .git/FETCH_HEAD. (When not in --append mode.)\n> This seems like perhaps the best fix,...\n\nSounds good, if you mean \"the first one that is marked as for-merge\" by\n\"intended FETCH_HEAD\".\n\nThanks. Please make it so.\n"},{"id":"181705","messageId":"20111226161656.GB29582@gnu.kitenet.net","threadId":"29249","inReplyTo":"7vd3bb929n.fsf@alter.siamese.dyndns.org","subject":"[PATCH] write first for-merge ref to FETCH_HEAD first","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2011-12-26T16:16:56Z","receivedAt":"2011-12-26T16:16:56Z","isPatch":true,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"The FETCH_HEAD refname is supposed to refer to the ref that was fetched\nand should be merged. However all fetched refs are written to\n.git/FETCH_HEAD in an arbitrary order, and resolve_ref_unsafe simply\ntakes the first ref as the FETCH_HEAD, which is often the wrong one,\nwhen other branches were also fetched.\n\nThe solution is to write the for-merge ref(s) to FETCH_HEAD first.\nThen, unless --append is used, the FETCH_HEAD refname behaves as intended.\nIf the user uses --append, they presumably are doing so in order to\npreserve the old FETCH_HEAD.\n\nAlso included a fix to documentation that assumes FETCH_HEAD contains\nonly a single ref.\n---\n Documentation/git-read-tree.txt |    2 +-\n builtin/fetch.c                 |  158 +++++++++++++++++++++------------------\n 2 files changed, 85 insertions(+), 75 deletions(-)\n\ndiff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt\nindex 5375549..2d3ff23 100644\n--- a/Documentation/git-read-tree.txt\n+++ b/Documentation/git-read-tree.txt\n@@ -342,7 +342,7 @@ since you pulled from him:\n \n ----------------\n $ git fetch git://.... linus\n-$ LT=`cat .git/FETCH_HEAD`\n+$ LT=`git rev-parse FETCH_HEAD`\n ----------------\n \n Your work tree is still based on your HEAD ($JC), but you have\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 33ad3aa..db565cd 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -377,6 +377,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \tconst char *what, *kind;\n \tstruct ref *rm;\n \tchar *url, *filename = dry_run ? \"/dev/null\" : git_path(\"FETCH_HEAD\");\n+\tsigned int want_merge;\n \n \tfp = fopen(filename, \"a\");\n \tif (!fp)\n@@ -393,84 +394,93 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\tgoto abort;\n \t}\n \n-\tfor (rm = ref_map; rm; rm = rm->next) {\n-\t\tstruct ref *ref = NULL;\n-\n-\t\tif (rm->peer_ref) {\n-\t\t\tref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);\n-\t\t\tstrcpy(ref->name, rm->peer_ref->name);\n-\t\t\thashcpy(ref->old_sha1, rm->peer_ref->old_sha1);\n-\t\t\thashcpy(ref->new_sha1, rm->old_sha1);\n-\t\t\tref->force = rm->peer_ref->force;\n-\t\t}\n+\t/* Two passes are made over the ref_map, to write merge refs\n+\t * to FETCH_HEAD first. This allows using FETCH_HEAD as a refname\n+\t * to refer to the ref to be merged. */\n+\tfor (want_merge = 1; want_merge >= 0 ; want_merge--) {\n+\t\tfor (rm = ref_map; rm; rm = rm->next) {\n+\t\t\tstruct ref *ref = NULL;\n+\n+\t\t\tcommit = lookup_commit_reference_gently(rm->old_sha1, 1);\n+\t\t\tif (!commit)\n+\t\t\t\trm->merge = 0;\n+\n+\t\t\tif (rm->merge != want_merge)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (rm->peer_ref) {\n+\t\t\t\tref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);\n+\t\t\t\tstrcpy(ref->name, rm->peer_ref->name);\n+\t\t\t\thashcpy(ref->old_sha1, rm->peer_ref->old_sha1);\n+\t\t\t\thashcpy(ref->new_sha1, rm->old_sha1);\n+\t\t\t\tref->force = rm->peer_ref->force;\n+\t\t\t}\n \n-\t\tcommit = lookup_commit_reference_gently(rm->old_sha1, 1);\n-\t\tif (!commit)\n-\t\t\trm->merge = 0;\n \n-\t\tif (!strcmp(rm->name, \"HEAD\")) {\n-\t\t\tkind = \"\";\n-\t\t\twhat = \"\";\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/heads/\")) {\n-\t\t\tkind = \"branch\";\n-\t\t\twhat = rm->name + 11;\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/tags/\")) {\n-\t\t\tkind = \"tag\";\n-\t\t\twhat = rm->name + 10;\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/remotes/\")) {\n-\t\t\tkind = \"remote-tracking branch\";\n-\t\t\twhat = rm->name + 13;\n-\t\t}\n-\t\telse {\n-\t\t\tkind = \"\";\n-\t\t\twhat = rm->name;\n-\t\t}\n+\t\t\tif (!strcmp(rm->name, \"HEAD\")) {\n+\t\t\t\tkind = \"\";\n+\t\t\t\twhat = \"\";\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/heads/\")) {\n+\t\t\t\tkind = \"branch\";\n+\t\t\t\twhat = rm->name + 11;\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/tags/\")) {\n+\t\t\t\tkind = \"tag\";\n+\t\t\t\twhat = rm->name + 10;\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/remotes/\")) {\n+\t\t\t\tkind = \"remote-tracking branch\";\n+\t\t\t\twhat = rm->name + 13;\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\tkind = \"\";\n+\t\t\t\twhat = rm->name;\n+\t\t\t}\n \n-\t\turl_len = strlen(url);\n-\t\tfor (i = url_len - 1; url[i] == '/' && 0 <= i; i--)\n-\t\t\t;\n-\t\turl_len = i + 1;\n-\t\tif (4 < i && !strncmp(\".git\", url + i - 3, 4))\n-\t\t\turl_len = i - 3;\n-\n-\t\tstrbuf_reset(&note);\n-\t\tif (*what) {\n-\t\t\tif (*kind)\n-\t\t\t\tstrbuf_addf(&note, \"%s \", kind);\n-\t\t\tstrbuf_addf(&note, \"'%s' of \", what);\n-\t\t}\n-\t\tfprintf(fp, \"%s\\t%s\\t%s\",\n-\t\t\tsha1_to_hex(rm->old_sha1),\n-\t\t\trm->merge ? \"\" : \"not-for-merge\",\n-\t\t\tnote.buf);\n-\t\tfor (i = 0; i < url_len; ++i)\n-\t\t\tif ('\\n' == url[i])\n-\t\t\t\tfputs(\"\\\\n\", fp);\n-\t\t\telse\n-\t\t\t\tfputc(url[i], fp);\n-\t\tfputc('\\n', fp);\n-\n-\t\tstrbuf_reset(&note);\n-\t\tif (ref) {\n-\t\t\trc |= update_local_ref(ref, what, &note);\n-\t\t\tfree(ref);\n-\t\t} else\n-\t\t\tstrbuf_addf(&note, \"* %-*s %-*s -> FETCH_HEAD\",\n-\t\t\t\t    TRANSPORT_SUMMARY_WIDTH,\n-\t\t\t\t    *kind ? kind : \"branch\",\n-\t\t\t\t    REFCOL_WIDTH,\n-\t\t\t\t    *what ? what : \"HEAD\");\n-\t\tif (note.len) {\n-\t\t\tif (verbosity >= 0 && !shown_url) {\n-\t\t\t\tfprintf(stderr, _(\"From %.*s\\n\"),\n-\t\t\t\t\t\turl_len, url);\n-\t\t\t\tshown_url = 1;\n+\t\t\turl_len = strlen(url);\n+\t\t\tfor (i = url_len - 1; url[i] == '/' && 0 <= i; i--)\n+\t\t\t\t;\n+\t\t\turl_len = i + 1;\n+\t\t\tif (4 < i && !strncmp(\".git\", url + i - 3, 4))\n+\t\t\t\turl_len = i - 3;\n+\n+\t\t\tstrbuf_reset(&note);\n+\t\t\tif (*what) {\n+\t\t\t\tif (*kind)\n+\t\t\t\t\tstrbuf_addf(&note, \"%s \", kind);\n+\t\t\t\tstrbuf_addf(&note, \"'%s' of \", what);\n+\t\t\t}\n+\t\t\tfprintf(fp, \"%s\\t%s\\t%s\",\n+\t\t\t\tsha1_to_hex(rm->old_sha1),\n+\t\t\t\trm->merge ? \"\" : \"not-for-merge\",\n+\t\t\t\tnote.buf);\n+\t\t\tfor (i = 0; i < url_len; ++i)\n+\t\t\t\tif ('\\n' == url[i])\n+\t\t\t\t\tfputs(\"\\\\n\", fp);\n+\t\t\t\telse\n+\t\t\t\t\tfputc(url[i], fp);\n+\t\t\tfputc('\\n', fp);\n+\n+\t\t\tstrbuf_reset(&note);\n+\t\t\tif (ref) {\n+\t\t\t\trc |= update_local_ref(ref, what, &note);\n+\t\t\t\tfree(ref);\n+\t\t\t} else\n+\t\t\t\tstrbuf_addf(&note, \"* %-*s %-*s -> FETCH_HEAD\",\n+\t\t\t\t\t    TRANSPORT_SUMMARY_WIDTH,\n+\t\t\t\t\t    *kind ? kind : \"branch\",\n+\t\t\t\t\t    REFCOL_WIDTH,\n+\t\t\t\t\t    *what ? what : \"HEAD\");\n+\t\t\tif (note.len) {\n+\t\t\t\tif (verbosity >= 0 && !shown_url) {\n+\t\t\t\t\tfprintf(stderr, _(\"From %.*s\\n\"),\n+\t\t\t\t\t\t\turl_len, url);\n+\t\t\t\t\tshown_url = 1;\n+\t\t\t\t}\n+\t\t\t\tif (verbosity >= 0)\n+\t\t\t\t\tfprintf(stderr, \" %s\\n\", note.buf);\n \t\t\t}\n-\t\t\tif (verbosity >= 0)\n-\t\t\t\tfprintf(stderr, \" %s\\n\", note.buf);\n \t\t}\n \t}\n \n-- \n1.7.7.3\n\n"},{"id":"181725","messageId":"7v1urp97mp.fsf@alter.siamese.dyndns.org","threadId":"29249","inReplyTo":"20111226161656.GB29582@gnu.kitenet.net","subject":"Re: [PATCH] write first for-merge ref to FETCH_HEAD first","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-27T18:44:46Z","receivedAt":"2011-12-27T18:44:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joey Hess <joey@kitenet.net> writes:\n\n> The FETCH_HEAD refname is supposed to refer to the ref that was fetched\n> and should be merged. However all fetched refs are written to\n> .git/FETCH_HEAD in an arbitrary order, and resolve_ref_unsafe simply\n> takes the first ref as the FETCH_HEAD, which is often the wrong one,\n> when other branches were also fetched.\n>\n> The solution is to write the for-merge ref(s) to FETCH_HEAD first.\n> Then, unless --append is used, the FETCH_HEAD refname behaves as intended.\n> If the user uses --append, they presumably are doing so in order to\n> preserve the old FETCH_HEAD.\n>\n> Also included a fix to documentation that assumes FETCH_HEAD contains\n> only a single ref.\n\nThat \"single ref\" assumption is perfectly fine for the part of the\ndocumentation you patched, actually. The \"fetch\" command-line the example\nshows explicitly fetches a single ref.\n\nIt is a good idea to use rev-parse anyway, so the patch itself is good. A\npotential problem of that example (I haven't re-tried these examples for\neons since they were written) comes from the fact that FETCH_HEAD contains\nnot just the object name of what we fetched, but also other information to\ndescribe what happened to that fetched object.\n\n> ---\n\nSign-off?\n\n>  Documentation/git-read-tree.txt |    2 +-\n>  builtin/fetch.c                 |  158 +++++++++++++++++++++------------------\n>  2 files changed, 85 insertions(+), 75 deletions(-)\n"},{"id":"181902","messageId":"7v7h18s5kg.fsf@alter.siamese.dyndns.org","threadId":"29249","inReplyTo":"7v1urp97mp.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] write first for-merge ref to FETCH_HEAD first","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-03T23:57:03Z","receivedAt":"2012-01-03T23:57:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Joey Hess <joey@kitenet.net> writes:\n>\n>> The FETCH_HEAD refname is supposed to refer to the ref that was fetched\n>> and should be merged. However all fetched refs are written to\n>> .git/FETCH_HEAD in an arbitrary order, and resolve_ref_unsafe simply\n>> takes the first ref as the FETCH_HEAD, which is often the wrong one,\n>> when other branches were also fetched.\n>>\n>> The solution is to write the for-merge ref(s) to FETCH_HEAD first.\n>> ...\n>\n> Sign-off?\n\nPing? I think this is a good change to go in before 1.7.9.\n\nThe change broke quite a lot of tests, and I think I've fixed them all.\n\n-- >8 --\nFrom: Joey Hess <joey@kitenet.net>\nDate: Mon, 26 Dec 2011 12:16:56 -0400\nSubject: [PATCH] write first for-merge ref to FETCH_HEAD first\n\nThe FETCH_HEAD refname is supposed to refer to the ref that was fetched\nand should be merged. However all fetched refs are written to\n.git/FETCH_HEAD in an arbitrary order, and resolve_ref_unsafe simply\ntakes the first ref as the FETCH_HEAD, which is often the wrong one,\nwhen other branches were also fetched.\n\nThe solution is to write the for-merge ref(s) to FETCH_HEAD first.\nThen, unless --append is used, the FETCH_HEAD refname behaves as intended.\nIf the user uses --append, they presumably are doing so in order to\npreserve the old FETCH_HEAD.\n\nWhile we are at it, update an old example in the read-tree documentation\nthat implied that each entry in FETCH_HEAD only has the object name, which\nis not true for quite a while.\n---\n Documentation/git-read-tree.txt                    |    2 +-\n builtin/fetch.c                                    |  160 +++++++++++---------\n t/t5510-fetch.sh                                   |    2 +-\n t/t5515/fetch.br-branches-default-merge            |    2 +-\n ...etch.br-branches-default-merge_branches-default |    2 +-\n t/t5515/fetch.br-branches-default-octopus          |    2 +-\n ...ch.br-branches-default-octopus_branches-default |    2 +-\n t/t5515/fetch.br-branches-one-merge                |    2 +-\n t/t5515/fetch.br-branches-one-merge_branches-one   |    2 +-\n t/t5515/fetch.br-config-explicit-merge             |    2 +-\n .../fetch.br-config-explicit-merge_config-explicit |    2 +-\n t/t5515/fetch.br-config-explicit-octopus           |    2 +-\n ...etch.br-config-explicit-octopus_config-explicit |    2 +-\n t/t5515/fetch.br-config-glob-merge                 |    2 +-\n t/t5515/fetch.br-config-glob-merge_config-glob     |    2 +-\n t/t5515/fetch.br-config-glob-octopus               |    4 +-\n t/t5515/fetch.br-config-glob-octopus_config-glob   |    4 +-\n t/t5515/fetch.br-remote-explicit-merge             |    2 +-\n .../fetch.br-remote-explicit-merge_remote-explicit |    2 +-\n t/t5515/fetch.br-remote-explicit-octopus           |    2 +-\n ...etch.br-remote-explicit-octopus_remote-explicit |    2 +-\n t/t5515/fetch.br-remote-glob-merge                 |    2 +-\n t/t5515/fetch.br-remote-glob-merge_remote-glob     |    2 +-\n t/t5515/fetch.br-remote-glob-octopus               |    4 +-\n t/t5515/fetch.br-remote-glob-octopus_remote-glob   |    4 +-\n 25 files changed, 114 insertions(+), 102 deletions(-)\n\ndiff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt\nindex 5375549..2d3ff23 100644\n--- a/Documentation/git-read-tree.txt\n+++ b/Documentation/git-read-tree.txt\n@@ -342,7 +342,7 @@ since you pulled from him:\n \n ----------------\n $ git fetch git://.... linus\n-$ LT=`cat .git/FETCH_HEAD`\n+$ LT=`git rev-parse FETCH_HEAD`\n ----------------\n \n Your work tree is still based on your HEAD ($JC), but you have\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 33ad3aa..0481c16 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -377,6 +377,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \tconst char *what, *kind;\n \tstruct ref *rm;\n \tchar *url, *filename = dry_run ? \"/dev/null\" : git_path(\"FETCH_HEAD\");\n+\tint want_merge;\n \n \tfp = fopen(filename, \"a\");\n \tif (!fp)\n@@ -393,84 +394,95 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\tgoto abort;\n \t}\n \n-\tfor (rm = ref_map; rm; rm = rm->next) {\n-\t\tstruct ref *ref = NULL;\n-\n-\t\tif (rm->peer_ref) {\n-\t\t\tref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);\n-\t\t\tstrcpy(ref->name, rm->peer_ref->name);\n-\t\t\thashcpy(ref->old_sha1, rm->peer_ref->old_sha1);\n-\t\t\thashcpy(ref->new_sha1, rm->old_sha1);\n-\t\t\tref->force = rm->peer_ref->force;\n-\t\t}\n+\t/*\n+\t * The first pass writes objects to be merged and then the\n+\t * second pass writes the rest, in order to allow using\n+\t * FETCH_HEAD as a refname to refer to the ref to be merged.\n+\t */\n+\tfor (want_merge = 1; 0 <= want_merge; want_merge--) {\n+\t\tfor (rm = ref_map; rm; rm = rm->next) {\n+\t\t\tstruct ref *ref = NULL;\n+\n+\t\t\tcommit = lookup_commit_reference_gently(rm->old_sha1, 1);\n+\t\t\tif (!commit)\n+\t\t\t\trm->merge = 0;\n+\n+\t\t\tif (rm->merge != want_merge)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (rm->peer_ref) {\n+\t\t\t\tref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);\n+\t\t\t\tstrcpy(ref->name, rm->peer_ref->name);\n+\t\t\t\thashcpy(ref->old_sha1, rm->peer_ref->old_sha1);\n+\t\t\t\thashcpy(ref->new_sha1, rm->old_sha1);\n+\t\t\t\tref->force = rm->peer_ref->force;\n+\t\t\t}\n \n-\t\tcommit = lookup_commit_reference_gently(rm->old_sha1, 1);\n-\t\tif (!commit)\n-\t\t\trm->merge = 0;\n \n-\t\tif (!strcmp(rm->name, \"HEAD\")) {\n-\t\t\tkind = \"\";\n-\t\t\twhat = \"\";\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/heads/\")) {\n-\t\t\tkind = \"branch\";\n-\t\t\twhat = rm->name + 11;\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/tags/\")) {\n-\t\t\tkind = \"tag\";\n-\t\t\twhat = rm->name + 10;\n-\t\t}\n-\t\telse if (!prefixcmp(rm->name, \"refs/remotes/\")) {\n-\t\t\tkind = \"remote-tracking branch\";\n-\t\t\twhat = rm->name + 13;\n-\t\t}\n-\t\telse {\n-\t\t\tkind = \"\";\n-\t\t\twhat = rm->name;\n-\t\t}\n+\t\t\tif (!strcmp(rm->name, \"HEAD\")) {\n+\t\t\t\tkind = \"\";\n+\t\t\t\twhat = \"\";\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/heads/\")) {\n+\t\t\t\tkind = \"branch\";\n+\t\t\t\twhat = rm->name + 11;\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/tags/\")) {\n+\t\t\t\tkind = \"tag\";\n+\t\t\t\twhat = rm->name + 10;\n+\t\t\t}\n+\t\t\telse if (!prefixcmp(rm->name, \"refs/remotes/\")) {\n+\t\t\t\tkind = \"remote-tracking branch\";\n+\t\t\t\twhat = rm->name + 13;\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\tkind = \"\";\n+\t\t\t\twhat = rm->name;\n+\t\t\t}\n \n-\t\turl_len = strlen(url);\n-\t\tfor (i = url_len - 1; url[i] == '/' && 0 <= i; i--)\n-\t\t\t;\n-\t\turl_len = i + 1;\n-\t\tif (4 < i && !strncmp(\".git\", url + i - 3, 4))\n-\t\t\turl_len = i - 3;\n-\n-\t\tstrbuf_reset(&note);\n-\t\tif (*what) {\n-\t\t\tif (*kind)\n-\t\t\t\tstrbuf_addf(&note, \"%s \", kind);\n-\t\t\tstrbuf_addf(&note, \"'%s' of \", what);\n-\t\t}\n-\t\tfprintf(fp, \"%s\\t%s\\t%s\",\n-\t\t\tsha1_to_hex(rm->old_sha1),\n-\t\t\trm->merge ? \"\" : \"not-for-merge\",\n-\t\t\tnote.buf);\n-\t\tfor (i = 0; i < url_len; ++i)\n-\t\t\tif ('\\n' == url[i])\n-\t\t\t\tfputs(\"\\\\n\", fp);\n-\t\t\telse\n-\t\t\t\tfputc(url[i], fp);\n-\t\tfputc('\\n', fp);\n-\n-\t\tstrbuf_reset(&note);\n-\t\tif (ref) {\n-\t\t\trc |= update_local_ref(ref, what, &note);\n-\t\t\tfree(ref);\n-\t\t} else\n-\t\t\tstrbuf_addf(&note, \"* %-*s %-*s -> FETCH_HEAD\",\n-\t\t\t\t    TRANSPORT_SUMMARY_WIDTH,\n-\t\t\t\t    *kind ? kind : \"branch\",\n-\t\t\t\t    REFCOL_WIDTH,\n-\t\t\t\t    *what ? what : \"HEAD\");\n-\t\tif (note.len) {\n-\t\t\tif (verbosity >= 0 && !shown_url) {\n-\t\t\t\tfprintf(stderr, _(\"From %.*s\\n\"),\n-\t\t\t\t\t\turl_len, url);\n-\t\t\t\tshown_url = 1;\n+\t\t\turl_len = strlen(url);\n+\t\t\tfor (i = url_len - 1; url[i] == '/' && 0 <= i; i--)\n+\t\t\t\t;\n+\t\t\turl_len = i + 1;\n+\t\t\tif (4 < i && !strncmp(\".git\", url + i - 3, 4))\n+\t\t\t\turl_len = i - 3;\n+\n+\t\t\tstrbuf_reset(&note);\n+\t\t\tif (*what) {\n+\t\t\t\tif (*kind)\n+\t\t\t\t\tstrbuf_addf(&note, \"%s \", kind);\n+\t\t\t\tstrbuf_addf(&note, \"'%s' of \", what);\n+\t\t\t}\n+\t\t\tfprintf(fp, \"%s\\t%s\\t%s\",\n+\t\t\t\tsha1_to_hex(rm->old_sha1),\n+\t\t\t\trm->merge ? \"\" : \"not-for-merge\",\n+\t\t\t\tnote.buf);\n+\t\t\tfor (i = 0; i < url_len; ++i)\n+\t\t\t\tif ('\\n' == url[i])\n+\t\t\t\t\tfputs(\"\\\\n\", fp);\n+\t\t\t\telse\n+\t\t\t\t\tfputc(url[i], fp);\n+\t\t\tfputc('\\n', fp);\n+\n+\t\t\tstrbuf_reset(&note);\n+\t\t\tif (ref) {\n+\t\t\t\trc |= update_local_ref(ref, what, &note);\n+\t\t\t\tfree(ref);\n+\t\t\t} else\n+\t\t\t\tstrbuf_addf(&note, \"* %-*s %-*s -> FETCH_HEAD\",\n+\t\t\t\t\t    TRANSPORT_SUMMARY_WIDTH,\n+\t\t\t\t\t    *kind ? kind : \"branch\",\n+\t\t\t\t\t    REFCOL_WIDTH,\n+\t\t\t\t\t    *what ? what : \"HEAD\");\n+\t\t\tif (note.len) {\n+\t\t\t\tif (verbosity >= 0 && !shown_url) {\n+\t\t\t\t\tfprintf(stderr, _(\"From %.*s\\n\"),\n+\t\t\t\t\t\t\turl_len, url);\n+\t\t\t\t\tshown_url = 1;\n+\t\t\t\t}\n+\t\t\t\tif (verbosity >= 0)\n+\t\t\t\t\tfprintf(stderr, \" %s\\n\", note.buf);\n \t\t\t}\n-\t\t\tif (verbosity >= 0)\n-\t\t\t\tfprintf(stderr, \" %s\\n\", note.buf);\n \t\t}\n \t}\n \ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex e88dbd5..79ee913 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -70,8 +70,8 @@ test_expect_success \"fetch test for-merge\" '\n \tmaster_in_two=`cd ../two && git rev-parse master` &&\n \tone_in_two=`cd ../two && git rev-parse one` &&\n \t{\n-\t\techo \"$master_in_two\tnot-for-merge\"\n \t\techo \"$one_in_two\t\"\n+\t\techo \"$master_in_two\tnot-for-merge\"\n \t} >expected &&\n \tcut -f -2 .git/FETCH_HEAD >actual &&\n \ttest_cmp expected actual'\ndiff --git a/t/t5515/fetch.br-branches-default-merge b/t/t5515/fetch.br-branches-default-merge\nindex e3a41ae..12ab08e 100644\n--- a/t/t5515/fetch.br-branches-default-merge\n+++ b/t/t5515/fetch.br-branches-default-merge\n@@ -1,6 +1,6 @@\n # br-branches-default-merge\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-branches-default-merge_branches-default b/t/t5515/fetch.br-branches-default-merge_branches-default\nindex 1f60561..5442752 100644\n--- a/t/t5515/fetch.br-branches-default-merge_branches-default\n+++ b/t/t5515/fetch.br-branches-default-merge_branches-default\n@@ -1,6 +1,6 @@\n # br-branches-default-merge branches-default\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-branches-default-octopus b/t/t5515/fetch.br-branches-default-octopus\nindex f31e1b3..498a761 100644\n--- a/t/t5515/fetch.br-branches-default-octopus\n+++ b/t/t5515/fetch.br-branches-default-octopus\n@@ -1,7 +1,7 @@\n # br-branches-default-octopus\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-branches-default-octopus_branches-default b/t/t5515/fetch.br-branches-default-octopus_branches-default\nindex 7060bd9..0857f13 100644\n--- a/t/t5515/fetch.br-branches-default-octopus_branches-default\n+++ b/t/t5515/fetch.br-branches-default-octopus_branches-default\n@@ -1,7 +1,7 @@\n # br-branches-default-octopus branches-default\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-branches-one-merge b/t/t5515/fetch.br-branches-one-merge\nindex aa1c8a9..54a7742 100644\n--- a/t/t5515/fetch.br-branches-one-merge\n+++ b/t/t5515/fetch.br-branches-one-merge\n@@ -1,6 +1,6 @@\n # br-branches-one-merge\n-8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-branches-one-merge_branches-one b/t/t5515/fetch.br-branches-one-merge_branches-one\nindex c93310a..b4d1bb0 100644\n--- a/t/t5515/fetch.br-branches-one-merge_branches-one\n+++ b/t/t5515/fetch.br-branches-one-merge_branches-one\n@@ -1,6 +1,6 @@\n # br-branches-one-merge branches-one\n-8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-config-explicit-merge b/t/t5515/fetch.br-config-explicit-merge\nindex f6475b7..5ce764a 100644\n--- a/t/t5515/fetch.br-config-explicit-merge\n+++ b/t/t5515/fetch.br-config-explicit-merge\n@@ -1,8 +1,8 @@\n # br-config-explicit-merge\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-config-explicit-merge_config-explicit b/t/t5515/fetch.br-config-explicit-merge_config-explicit\nindex 018bdd7..b1152b7 100644\n--- a/t/t5515/fetch.br-config-explicit-merge_config-explicit\n+++ b/t/t5515/fetch.br-config-explicit-merge_config-explicit\n@@ -1,8 +1,8 @@\n # br-config-explicit-merge config-explicit\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-config-explicit-octopus b/t/t5515/fetch.br-config-explicit-octopus\nindex 36d0270..110577b 100644\n--- a/t/t5515/fetch.br-config-explicit-octopus\n+++ b/t/t5515/fetch.br-config-explicit-octopus\n@@ -1,7 +1,7 @@\n # br-config-explicit-octopus\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-config-explicit-octopus_config-explicit b/t/t5515/fetch.br-config-explicit-octopus_config-explicit\nindex 6654ad0..a29dd8b 100644\n--- a/t/t5515/fetch.br-config-explicit-octopus_config-explicit\n+++ b/t/t5515/fetch.br-config-explicit-octopus_config-explicit\n@@ -1,7 +1,7 @@\n # br-config-explicit-octopus config-explicit\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-config-glob-merge b/t/t5515/fetch.br-config-glob-merge\nindex 8bb5e8b..89f2596 100644\n--- a/t/t5515/fetch.br-config-glob-merge\n+++ b/t/t5515/fetch.br-config-glob-merge\n@@ -1,7 +1,7 @@\n # br-config-glob-merge\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-config-glob-merge_config-glob b/t/t5515/fetch.br-config-glob-merge_config-glob\nindex 113c08d..2ba4832 100644\n--- a/t/t5515/fetch.br-config-glob-merge_config-glob\n+++ b/t/t5515/fetch.br-config-glob-merge_config-glob\n@@ -1,7 +1,7 @@\n # br-config-glob-merge config-glob\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-config-glob-octopus b/t/t5515/fetch.br-config-glob-octopus\nindex 9bbd537..64994df 100644\n--- a/t/t5515/fetch.br-config-glob-octopus\n+++ b/t/t5515/fetch.br-config-glob-octopus\n@@ -1,8 +1,8 @@\n # br-config-glob-octopus\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-config-glob-octopus_config-glob b/t/t5515/fetch.br-config-glob-octopus_config-glob\nindex 4e51043..681a725 100644\n--- a/t/t5515/fetch.br-config-glob-octopus_config-glob\n+++ b/t/t5515/fetch.br-config-glob-octopus_config-glob\n@@ -1,8 +1,8 @@\n # br-config-glob-octopus config-glob\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-remote-explicit-merge b/t/t5515/fetch.br-remote-explicit-merge\nindex 7421b2c..d018b35 100644\n--- a/t/t5515/fetch.br-remote-explicit-merge\n+++ b/t/t5515/fetch.br-remote-explicit-merge\n@@ -1,8 +1,8 @@\n # br-remote-explicit-merge\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-remote-explicit-merge_remote-explicit b/t/t5515/fetch.br-remote-explicit-merge_remote-explicit\nindex b6975d3..0d3d780 100644\n--- a/t/t5515/fetch.br-remote-explicit-merge_remote-explicit\n+++ b/t/t5515/fetch.br-remote-explicit-merge_remote-explicit\n@@ -1,8 +1,8 @@\n # br-remote-explicit-merge remote-explicit\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-remote-explicit-octopus b/t/t5515/fetch.br-remote-explicit-octopus\nindex 7681281..6f84304 100644\n--- a/t/t5515/fetch.br-remote-explicit-octopus\n+++ b/t/t5515/fetch.br-remote-explicit-octopus\n@@ -1,7 +1,7 @@\n # br-remote-explicit-octopus\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit b/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit\nindex 4c896cf..3546a83 100644\n--- a/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit\n+++ b/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit\n@@ -1,7 +1,7 @@\n # br-remote-explicit-octopus remote-explicit\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-remote-glob-merge b/t/t5515/fetch.br-remote-glob-merge\nindex 4b62b01..7e1a433 100644\n--- a/t/t5515/fetch.br-remote-glob-merge\n+++ b/t/t5515/fetch.br-remote-glob-merge\n@@ -1,7 +1,7 @@\n # br-remote-glob-merge\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-remote-glob-merge_remote-glob b/t/t5515/fetch.br-remote-glob-merge_remote-glob\nindex 7478f1f..53571bb 100644\n--- a/t/t5515/fetch.br-remote-glob-merge_remote-glob\n+++ b/t/t5515/fetch.br-remote-glob-merge_remote-glob\n@@ -1,7 +1,7 @@\n # br-remote-glob-merge remote-glob\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\t\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tbranch 'two' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\ndiff --git a/t/t5515/fetch.br-remote-glob-octopus b/t/t5515/fetch.br-remote-glob-octopus\nindex 2543420..c7c8b6d 100644\n--- a/t/t5515/fetch.br-remote-glob-octopus\n+++ b/t/t5515/fetch.br-remote-glob-octopus\n@@ -1,8 +1,8 @@\n # br-remote-glob-octopus\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\ndiff --git a/t/t5515/fetch.br-remote-glob-octopus_remote-glob b/t/t5515/fetch.br-remote-glob-octopus_remote-glob\nindex 5ffde9c..36076fb 100644\n--- a/t/t5515/fetch.br-remote-glob-octopus_remote-glob\n+++ b/t/t5515/fetch.br-remote-glob-octopus_remote-glob\n@@ -1,8 +1,8 @@\n # br-remote-glob-octopus remote-glob\n-754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\t\tbranch 'one' of ../\n-0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\t\tbranch 'two' of ../\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tbranch 'master' of ../\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tbranch 'three' of ../\n 6c9dec2b923228c9ff994c6cfe4ae16c12408dc5\tnot-for-merge\ttag 'tag-master' of ../\n 8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\ttag 'tag-one' of ../\n 22feea448b023a2d864ef94b013735af34d238ba\tnot-for-merge\ttag 'tag-one-tree' of ../\n-- \n1.7.8.2.334.ge177b0f\n"},{"id":"181903","messageId":"20120104000339.GA22662@gnu.kitenet.net","threadId":"29249","inReplyTo":"7v7h18s5kg.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] write first for-merge ref to FETCH_HEAD first","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2012-01-04T00:03:39Z","receivedAt":"2012-01-04T00:03:39Z","isPatch":true,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Junio C Hamano wrote:\n> Ping? I think this is a good change to go in before 1.7.9.\n> \n> The change broke quite a lot of tests, and I think I've fixed them all.\n\nSigned-off-by: Joey Hess <joey@kitenet.net>\n\n(Hope that's enough!)\n\n-- \nsee shy jo\n"},{"id":"181906","messageId":"7vty4cqqa0.fsf@alter.siamese.dyndns.org","threadId":"29249","inReplyTo":"20120104000339.GA22662@gnu.kitenet.net","subject":"Re: [PATCH] write first for-merge ref to FETCH_HEAD first","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-04T00:12:39Z","receivedAt":"2012-01-04T00:12:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joey Hess <joey@kitenet.net> writes:\n\n> Junio C Hamano wrote:\n>> Ping? I think this is a good change to go in before 1.7.9.\n>> \n>> The change broke quite a lot of tests, and I think I've fixed them all.\n>\n> Signed-off-by: Joey Hess <joey@kitenet.net>\n>\n> (Hope that's enough!)\n\nYes. Thanks.\n"}]}