{"thread":{"id":"15807","subject":"error pushing stash ?","startedAt":"2008-10-07T00:34:35Z","lastAt":"2008-11-06T17:39:14Z","messageCount":8,"participants":["David Bryson","Shawn O. Pearce","Jeff King","david@statichacks.org","Sverre Rabbelier","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92468","messageId":"20081007003435.GZ5774@eratosthenes.cryptobackpack.org","threadId":"15807","inReplyTo":null,"subject":"error pushing stash ?","fromName":"David Bryson","fromEmail":"david@statichacks.org","sentAt":"2008-10-07T00:34:35Z","receivedAt":"2008-10-07T00:34:35Z","isPatch":false,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"I have a git mirror remote setup on a few of my repositories:\n\n[remote \"backup\"]\n    url = /users/dbryson/backup/janus.git/\n    fetch = +refs/heads/*:refs/remotes/origin/*\n    receivepack = sudo -u dbryson git-receive-pack\n    mirror = 1\n\nI send my refs to the backup with:\n\n$ git push backup\n\nOnly to find some odd error messages:\n\nCounting objects: 133, done.\nCompressing objects: 100% (109/109), done.\nWriting objects: 100% (109/109), 31.25 KiB, done.\nTotal 109 (delta 82), reused 0 (delta 0)\nerror: refusing to create funny ref 'refs/stash' remotely\nTo /users/dbryson/backup/janus.git/\n   549f8a4..8e93d51  8654 -> 8654\n   ef6195b..549f8a4  origin/8654 -> origin/8654\n + 623e7cb...63d7262 origin/master -> origin/master (forced update)\n ! [remote rejected] refs/stash -> refs/stash (funny refname)\nerror: failed to push some refs to '/users/dbryson/backup/janus.git/'\n\nShould I be concnerned about this or is it normal ? To be honest the\nfact that the stash isn't pushing doesn't bother me.  But maybe it is a\nsymptom of a larger problem ?\n\nDave\n\n"},{"id":"92469","messageId":"20081007004051.GA18889@spearce.org","threadId":"15807","inReplyTo":"20081007003435.GZ5774@eratosthenes.cryptobackpack.org","subject":"Re: error pushing stash ?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-07T00:40:51Z","receivedAt":"2008-10-07T00:40:51Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"David Bryson <david@statichacks.org> wrote:\n> [remote \"backup\"]\n...\n>     mirror = 1\n> \n> Only to find some odd error messages:\n> \n> $ git push backup\n> Counting objects: 133, done.\n> Compressing objects: 100% (109/109), done.\n> Writing objects: 100% (109/109), 31.25 KiB, done.\n> Total 109 (delta 82), reused 0 (delta 0)\n> error: refusing to create funny ref 'refs/stash' remotely\n> To /users/dbryson/backup/janus.git/\n>    549f8a4..8e93d51  8654 -> 8654\n>    ef6195b..549f8a4  origin/8654 -> origin/8654\n>  + 623e7cb...63d7262 origin/master -> origin/master (forced update)\n>  ! [remote rejected] refs/stash -> refs/stash (funny refname)\n> error: failed to push some refs to '/users/dbryson/backup/janus.git/'\n\nrefs/stash is a funny refname because it contains only 1 '/'.\nNormally a valid ref has at least 2 '/', e.g. refs/heads/8654 or\nrefs/tags/v1.0.\n\nNaming the stash refs/stash was perhaps funny in the first place\nsince it cannot be moved about on the transport protocol, but then\nagain the bulk of the stash data is actually in the reflog for the\nstash (and not the stash ref itself) so there is basically no point\nin pushing or fetching a stash directly.\n\n-- \nShawn.\n"},{"id":"94140","messageId":"20081028211755.GA8074@sigill.intra.peff.net","threadId":"15807","inReplyTo":"20081007004051.GA18889@spearce.org","subject":"Re: error pushing stash ?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-28T21:17:55Z","receivedAt":"2008-10-28T21:17:55Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 06, 2008 at 05:40:51PM -0700, Shawn O. Pearce wrote:\n\n> >  ! [remote rejected] refs/stash -> refs/stash (funny refname)\n> > error: failed to push some refs to '/users/dbryson/backup/janus.git/'\n> \n> refs/stash is a funny refname because it contains only 1 '/'.\n> Normally a valid ref has at least 2 '/', e.g. refs/heads/8654 or\n> refs/tags/v1.0.\n\nSince no version of receive-pack accepts these \"funny refs\", perhaps we\nshould mirror the check when considering the list of refs to send. IOW,\ndon't even make them eligible for matching or mirroring. Patch is below.\n\n> Naming the stash refs/stash was perhaps funny in the first place\n> since it cannot be moved about on the transport protocol, but then\n> again the bulk of the stash data is actually in the reflog for the\n> stash (and not the stash ref itself) so there is basically no point\n> in pushing or fetching a stash directly.\n\nI agree there is not much point in pushing it, since the useful bit is\nin the reflog. So perhaps a \"funny\" refname is a good place to put it,\nsince it easily tells us that it is not a useful thing to push.\n\n---\ndiff --git a/builtin-send-pack.c b/builtin-send-pack.c\nindex bbf6e0a..298bd71 100644\n--- a/builtin-send-pack.c\n+++ b/builtin-send-pack.c\n@@ -140,7 +140,13 @@ static struct ref *remote_refs, **remote_tail;\n static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n {\n \tstruct ref *ref;\n-\tint len = strlen(refname) + 1;\n+\tint len;\n+\n+\t/* we already know it starts with refs/ to get here */\n+\tif (check_ref_format(refname + 5))\n+\t\treturn 0;\n+\n+\tlen = strlen(refname) + 1;\n \tref = xcalloc(1, sizeof(*ref) + len);\n \thashcpy(ref->new_sha1, sha1);\n \tmemcpy(ref->name, refname, len);\n"},{"id":"94141","messageId":"20081028212327.GA25358@sigill.intra.peff.net","threadId":"15807","inReplyTo":"20081028211755.GA8074@sigill.intra.peff.net","subject":"Re: error pushing stash ?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-28T21:23:28Z","receivedAt":"2008-10-28T21:23:28Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 28, 2008 at 05:17:55PM -0400, Jeff King wrote:\n\n> Since no version of receive-pack accepts these \"funny refs\", perhaps we\n> should mirror the check when considering the list of refs to send. IOW,\n> don't even make them eligible for matching or mirroring. Patch is below.\n> [...]\n> +\t/* we already know it starts with refs/ to get here */\n> +\tif (check_ref_format(refname + 5))\n> +\t\treturn 0;\n\nIt occurs to me that since I didn't give a good commit message, and\nsince I replied to a several-weeks-old message, this might be confusing.\nBut what I am suggesting is that git-push should not bother trying to\nsend something that it knows git-receive-pack will refuse. So this check\ngoes into builtin-send-pack.c, and is an exact mirror of the one in\nbuiltin-receive-pack.c:\n\n $ sed -n 177,181p builtin-receive-pack.c\n        /* only refs/... are allowed */\n        if (prefixcmp(name, \"refs/\") || check_ref_format(name + 5)) {\n                error(\"refusing to create funny ref '%s' remotely\", name);\n                return \"funny refname\";\n        }\n\n-Peff\n"},{"id":"95030","messageId":"1225942397-20513-1-git-send-email-david@statichacks.org","threadId":"15807","inReplyTo":"20081028212327.GA25358@sigill.intra.peff.net","subject":"[PATCH] Added test case for mirror to not push stash refs","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T03:33:17Z","receivedAt":"2008-11-06T03:33:17Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\nThis test case checks to make sure mirror does not push stashed refs\n\n---\n t/t5517-push-mirror.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh\nindex ea49ded..bb263cd 100755\n--- a/t/t5517-push-mirror.sh\n+++ b/t/t5517-push-mirror.sh\n@@ -123,6 +123,16 @@ test_expect_success 'push mirror adds, updates and removes branches together' '\n \n '\n \n+test_expect_success 'push mirror does not push stash refs' '\n+\n+\tmk_repo_pair &&\n+\t(\n+\t\tcd master &&\n+\t\techo foo >foo && git add foo && git commit -m 'foo' &&\n+\t\techo bar >foo && git stash save 'WIP' &&\n+\t\tgit push --mirror up\n+\t)\n+'\n \n # TAG tests\n test_expect_success 'push mirror creates new tags' '\n-- \n1.6.0.1\n"},{"id":"95032","messageId":"bd6139dc0811060034q14e47232n5f00471e5420efbb@mail.gmail.com","threadId":"15807","inReplyTo":"1225942397-20513-1-git-send-email-david@statichacks.org","subject":"Re: [PATCH] Added test case for mirror to not push stash refs","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-11-06T08:34:36Z","receivedAt":"2008-11-06T08:34:36Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"> +               git push --mirror up\n> +       )\n> +'\n\nI don't quite get how this works, I don't see a test here anywhere to\nactually test that the stash refs were not pushed?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"95060","messageId":"7vod0siyfx.fsf@gitster.siamese.dyndns.org","threadId":"15807","inReplyTo":"bd6139dc0811060034q14e47232n5f00471e5420efbb@mail.gmail.com","subject":"Re: [PATCH] Added test case for mirror to not push stash refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-06T16:58:10Z","receivedAt":"2008-11-06T16:58:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sverre Rabbelier\" <alturin@gmail.com> writes:\n\n>> +               git push --mirror up\n>> +       )\n>> +'\n>\n> I don't quite get how this works, I don't see a test here anywhere to\n> actually test that the stash refs were not pushed?\n\nI agree that this test should check the receiving end.\n\nThe patch is relying on the fact that the receiving end would reject the\npush if the sending end tries to push refs/$foo where $foo does not have\nany slash.\n"},{"id":"95065","messageId":"1225993154-3685-1-git-send-email-david@statichacks.org","threadId":"15807","inReplyTo":"20081028212327.GA25358@sigill.intra.peff.net","subject":"[PATCH] Added test case for mirror to not push stash refs","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:39:14Z","receivedAt":"2008-11-06T17:39:14Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\nThis test case checks to make sure mirror does not push stashed refs\n\n---\n t/t5517-push-mirror.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh\nindex ea49ded..bb263cd 100755\n--- a/t/t5517-push-mirror.sh\n+++ b/t/t5517-push-mirror.sh\n@@ -123,6 +123,16 @@ test_expect_success 'push mirror adds, updates and removes branches together' '\n \n '\n \n+test_expect_success 'push mirror does not push stash refs' '\n+\n+\tmk_repo_pair &&\n+\t(\n+\t\tcd master &&\n+\t\techo foo >foo && git add foo && git commit -m 'foo' &&\n+\t\techo bar >foo && git stash save 'WIP' &&\n+\t\tgit push --mirror up\n+\t)\n+'\n \n # TAG tests\n test_expect_success 'push mirror creates new tags' '\n-- \n1.6.0.1\n"}]}