{"thread":{"id":"18964","subject":"[PATCH] BUG: git push on an empty clone segfaults.","startedAt":"2009-04-20T09:48:50Z","lastAt":"2009-04-20T20:46:04Z","messageCount":11,"participants":["Matthieu Moy","Johannes Schindelin","Junio C Hamano","Jay Soffian","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"111704","messageId":"1240220930-24679-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"18964","inReplyTo":null,"subject":"[PATCH] BUG: git push on an empty clone segfaults.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-04-20T09:48:50Z","receivedAt":"2009-04-20T09:48:50Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Ideally, \"git push\" from an empty repository to another empty one\nshould be a no-op, or perhaps should error out cleanly. Currently, it\njust segfaults.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t5701-clone-local.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 3559d17..7c6ef4c 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -132,4 +132,14 @@ test_expect_success 'clone empty repository' '\n \t test $actual = $expected)\n '\n \n+test_expect_failure 'clone empty repository, and then push should not segfault.' '\n+\tcd \"$D\" &&\n+\trm -fr empty/ empty-clone/ &&\n+\tmkdir empty &&\n+\t(cd empty && git init) &&\n+\tgit clone empty empty-clone &&\n+\tcd empty-clone &&\n+\ttest_must_fail git push\n+'\n+\n test_done\n-- \n1.6.2.2.449.g92961.dirty\n"},{"id":"111709","messageId":"alpine.DEB.1.00.0904201219240.6955@intel-tinevez-2-302","threadId":"18964","inReplyTo":"1240220930-24679-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH] Fix uninitialized memory in get_local_heads()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-20T10:20:51Z","receivedAt":"2009-04-20T10:20:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIn 454e202(move duplicated get_local_heads() to remote.c), a static\nlocal variable was moved into a function, but not initialized.\n\nThis resulted in a crash when trying to push from an empty repository.\n\nNoticed by Matthieu Moy.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Mon, 20 Apr 2009, Matthieu Moy wrote:\n\n\t> Ideally, \"git push\" from an empty repository to another empty \n\t> one should be a no-op, or perhaps should error out cleanly.\n\t> Currently, it just segfaults.\n\n\tGood catch.  This patch goes on top of yours.\n\n\t/me is running valgrind now.\n\n remote.c               |    2 +-\n t/t5701-clone-local.sh |    2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex a06761a..e4c89b8 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1504,7 +1504,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla\n \n struct ref *get_local_heads(void)\n {\n-\tstruct ref *local_refs, **local_tail = &local_refs;\n+\tstruct ref *local_refs = NULL, **local_tail = &local_refs;\n \tfor_each_ref(one_local_ref, &local_tail);\n \treturn local_refs;\n }\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 7c6ef4c..f26b511 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -132,7 +132,7 @@ test_expect_success 'clone empty repository' '\n \t test $actual = $expected)\n '\n \n-test_expect_failure 'clone empty repository, and then push should not segfault.' '\n+test_expect_success 'clone empty repository, and then push should not segfault.' '\n \tcd \"$D\" &&\n \trm -fr empty/ empty-clone/ &&\n \tmkdir empty &&\n-- \n1.6.2.1.493.g67cf3\n"},{"id":"111710","messageId":"7vfxg3ipib.fsf@gitster.siamese.dyndns.org","threadId":"18964","inReplyTo":"1240220930-24679-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T10:33:00Z","receivedAt":"2009-04-20T10:33:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Ideally, \"git push\" from an empty repository to another empty one\n> should be a no-op, or perhaps should error out cleanly. Currently, it\n> just segfaults.\n\nDidn't we see this fixed by Nguyễn with 55f0566 (get_local_heads(): do not\nreturn random pointer if there is no head, 2009-04-17)?\n"},{"id":"111713","messageId":"alpine.DEB.1.00.0904201252120.6955@intel-tinevez-2-302","threadId":"18964","inReplyTo":"7vfxg3ipib.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-20T10:55:10Z","receivedAt":"2009-04-20T10:55:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 20 Apr 2009, Junio C Hamano wrote:\n\n> Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n> \n> > Ideally, \"git push\" from an empty repository to another empty one\n> > should be a no-op, or perhaps should error out cleanly. Currently, it\n> > just segfaults.\n> \n> Didn't we see this fixed by Nguyễn with 55f0566 (get_local_heads(): do not\n> return random pointer if there is no head, 2009-04-17)?\n\nI fetched from repo.or.cz and tested with 'master', and it was broken.  \nApparently git://repo.or.cz/git.git is lagging behind by 5 days.  Pasky?\n\nCiao,\nDscho\n"},{"id":"111757","messageId":"vpqbpqr1t3w.fsf@bauges.imag.fr","threadId":"18964","inReplyTo":"7vfxg3ipib.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-04-20T11:07:15Z","receivedAt":"2009-04-20T11:07:15Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n>\n>> Ideally, \"git push\" from an empty repository to another empty one\n>> should be a no-op, or perhaps should error out cleanly. Currently, it\n>> just segfaults.\n>\n> Didn't we see this fixed by Nguyễn with 55f0566 (get_local_heads(): do not\n> return random pointer if there is no head, 2009-04-17)?\n\nOops, right, I wasn't up to date. Still, the test-case is relevant,\nI'll resend with test_expect_success.\n\n-- \nMatthieu\n"},{"id":"111720","messageId":"1240225777-31334-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"18964","inReplyTo":"7vfxg3ipib.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] clone: add test for push on an empty clone.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-04-20T11:09:37Z","receivedAt":"2009-04-20T11:09:37Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Commit 55f0566 (get_local_heads(): do not return random pointer if\nthere is no head, 2009-04-17) fixed a segfault for git push, this\npatch adds a test-case to avoid future regressions.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t5701-clone-local.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 3559d17..f26b511 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -132,4 +132,14 @@ test_expect_success 'clone empty repository' '\n \t test $actual = $expected)\n '\n \n+test_expect_success 'clone empty repository, and then push should not segfault.' '\n+\tcd \"$D\" &&\n+\trm -fr empty/ empty-clone/ &&\n+\tmkdir empty &&\n+\t(cd empty && git init) &&\n+\tgit clone empty empty-clone &&\n+\tcd empty-clone &&\n+\ttest_must_fail git push\n+'\n+\n test_done\n-- \n1.6.2.2.449.g92961.dirty\n"},{"id":"111721","messageId":"7vhc0jh928.fsf@gitster.siamese.dyndns.org","threadId":"18964","inReplyTo":"alpine.DEB.1.00.0904201252120.6955@intel-tinevez-2-302","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T11:13:35Z","receivedAt":"2009-04-20T11:13:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Mon, 20 Apr 2009, Junio C Hamano wrote:\n>\n>> Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n>> \n>> > Ideally, \"git push\" from an empty repository to another empty one\n>> > should be a no-op, or perhaps should error out cleanly. Currently, it\n>> > just segfaults.\n>> \n>> Didn't we see this fixed by Nguyễn with 55f0566 (get_local_heads(): do not\n>> return random pointer if there is no head, 2009-04-17)?\n>\n> I fetched from repo.or.cz and tested with 'master', and it was broken.  \n> Apparently git://repo.or.cz/git.git is lagging behind by 5 days.  Pasky?\n\nUnfortunately, that repository is outside of my direct control.\n\nI push into the following four repositories:\n\n\tk.org's master repository\n\tgit://repo.or.cz/alt-git.git/\n        git://git.sourceforge.jp/gitroot/git-core/git.git\n\tgit://git-core.git.sourceforge.net/gitroot/git-core\n\nThe k.org's master repository is mirrored (with small lag) to:\n\n\tgit://git.kernel.org/pub/scm/git/git.git\n\nI suspect that Pasky mirrors that mirror (with some lag) to:\n\n        git://repo.or.cz/git.git\n\nThere may be some other mirrors of mirrors I do not know about.\n\nI'd guess that people in the US are better off going to git.kernel.org,\nEuropeans to git://repo.or.cz/alt-git.git, and East Asians to\ngit.sourceforge.jp/.\n\nI've already written about this elsewhere [*1*], but the sourceforge ones\nare partial; they only have maint and master (and tags).\n\n\n[Footnote]\n\n*1* http://gitster.livejournal.com/31668.html\n"},{"id":"111732","messageId":"76718490904200651t6cee0d73n8cbdea8099487654@mail.gmail.com","threadId":"18964","inReplyTo":"alpine.DEB.1.00.0904201219240.6955@intel-tinevez-2-302","subject":"Re: [PATCH] Fix uninitialized memory in get_local_heads()","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-20T13:51:18Z","receivedAt":"2009-04-20T13:51:18Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Mon, Apr 20, 2009 at 6:20 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> In 454e202(move duplicated get_local_heads() to remote.c), a static\n> local variable was moved into a function, but not initialized.\n>\n> This resulted in a crash when trying to push from an empty repository.\n>\n> Noticed by Matthieu Moy.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nDoh. Thank you for the fix.\n\nj.\n"},{"id":"111735","messageId":"20090420135532.GC8940@machine.or.cz","threadId":"18964","inReplyTo":"alpine.DEB.1.00.0904201252120.6955@intel-tinevez-2-302","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-04-20T13:55:32Z","receivedAt":"2009-04-20T13:55:32Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Mon, Apr 20, 2009 at 12:55:10PM +0200, Johannes Schindelin wrote:\n> I fetched from repo.or.cz and tested with 'master', and it was broken.  \n> Apparently git://repo.or.cz/git.git is lagging behind by 5 days.  Pasky?\n\n  yes, I noticed that the mirroring got hanging on some dead repository\nearlier today and restarted it, but it might take a while until a full\nmirror cycle refreshes everything.\n\n  Sorry about this.\n\n\t\t\t\tPetr \"Pasky\" Baudis\n"},{"id":"111742","messageId":"alpine.DEB.1.00.0904201629280.6771@intel-tinevez-2-302","threadId":"18964","inReplyTo":"20090420135532.GC8940@machine.or.cz","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-20T14:30:38Z","receivedAt":"2009-04-20T14:30:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 20 Apr 2009, Petr Baudis wrote:\n\n> On Mon, Apr 20, 2009 at 12:55:10PM +0200, Johannes Schindelin wrote:\n> > I fetched from repo.or.cz and tested with 'master', and it was broken.  \n> > Apparently git://repo.or.cz/git.git is lagging behind by 5 days.  \n> > Pasky?\n> \n>   yes, I noticed that the mirroring got hanging on some dead repository \n> earlier today and restarted it, but it might take a while until a full \n> mirror cycle refreshes everything.\n\nI always wondered why it should make sense to have a mirror git.git, and \nin addition a repository alt-git.git that Junio pushes to.\n\nMaybe it is time to fix that?\n\nI mean, I am hardly a Git newbie, and even I got burnt.\n\nCiao,\nDscho\n"},{"id":"111779","messageId":"20090420204604.GF8940@machine.or.cz","threadId":"18964","inReplyTo":"alpine.DEB.1.00.0904201629280.6771@intel-tinevez-2-302","subject":"Re: [PATCH] BUG: git push on an empty clone segfaults.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-04-20T20:46:04Z","receivedAt":"2009-04-20T20:46:04Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Mon, Apr 20, 2009 at 04:30:38PM +0200, Johannes Schindelin wrote:\n> On Mon, 20 Apr 2009, Petr Baudis wrote:\n> \n> > On Mon, Apr 20, 2009 at 12:55:10PM +0200, Johannes Schindelin wrote:\n> > > I fetched from repo.or.cz and tested with 'master', and it was broken.  \n> > > Apparently git://repo.or.cz/git.git is lagging behind by 5 days.  \n> > > Pasky?\n> > \n> >   yes, I noticed that the mirroring got hanging on some dead repository \n> > earlier today and restarted it, but it might take a while until a full \n> > mirror cycle refreshes everything.\n> \n> I always wondered why it should make sense to have a mirror git.git, and \n> in addition a repository alt-git.git that Junio pushes to.\n> \n> Maybe it is time to fix that?\n> \n> I mean, I am hardly a Git newbie, and even I got burnt.\n\nSure, I can fix that, making alt-git.git a soft-link to git.git (or,\nspecifically, making refs/ and objects/ symlinks). Junio even might not\nhave to change his push scripts. ;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe average, healthy, well-adjusted adult gets up at seven-thirty\nin the morning feeling just terrible. -- Jean Kerr\n"}]}