{"thread":{"id":"19276","subject":"[PATCH] Fix git-push --mirror also mirroring refs/remotes/","startedAt":"2009-05-10T19:35:36Z","lastAt":"2009-05-10T22:15:06Z","messageCount":7,"participants":["Bryan Drewery","Markus Heidelberg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113483","messageId":"1241984136-2578-1-git-send-email-bryan@shatow.net","threadId":"19276","inReplyTo":null,"subject":"[PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Bryan Drewery","fromEmail":"bryan@shatow.net","sentAt":"2009-05-10T19:35:36Z","receivedAt":"2009-05-10T19:35:36Z","isPatch":true,"sender":{"key":"bryan@shatow.net","avatar":"https://gravatar.com/avatar/97f2135497453f52d450b5cc8a09910e12efea7dc520a25107afcc666ab9a182?d=mp&s=160"},"body":"git-push --mirror was incorrectly mirroring refs/remotes/\npreviously. This patch fixes it to follow the documentation\nwhich is to mirror only refs/heads/ and refs/tags/.\n\nSigned-off-by: Bryan Drewery <bryan@shatow.net>\n---\n remote.c               |    4 +++-\n t/t5517-push-mirror.sh |   21 +++++++++++++++++++++\n 2 files changed, 24 insertions(+), 1 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex d66e2f3..70cfab8 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1123,8 +1123,10 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\n \t\t\t * \"matching refs\"; traditionally we pushed everything\n \t\t\t * including refs outside refs/heads/ hierarchy, but\n \t\t\t * that does not make much sense these days.\n+\t\t\t * Push only refs/heads/ and refs/tags/ when mirroring\n+\t\t\t * otherwise only matching refs/heads/\n \t\t\t */\n-\t\t\tif (!send_mirror && prefixcmp(src->name, \"refs/heads/\"))\n+\t\t\tif ((!send_mirror || prefixcmp(src->name, \"refs/tags/\")) && prefixcmp(src->name, \"refs/heads/\"))\n \t\t\t\tcontinue;\n \t\t\tdst_name = xstrdup(src->name);\n \ndiff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh\nindex ea49ded..3fc7dc2 100755\n--- a/t/t5517-push-mirror.sh\n+++ b/t/t5517-push-mirror.sh\n@@ -264,4 +264,25 @@ test_expect_success 'remote.foo.mirror=no has no effect' '\n \n '\n \n+# REMOTES test\n+test_expect_success 'push mirror does not push remotes' '\n+\n+\tmk_repo_pair &&\n+\t(\n+\t\tcd master &&\n+\t\techo one >foo && git add foo && git commit -m one &&\n+\t\tgit push --mirror up &&\n+\t\tgit remote update &&\n+\t\tgit push --mirror up\n+\t) &&\n+\tmaster_master=$(cd master && git show-ref -s --verify refs/heads/master) &&\n+\tmirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&\n+\ttest \"$master_master\" = \"$mirror_master\" &&\n+\t(\n+\t\tcd mirror &&\n+\t\tinvert git show-ref -s --verify refs/remotes/up/master\n+\t)\n+'\n+\n+\n test_done\n-- \n1.6.2.5\n"},{"id":"113484","messageId":"200905102225.25508.markus.heidelberg@web.de","threadId":"19276","inReplyTo":"1241984136-2578-1-git-send-email-bryan@shatow.net","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-05-10T20:25:24Z","receivedAt":"2009-05-10T20:25:24Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Bryan Drewery, 10.05.2009:\n> git-push --mirror was incorrectly mirroring refs/remotes/\n\nNo, that's correct.\n\n> previously. This patch fixes it to follow the documentation\n> which is to mirror only refs/heads/ and refs/tags/.\n\nWhere have you read this? In the git-push docs at the --mirror\ndescription there is written \"all refs under $GIT_DIR/refs/\".\n\nMarkus\n"},{"id":"113486","messageId":"4A073E2E.6060403@shatow.net","threadId":"19276","inReplyTo":"200905102225.25508.markus.heidelberg@web.de","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Bryan Drewery","fromEmail":"bryan@shatow.net","sentAt":"2009-05-10T20:50:54Z","receivedAt":"2009-05-10T20:50:54Z","isPatch":true,"sender":{"key":"bryan@shatow.net","avatar":"https://gravatar.com/avatar/97f2135497453f52d450b5cc8a09910e12efea7dc520a25107afcc666ab9a182?d=mp&s=160"},"body":"My git is outdated on my development server, 1.5.6.5:\n\n       --mirror\n           Instead of naming each ref to push, specifies that all refs\nunder $GIT_DIR/refs/heads/ and $GIT_DIR/refs/tags/ be mirrored to the\nremote repository. Newly created\n           local refs will be pushed to the remote end, locally updated\nrefs will be force updated on the remote end, and deleted refs will be\nremoved from the remote end.\n           This is the default if the configuration option\nremote.<remote>.mirror is set.\n\nSo, it's a bug in the docs in 1.5.6.5.\n\nThis behavior makes no sense to me. Can we at least add a config option\nto make it not push remotes? I push my development repository\nto a remote private repository only as a backup, and push my master/next\nto a public repository. I see no reason to push my 8 remotes and\nall their branches to my backup repository.\n\nBryan\n\nMarkus Heidelberg wrote:\n> Bryan Drewery, 10.05.2009:\n>   \n>> git-push --mirror was incorrectly mirroring refs/remotes/\n>>     \n>\n> No, that's correct.\n>\n>   \n>> previously. This patch fixes it to follow the documentation\n>> which is to mirror only refs/heads/ and refs/tags/.\n>>     \n>\n> Where have you read this? In the git-push docs at the --mirror\n> description there is written \"all refs under $GIT_DIR/refs/\".\n>\n> Markus\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>   \n"},{"id":"113487","messageId":"200905102313.13544.markus.heidelberg@web.de","threadId":"19276","inReplyTo":"4A073E2E.6060403@shatow.net","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-05-10T21:13:13Z","receivedAt":"2009-05-10T21:13:13Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Bryan Drewery, 10.05.2009:\n> This behavior makes no sense to me. Can we at least add a config option\n> to make it not push remotes? I push my development repository\n> to a remote private repository only as a backup, and push my master/next\n> to a public repository. I see no reason to push my 8 remotes and\n> all their branches to my backup repository.\n\nWhy are you disturbed by the remotes, if it's only a backup repository\nwhere you don't look into in the normal case?\n\nMarkus\n"},{"id":"113491","messageId":"4A0747B9.1080707@shatow.net","threadId":"19276","inReplyTo":"200905102313.13544.markus.heidelberg@web.de","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Bryan Drewery","fromEmail":"bryan@shatow.net","sentAt":"2009-05-10T21:31:37Z","receivedAt":"2009-05-10T21:31:37Z","isPatch":true,"sender":{"key":"bryan@shatow.net","avatar":"https://gravatar.com/avatar/97f2135497453f52d450b5cc8a09910e12efea7dc520a25107afcc666ab9a182?d=mp&s=160"},"body":"Markus Heidelberg wrote:\n> Bryan Drewery, 10.05.2009:\n>   \n>> This behavior makes no sense to me. Can we at least add a config option\n>> to make it not push remotes? I push my development repository\n>> to a remote private repository only as a backup, and push my master/next\n>> to a public repository. I see no reason to push my 8 remotes and\n>> all their branches to my backup repository.\n>>     \n>\n> Why are you disturbed by the remotes, if it's only a backup repository\n> where you don't look into in the normal case?\n>\n>   \nIf it's going to push remote heads, shouldn't it (in line with \"mirror\")\nalso push all\nremote settings for all remotes from the config to the destination\nrepository, as\nwell as other config settings?\n\nIf not, then why push remote heads at all?\n\nBryan\n"},{"id":"113492","messageId":"7vskjctyey.fsf@alter.siamese.dyndns.org","threadId":"19276","inReplyTo":"200905102313.13544.markus.heidelberg@web.de","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-10T21:56:21Z","receivedAt":"2009-05-10T21:56:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Markus Heidelberg <markus.heidelberg@web.de> writes:\n\n> Bryan Drewery, 10.05.2009:\n>> This behavior makes no sense to me. Can we at least add a config option\n>> to make it not push remotes? I push my development repository\n>> to a remote private repository only as a backup, and push my master/next\n>> to a public repository. I see no reason to push my 8 remotes and\n>> all their branches to my backup repository.\n>\n> Why are you disturbed by the remotes, if it's only a backup repository\n> where you don't look into in the normal case?\n\nI suspect you got a wrong \"backup\".\n\n\"push --mirror\" is about backing up the local repository so that other\npeople (most likely \"you working on some other machine\") who usually\ninteract with the current repository can instead get history from the\nrepository that you are pushing into, when the current repository is not\nreachable for whatever reason.\n\nIn other words, \"push --mirror\" is not a backup in the \"archive to tape\nfor disaster recovery\" sense, but is a backup in the \"you can go there in\ncase this is not reachable\" sense.  The refspec \"remote add --mirror\"\ncreates is set up to support a backup repository in the same sense in the\nopposite direction [*1*].\n\nNow, these other people may not have any business looking into remotes\nhierarchy of this repository, and we could argue that there is not much\npoint pushing remotes hierarchy over there (nor stash or topgit for that\nmatter) in a normal workflow.\n\nBut these other people can say \"git fetch $here remotes/origin/master\"\nexplicitly when fetching from this repository.  By mirroring everything\nunder refs/ to its --mirror backup repository, these other people can\nsubstitute $here with its --mirror backup repository and expect it to\nstill work.  It would be a regression if you stop pushing the refs/remotes\nhierarchy, and such a proposal must be backed by an argument that says the\nbenefit such a change brings in far outweighs the regression it causes.\n\n\n[Footnote]\n\n*1* If you want a \"disaster recovery backup\", there is always \"tar\".  My\nrecent favourite is to append into an existing squashfs image, though ;-)\n"},{"id":"113494","messageId":"200905110015.06939.markus.heidelberg@web.de","threadId":"19276","inReplyTo":"7vskjctyey.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Fix git-push --mirror also mirroring refs/remotes/","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-05-10T22:15:06Z","receivedAt":"2009-05-10T22:15:06Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Junio C Hamano, 10.05.2009:\n> Markus Heidelberg <markus.heidelberg@web.de> writes:\n> \n> > Bryan Drewery, 10.05.2009:\n> >> This behavior makes no sense to me. Can we at least add a config option\n> >> to make it not push remotes? I push my development repository\n> >> to a remote private repository only as a backup, and push my master/next\n> >> to a public repository. I see no reason to push my 8 remotes and\n> >> all their branches to my backup repository.\n> >\n> > Why are you disturbed by the remotes, if it's only a backup repository\n> > where you don't look into in the normal case?\n> \n> I suspect you got a wrong \"backup\".\n> \n> [...]\n> \n> It would be a regression if you stop pushing the refs/remotes\n> hierarchy, and such a proposal must be backed by an argument that says the\n> benefit such a change brings in far outweighs the regression it causes.\n\nI'm not sure if this is addressed to me, but I'm not for removing\nrefs/remotes from push --mirror, maybe I was a bit confusing above.\n\nMarkus\n"}]}