{"thread":{"id":"30771","subject":"Git repository name-guessing corner case","startedAt":"2012-06-11T19:28:51Z","lastAt":"2012-06-11T20:09:45Z","messageCount":2,"participants":["Joseph Chiu","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193364","messageId":"1339442931056-7561236.post@n2.nabble.com","threadId":"30771","inReplyTo":null,"subject":"Git repository name-guessing corner case","fromName":"Joseph Chiu","fromEmail":"joechiu@joechiu.com","sentAt":"2012-06-11T19:28:51Z","receivedAt":"2012-06-11T19:28:51Z","isPatch":false,"sender":{"key":"joechiu@joechiu.com","avatar":null},"body":"Hello,\n\nI ran into an admittedly bizarre corner case, caused in part by my own\nfailings, but I wanted to report it.  I haven't come across anyone else\nhaving had this experience (but I suspect that I haven't properly exhausted\nthe right combination of search terms).\n\nI maintain a big handful of my workplace's git repo's - there is a \"north\"\nserver and a \"south\" git server.  They both run gitosis for access control. \nThe repo's are generally setup to sync the north and south repos to each\nother for disaster recovery purposes.\n\nI'll glossing over the backstory - but the process for creating repo's for\nnew projects is partially automated, and involves some manual steps.  \n\nOn the north machine, I created the repo wizard.git, with the mirroring\nconfigured to south:wizard.git\n\nOn the south machine, I first accidentally created the repo wizard.git.git\n(note the double .git), with the mirroring configured by default to\nnorth:android.git (I'll gloss over the back story here - but basically, the\ntemplate used for repo setup used a working config file from the android\nproject - and the real repo name was left in the template).\n\nOn the south machine, I then created the repo wizard.git with the mirror\nconfigured to north:wizard.git\n\nAs you might guess, there was already a north:android.git and\nsouth:android.git repo's configured.\n\nSo the corner case (or perhaps just a \"gotcha\") that occured is this:  when\nmy developer pushed their new code into the north:wizard.git repo, the hook\nto replicate the repo fired, mirroring to south:wizard.git -- however,\ninstead of operating on the wizard.git bare repo, the mirroring was done to\nthe wizard.git.git repo.   The hook that subsequently fired mirrored to\nnorth:android.git and, in turn, a mirroring was done to south:android.git.\n\nBecause the android.git bare repo was recently set to allow deletes of\nbranches and tags for housekeeping reasons, this allowed the push to the\nnorth:wizard.git repo to chain to the android.git repo's, deleting all\nbranches in that project.\n\nI'm guessing this must be the result of the git repo name guessing code\ntrying a repo name with a .git attached first.  Admittedly, this problem was\ncaused by my dumb actions (template config file pointing to a real repo; not\nremoving the wrong bare repo as soon as I created it) -- but I suspect that\nthis is an undesired behavior.  (BTW, no permanent damage was done in my\ncase - I was able to replicate a relatively recent clone back into the\nmaster servers.)\n\nThanks for reading this.\nJoseph\n\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Git-repository-name-guessing-corner-case-tp7561236.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"193367","messageId":"7vwr3d625y.fsf@alter.siamese.dyndns.org","threadId":"30771","inReplyTo":"1339442931056-7561236.post@n2.nabble.com","subject":"Re: Git repository name-guessing corner case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-11T20:09:45Z","receivedAt":"2012-06-11T20:09:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joseph Chiu <joechiu@joechiu.com> writes:\n\n> On the south machine, I first accidentally created the repo wizard.git.git\n> (note the double .git), with ...\n\nWe have updated the logic around this area with b3256eb (standardize\nand improve lookup rules for external local repos, 2012-02-02), and\nthis is part of v1.7.9.2 and later releases.  The rule used to be\n(1) check with \"/.git\" appended, to cover the case where you access\na repository with a working tree attached, (2) check with \".git\"\nappended, and then (3) check without anything appended. It was very\nerror prone to cause exactly the above kind of gotchas.\n\nThe updated rule checks with \"/.git\" first andthe next possibility\nthat is checked is the given name without modification, so if you\nhave both wizard.git and wizard.git.git (with or without working\ntree):\n\n        accessing with this name ... will find this repository\n        wizard                       wizard.git\n        wizard.git                   wizard.git\n        wizard.git.git               wizard.git.git\n\nwhich should be much saner.\n"}]}