{"thread":{"id":"32909","subject":"[BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","startedAt":"2013-02-15T19:33:24Z","lastAt":"2014-05-28T15:59:37Z","messageCount":9,"participants":["Alain Kalker","Junio C Hamano","Jeff King","Philip Oakley","Bram Geron"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"209558","messageId":"511E8D84.6060601@gmail.com","threadId":"32909","inReplyTo":null,"subject":"[BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Alain Kalker","fromEmail":"a.c.kalker@gmail.com","sentAt":"2013-02-15T19:33:24Z","receivedAt":"2013-02-15T19:33:24Z","isPatch":false,"sender":{"key":"a.c.kalker@gmail.com","avatar":null},"body":"tl;dr:\n\n- `git bundle create` without <git-rev-list-args> gives git rev-list \nhelp, then dies.\n   Should point out missing <git-rev-list-args> instead.\n- `git clone <bundle> <dir> gives \"ERROR: Repository not found.\"\n- `strace ... git clone <bundle> <dir>` (magically) appears to work but\n   cannot checkout files b/c of nonexistent ref.\n- Heisenbug? Race condition?\n- Zaphod Beeblebrox has left the building, sulking.\n\nFull description:\n\nWhen I try to clone from a bundle created from a local repository, `git \nclone <bundle> <dir>` fails with: \"ERROR: Repository not found. fatal: \nCould not read from remote repository.\" unless I run it with strace.\n\nOS: Arch Linux (rolling release)\nGit versions: 1.8.1.3 and git://github.com/git.git master@02339dd\n\nSteps to reproduce:\n\n$ # Clone the Linux kernel repository\n$ git clone git://github.com/torvalds/linux.git\nCloning into 'linux'...\nremote: Counting objects: 2841147, done.\nremote: Compressing objects: 100% (670736/670736), done.\nremote: Total 2841147 (delta 2308339), reused 2657487 (delta 2143012)\nReceiving objects: 100% (2841147/2841147), 797.62 MiB | 2.59 MiB/s, done.\nResolving deltas: 100% (2308339/2308339), done.\nChecking out files: 100% (41521/41521), done.\n$ cd linux\n$ git branch -av\n* master                323a72d Merge \ngit://git.kernel.org/pub/scm/linux/kernel/git/davem/net\n   remotes/origin/HEAD   -> origin/master\n   remotes/origin/master 323a72d Merge \ngit://git.kernel.org/pub/scm/linux/kernel/git/davem/net\n\n$ # Try to create a bundle\n$ git bundle create ../linux.bundle\nusage: git rev-list [OPTION] <commit-id>... [ -- paths... ]\n   limiting output:\n     --max-count=<n>\n     --max-age=<epoch>\n     --min-age=<epoch>\n     --sparse\n     --no-merges\n     --min-parents=<n>\n     --no-min-parents\n     --max-parents=<n>\n     --no-max-parents\n     --remove-empty\n     --all\n     --branches\n     --tags\n     --remotes\n     --stdin\n     --quiet\n   ordering output:\n     --topo-order\n     --date-order\n     --reverse\n   formatting output:\n     --parents\n     --children\n     --objects | --objects-edge\n     --unpacked\n     --header | --pretty\n     --abbrev=<n> | --no-abbrev\n     --abbrev-commit\n     --left-right\n   special purpose:\n     --bisect\n     --bisect-vars\n     --bisect-all\nerror: rev-list died\n$ # IMHO the error should refer to the usage of `git bundle` with a \nproper basis, not `git rev-list`.\n$ # Also nothing should die loudly because of a missing parameter.\n$ git bundle create ../linux.bundle master\nCounting objects: 2836191, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (505627/505627), done.\nWriting objects: 100% (2836191/2836191), 796.59 MiB | 16.23 MiB/s, done.\nTotal 2836191 (delta 2304454), reused 2834391 (delta 2303193)\n\n$ # Try to clone a new repository from the bundle\n$ cd ..\n$ git clone linux.bundle linuxfrombundle\nCloning into 'linuxfrombundle'...\nERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n$ git clone linux.bundle -b master linuxfrombundle\nCloning into 'linuxfrombundle'...\nERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\n# Try again using strace\n$ # (Replace /dev/null with a filename if you really want to try and \ndebug this, or if you just want to torture your hard drive ;) )\n$ strace -o /dev/null git clone linux.bundle linuxfrombundle\nCloning into 'linuxfrombundle'...\nReceiving objects: 100% (2836191/2836191), 796.59 MiB | 24.64 MiB/s, done.\nResolving deltas: 100% (2304454/2304454), done.\nwarning: remote HEAD refers to nonexistent ref, unable to checkout.\n\n$ # Let's have a look at what we cloned\n$ cd linuxfrombundle\n$ ls\n$ git branch -av\n   remotes/origin/master 323a72d Merge \ngit://git.kernel.org/pub/scm/linux/kernel/git/davem/net\n$ git checkout master\nChecking out files: 100% (41521/41521), done.\nBranch master set up to track remote branch master from origin.\nAlready on 'master'\n$ git branch -av\n* master                323a72d Merge \ngit://git.kernel.org/pub/scm/linux/kernel/git/davem/net\n   remotes/origin/master 323a72d Merge \ngit://git.kernel.org/pub/scm/linux/kernel/git/davem/net\n$ # Where's my HEAD?\n\nKind regards,\n\nAlain Kalker\n"},{"id":"209562","messageId":"kfmclb$4ro$2@ger.gmane.org","threadId":"32909","inReplyTo":"511E8D84.6060601@gmail.com","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Alain Kalker","fromEmail":"a.c.kalker@gmail.com","sentAt":"2013-02-15T22:25:47Z","receivedAt":"2013-02-15T22:25:47Z","isPatch":false,"sender":{"key":"a.c.kalker@gmail.com","avatar":null},"body":"On Fri, 15 Feb 2013 20:33:24 +0100, Alain Kalker wrote:\n\n> tl;dr:\n> \n> - `git bundle create` without <git-rev-list-args> gives git rev-list\n> help, then dies.\n>    Should point out missing <git-rev-list-args> instead.\n> - `git clone <bundle> <dir> gives \"ERROR: Repository not found.\"\n> - `strace ... git clone <bundle> <dir>` (magically) appears to work but\n>    cannot checkout files b/c of nonexistent ref.\n> - Heisenbug? Race condition?\n> - Zaphod Beeblebrox has left the building, sulking.\n> \n> Full description:\n> \n> When I try to clone from a bundle created from a local repository, `git\n> clone <bundle> <dir>` fails with: \"ERROR: Repository not found. fatal:\n> Could not read from remote repository.\" unless I run it with strace.\n> \n> OS: Arch Linux (rolling release)\n> Git versions: 1.8.1.3 and git://github.com/git.git master@02339dd\n> \n> Steps to reproduce:\n\nFor those who like to \"save the trees\" (source code or otherwise), here \nis a much simplified test case:\n\n$ # Create test repository with a single commit in it\n$ mkdir testrepo\n$ cd testrepo\n$ git init\n$ echo Test > test.txt\n$ git add test.txt\n$ git commit -m \"Add test.txt\"\n\n$ # Create bundle\n$ git bundle create ../testrepo.bundle master\n\n$ # Try to clone from bundle\n$ cd ..\n$ git clone testrepo.bundle testrepofrombundle\n\n$ # Clone from bundle, wrapped with strace\n$ strace -f -o /dev/null git clone testrepo.bundle testrepofrombundle\n\n$ # Examine cloned repository\n$ cd testrepofrombundle\n$ ls\n$ git branch -av\n$ git checkout master\n$ git branch -av\n$ # Where's my HEAD?\n\n> Kind regards,\n> \n> Alain Kalker\n"},{"id":"209573","messageId":"kfmide$4ro$3@ger.gmane.org","threadId":"32909","inReplyTo":"kfmclb$4ro$2@ger.gmane.org","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Alain Kalker","fromEmail":"a.c.kalker@gmail.com","sentAt":"2013-02-16T00:03:58Z","receivedAt":"2013-02-16T00:03:58Z","isPatch":false,"sender":{"key":"a.c.kalker@gmail.com","avatar":null},"body":"On Fri, 15 Feb 2013 22:25:47 +0000, Alain Kalker wrote:\n\n> On Fri, 15 Feb 2013 20:33:24 +0100, Alain Kalker wrote:\n> \n>> tl;dr:\n>> \n>> - `git bundle create` without <git-rev-list-args> gives git rev-list\n>> help, then dies.\n>>    Should point out missing <git-rev-list-args> instead.\n>> - `git clone <bundle> <dir> gives \"ERROR: Repository not found.\"\n>> - `strace ... git clone <bundle> <dir>` (magically) appears to work but\n>>    cannot checkout files b/c of nonexistent ref.\n>> - Heisenbug? Race condition?\n>> - Zaphod Beeblebrox has left the building, sulking.\n>> \n>> Full description:\n>> \n>> When I try to clone from a bundle created from a local repository, `git\n>> clone <bundle> <dir>` fails with: \"ERROR: Repository not found. fatal:\n>> Could not read from remote repository.\" unless I run it with strace.\n\nAfter trying to bisect this using `bisect start; bisect good v1.5.1; git \nbisect bad HEAD; git bisect run ..test.sh`:\n\n---test.sh---\n#!/bin/sh\n\nmake clean\nmake || return 125\nGIT=$(pwd)/git\n\ncd /tmp\nrm -rf testrepo\nmkdir testrepo\ncd testrepo\n$GIT init\necho test > test.txt\n$GIT add test.txt\n$GIT commit -m \"Add test.txt\"\n$GIT bundle create ../testrepo.bundle master || return 125\ncd ..\n\nrm -rf testrepofrombundle\n$GIT clone testrepo.bundle testrepofrombundle || return 1\n---\nI was unable to find a bad revision.\nAfter a lot more searching I found that I had `git` aliased to `hub`, a \ntool used to make Github actions easier.\nEliminating `hub` from the equation resolved most problems.\nThe only ones remaining are the confusing error message from `git bundle \ncreate` and the \"missing HEAD\" (you can interpret that in different \nways) ;-)\n\nP.S. I hereby promise to _never_ _ever_ alias `git` to something else and \nthen post a Git bug about that \"something else\" on this ML.\n\nSorry to have wasted your time,\n\nAlain\n"},{"id":"209574","messageId":"7vd2w1f7bc.fsf@alter.siamese.dyndns.org","threadId":"32909","inReplyTo":"kfmide$4ro$3@ger.gmane.org","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-16T00:09:27Z","receivedAt":"2013-02-16T00:09:27Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alain Kalker <a.c.kalker@gmail.com> writes:\n\n> P.S. I hereby promise to _never_ _ever_ alias `git` to something else and \n> then post a Git bug about that \"something else\" on this ML.\n>\n> Sorry to have wasted your time,\n\nThanks.\n\nPeople around here tend to be quiet until they sufficiently have dug\nthe issue themselves; unless the initial report grossly lack\nnecessary level of details, you may not hear \"does not reproduce for\nme\" for some time, so some may still have been scratching their\nhead, and your honestly following-up on your message will save time\nfor them.  Thanks again, and happy Gitting ;-)\n"},{"id":"209576","messageId":"20130216040109.GA31630@sigill.intra.peff.net","threadId":"32909","inReplyTo":"kfmide$4ro$3@ger.gmane.org","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-02-16T04:01:09Z","receivedAt":"2013-02-16T04:01:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Feb 16, 2013 at 12:03:58AM +0000, Alain Kalker wrote:\n\n> ---test.sh---\n> #!/bin/sh\n> \n> make clean\n> make || return 125\n> GIT=$(pwd)/git\n> \n> cd /tmp\n> rm -rf testrepo\n> mkdir testrepo\n> cd testrepo\n> $GIT init\n> echo test > test.txt\n> $GIT add test.txt\n> $GIT commit -m \"Add test.txt\"\n> $GIT bundle create ../testrepo.bundle master || return 125\n> cd ..\n> \n> rm -rf testrepofrombundle\n> $GIT clone testrepo.bundle testrepofrombundle || return 1\n> ---\n> I was unable to find a bad revision.\n> After a lot more searching I found that I had `git` aliased to `hub`, a \n> tool used to make Github actions easier.\n> Eliminating `hub` from the equation resolved most problems.\n\nGreat.\n\n> The only ones remaining are the confusing error message from `git bundle \n> create` and the \"missing HEAD\" (you can interpret that in different \n> ways) ;-)\n\nI do not see any odd message from \"bundle create\" in the recipe above.\nMine says:\n\n$ git bundle create ../repo.bundle master\nCounting objects: 3, done.\nWriting objects: 100% (3/3), 209 bytes, done.\nTotal 3 (delta 0), reused 0 (delta 0)\n\nWhat you _might_ be seeing is the fact that the invocation above is\nlikely to be running two different versions of git under the hood. \"git\nbundle\" will invoke \"git rev-list\", and it will use the first git in\nyour PATH, even if it is not $GIT. The proper way to test an un-installed\nversion of git is to use $YOUR_GIT_BUILD/bin-wrappers/git, which will\nset up environment variables sufficient to make sure all sub-gits are\nfrom the same version. Sometimes mixing versions can have weird results\n(e.g., the new \"git bundle\" expects \"rev-list\" to have a particular\noption, but the older version does not have it).\n\nSecondly, I do get the same warning about HEAD:\n\n  $ git clone repo.bundle repofrombundle\n  Cloning into 'repofrombundle'...\n  Receiving objects: 100% (3/3), done.\n  warning: remote HEAD refers to nonexistent ref, unable to checkout.\n\nbut that warning makes sense. You did not create a bundle that contains\nHEAD, therefore when we clone it, we do not know what to point HEAD to.\nYou probably wanted \"git bundle create ../repo.bundle --all\" which\nincludes both \"master\" and \"HEAD\".\n\nIt would be slightly more accurate to say \"the remote HEAD does not\nexist\", rather than \"refers to nonexistent ref\".  It would perhaps be\nnicer still for \"git clone\" to make a guess about the correct HEAD when\none is not present (especially in the single-branch case, it is easy to\nmake the right guess).\n\nPatches welcome. In the meantime, you can clone with \"-b master\" to tell\nit explicitly, or you can \"git checkout master\" inside the newly-cloned\nrepository.\n\n-Peff\n"},{"id":"209598","messageId":"kfqkak$ugv$1@ger.gmane.org","threadId":"32909","inReplyTo":"20130216040109.GA31630@sigill.intra.peff.net","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Alain Kalker","fromEmail":"a.c.kalker@gmail.com","sentAt":"2013-02-17T13:01:08Z","receivedAt":"2013-02-17T13:01:08Z","isPatch":false,"sender":{"key":"a.c.kalker@gmail.com","avatar":null},"body":"On Fri, 15 Feb 2013 23:01:09 -0500, Jeff King wrote:\n\n> On Sat, Feb 16, 2013 at 12:03:58AM +0000, Alain Kalker wrote:\n> \n>> ---test.sh---\n>> #!/bin/sh\n>> \n>> make clean make || return 125 GIT=$(pwd)/git\n>> \n>> cd /tmp rm -rf testrepo mkdir testrepo cd testrepo $GIT init echo test\n>> > test.txt $GIT add test.txt $GIT commit -m \"Add test.txt\"\n>> $GIT bundle create ../testrepo.bundle master || return 125 cd ..\n>> \n>> rm -rf testrepofrombundle $GIT clone testrepo.bundle testrepofrombundle\n>> || return 1 ---\n>> I was unable to find a bad revision.\n>> After a lot more searching I found that I had `git` aliased to `hub`, a\n>> tool used to make Github actions easier.\n>> Eliminating `hub` from the equation resolved most problems.\n> \n> Great.\n> \n>> The only ones remaining are the confusing error message from `git\n>> bundle create` and the \"missing HEAD\" (you can interpret that in\n>> different ways) ;-)\n> \n> I do not see any odd message from \"bundle create\" in the recipe above.\n> Mine says:\n> \n> $ git bundle create ../repo.bundle master Counting objects: 3, done.\n> Writing objects: 100% (3/3), 209 bytes, done.\n> Total 3 (delta 0), reused 0 (delta 0)\n> \n> What you _might_ be seeing is the fact that the invocation above is\n> likely to be running two different versions of git under the hood. \"git\n> bundle\" will invoke \"git rev-list\", and it will use the first git in\n> your PATH, even if it is not $GIT. The proper way to test an\n> un-installed version of git is to use $YOUR_GIT_BUILD/bin-wrappers/git,\n> which will set up environment variables sufficient to make sure all\n> sub-gits are from the same version. Sometimes mixing versions can have\n> weird results (e.g., the new \"git bundle\" expects \"rev-list\" to have a\n> particular option, but the older version does not have it).\n\nThanks for the very useful tip! I will try to remember to use this for \nany future testing.\n\n> Secondly, I do get the same warning about HEAD:\n> \n>   $ git clone repo.bundle repofrombundle Cloning into\n>   'repofrombundle'...\n>   Receiving objects: 100% (3/3), done.\n>   warning: remote HEAD refers to nonexistent ref, unable to checkout.\n> \n> but that warning makes sense. You did not create a bundle that contains\n> HEAD, therefore when we clone it, we do not know what to point HEAD to.\n> You probably wanted \"git bundle create ../repo.bundle --all\" which\n> includes both \"master\" and \"HEAD\".\n\nThat explains it, thanks! Maybe this could be added as an example to the \ndocumentation for `git bundle`? People looking at `man git-bundle` hoping \nto use it as one possible way to make a backup of a Git repository might \nnot realize right away that --all is the way to specify all refs, like \nwith `git log`.\n\n> \n> It would be slightly more accurate to say \"the remote HEAD does not\n> exist\", rather than \"refers to nonexistent ref\".  It would perhaps be\n> nicer still for \"git clone\" to make a guess about the correct HEAD when\n> one is not present (especially in the single-branch case, it is easy to\n> make the right guess).\n> \n> Patches welcome. In the meantime, you can clone with \"-b master\" to tell\n> it explicitly, or you can \"git checkout master\" inside the newly-cloned\n> repository.\n\nThanks again for your help, very welcome :-)\n\nAlain\n"},{"id":"209605","messageId":"20C7ED1EA37C4EECA28070D1483C57B7@PhilipOakley","threadId":"32909","inReplyTo":"kfqkak$ugv$1@ger.gmane.org","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2013-02-17T17:46:31Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Alain Kalker\" <a.c.kalker@gmail.com>\nSent: Sunday, February 17, 2013 1:01 PM\n> On Fri, 15 Feb 2013 23:01:09 -0500, Jeff King wrote:\n>\n>> On Sat, Feb 16, 2013 at 12:03:58AM +0000, Alain Kalker wrote:\n>>\n>>> ---test.sh---\n>>> #!/bin/sh\n[...]\n>>\n>> but that warning makes sense. You did not create a bundle that \n>> contains\n>> HEAD, therefore when we clone it, we do not know what to point HEAD \n>> to.\n>> You probably wanted \"git bundle create ../repo.bundle --all\" which\n>> includes both \"master\" and \"HEAD\".\n>\n> That explains it, thanks! Maybe this could be added as an example to \n> the\n> documentation for `git bundle`? People looking at `man git-bundle` \n> hoping\n> to use it as one possible way to make a backup of a Git repository \n> might\n> not realize right away that --all is the way to specify all refs, like\n> with `git log`.\n\nI had posted a documentation patch back in Setemeber last year,\nhttp://thread.gmane.org/gmane.comp.version-control.git/205887/focus=205897,\nhowever Junio highlighted some additional concerns that I wasn't able to \nrespond to at the time.\n\nIt may be worth resurrecting once the concerns have been addressed.\n\n>\n>>\n>> It would be slightly more accurate to say \"the remote HEAD does not\n>> exist\", rather than \"refers to nonexistent ref\".  It would perhaps be\n>> nicer still for \"git clone\" to make a guess about the correct HEAD \n>> when\n>> one is not present (especially in the single-branch case, it is easy \n>> to\n>> make the right guess).\n>>\n>> Patches welcome. In the meantime, you can clone with \"-b master\" to \n>> tell\n>> it explicitly, or you can \"git checkout master\" inside the \n>> newly-cloned\n>> repository.\n>\n> Thanks again for your help, very welcome :-)\n>\n> Alain\n>\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n>\n> -----\n> No virus found in this message.\n> Checked by AVG - www.avg.com\n> Version: 2013.0.2899 / Virus Database: 2639/6108 - Release Date: \n> 02/16/13\n> \n"},{"id":"210234","messageId":"7vy5eczxoj.fsf@alter.siamese.dyndns.org","threadId":"32909","inReplyTo":"20C7ED1EA37C4EECA28070D1483C57B7@PhilipOakley","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-25T06:59:08Z","receivedAt":"2013-02-25T06:59:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Philip Oakley\" <philipoakley@iee.org> writes:\n\n>>> You probably wanted \"git bundle create ../repo.bundle --all\" which\n>>> includes both \"master\" and \"HEAD\".\n>>\n>> That explains it, thanks! Maybe this could be added as an example to\n>> the\n>> documentation for `git bundle`? People looking at `man git-bundle`\n>> hoping\n>> to use it as one possible way to make a backup of a Git repository\n>> might\n>> not realize right away that --all is the way to specify all refs, like\n>> with `git log`.\n>\n> I had posted a documentation patch back in Setemeber last year,\n> http://thread.gmane.org/gmane.comp.version-control.git/205887/focus=205897,\n> however Junio highlighted some additional concerns that I wasn't able\n> to respond to at the time.\n>\n> It may be worth resurrecting once the concerns have been addressed.\n\nA saner thing to do, instead of explaining away the lack of HEAD as\n\"the creator of the bundle did not bother to name it\", might be to\nautomatically add an artificial HEAD to the resulting bundle when\nthe arguments given to specify the \"range\" do not have any negative\nones (because by definition such a bundle is unsuitable for use with\n\"git clone\" [*1*]), and HEAD is not among the refs.\n\nThe heuristics to pick what to record as the artificial HEAD could\nvary, though. Without thinking things through...\n\n * When only one positive ref is given, use it (sort of obvious);\n\n * When two or more positive refs are given, and the current branch\n   is one of them, use that;\n\n * Otherwise, pick the \"first\" positive ref given from the command\n   line.\n\nperhaps?\n\n\n[Footnote]\n\n*1* Strictly speaking, this condition could be loosened, as long as\ncloning side uses an appropriate --depth, but I do not know such an\n\"advanced use case\" needs a hand-holding change to add a HEAD that\nwas not asked by the user.\n"},{"id":"242866","messageId":"loom.20140528T171956-380@post.gmane.org","threadId":"32909","inReplyTo":"20130216040109.GA31630@sigill.intra.peff.net","subject":"Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace","fromName":"Bram Geron","fromEmail":"bgeron@bgeron.nl","sentAt":"2014-05-28T15:59:37Z","receivedAt":"2014-05-28T15:59:37Z","isPatch":false,"sender":{"key":"bgeron@bgeron.nl","avatar":null},"body":"Jeff King <peff <at> peff.net> writes:\n> [..]\n> Secondly, I do get the same warning about HEAD:\n> \n>   $ git clone repo.bundle repofrombundle\n>   Cloning into 'repofrombundle'...\n>   Receiving objects: 100% (3/3), done.\n>   warning: remote HEAD refers to nonexistent ref, unable to checkout.\n> \n> but that warning makes sense. You did not create a bundle that contains\n> HEAD, therefore when we clone it, we do not know what to point HEAD to.\n> You probably wanted \"git bundle create ../repo.bundle --all\" which\n> includes both \"master\" and \"HEAD\".\n\nI'd like to revive this discussion and submit a patch, as I just spent\nsignificant time wondering why git clone failed. It's been a while, so I'll\nsummarize: when you make a git bundle without including HEAD explicitly,\nthen clone from that bundle, Git throws a warning and leaves you with a\nbroken HEAD.\n\nI do not agree that the warning makes sense. It implies that HEAD exists but\nis invalid. In reality, no ref is referred to by HEAD in the first place.\nFurthermore, .git/HEAD in the clone is \"autocorrected\" to be\nrefs/heads/master, so the error message is even more misleading.\n\nIt's like saying \"Our CEO's guitar is actually an air guitar\", then\nexplaining where he stores his guitar, when I don't work in a company in the\nfirst place.\n\n> It would be slightly more accurate to say \"the remote HEAD does not\n> exist\", rather than \"refers to nonexistent ref\".  It would perhaps be\n> nicer still for \"git clone\" to make a guess about the correct HEAD when\n> one is not present (especially in the single-branch case, it is easy to\n> make the right guess).\n\nSeems sensible at first sight, though it seems orthogonal to the warning\nmessage.\n\n> Patches welcome. In the meantime, you can clone with \"-b master\" to tell\n> it explicitly, or you can \"git checkout master\" inside the newly-cloned\n> repository.\n\nAlright :) See below.\n\nCheers, Bram\n\n\n>From bc799b12b659d7ab20df7fe420d5f1f1c90450aa Mon Sep 17 00:00:00 2001\nFrom: Bram Geron <bgeron@bgeron.nl>\nDate: Wed, 28 May 2014 15:54:37 +0100\nSubject: [PATCH] Clearer error message when cloning a bundle without a HEAD\n ref.\n\n---\n builtin/clone.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 9b3c04d..e3c1447 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -623,7 +623,7 @@ static int checkout(void)\n \n \thead = resolve_refdup(\"HEAD\", sha1, 1, NULL);\n \tif (!head) {\n-\t\twarning(_(\"remote HEAD refers to nonexistent ref, \"\n+\t\twarning(_(\"no HEAD in remote or HEAD refers to nonexistent ref, \"\n \t\t\t  \"unable to checkout.\\n\"));\n \t\treturn 0;\n \t}\n-- \n1.9.1\n"}]}