{"thread":{"id":"30035","subject":"howto handle name clashes","startedAt":"2012-03-23T13:06:01Z","lastAt":"2012-03-24T00:19:59Z","messageCount":6,"participants":["Sven Strickroth","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"187569","messageId":"4F6C7539.3080607@tu-clausthal.de","threadId":"30035","inReplyTo":null,"subject":"howto handle name clashes","fromName":"Sven Strickroth","fromEmail":"sven.strickroth@tu-clausthal.de","sentAt":"2012-03-23T13:06:01Z","receivedAt":"2012-03-23T13:06:01Z","isPatch":false,"sender":{"key":"sven.strickroth@tu-clausthal.de","avatar":null},"body":"Hi,\n\nhow to handle name clashes for branches and tags? Is there anything I\ncan add to the refspec to make the name unique?\n\nE.g.\n- for merging \"git merge --no-ff refs/branches/test\" works, but\ngenerates a not so nice default merge message. (\"merged  commit\nrefs/branches/test\" instead of \"merged branch test\")\n- how to drop a remote tag/branch (\"git push origin :test\" does not work)\n\n-- \nBest regards,\n Sven Strickroth\n ClamAV, a GPL anti-virus toolkit   http://www.clamav.net\n PGP key id F5A9D4C4 @ any key-server\n"},{"id":"187581","messageId":"20120323171219.GB12881@sigill.intra.peff.net","threadId":"30035","inReplyTo":"4F6C7539.3080607@tu-clausthal.de","subject":"Re: howto handle name clashes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-23T17:12:19Z","receivedAt":"2012-03-23T17:12:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 23, 2012 at 02:06:01PM +0100, Sven Strickroth wrote:\n\n> how to handle name clashes for branches and tags? Is there anything I\n> can add to the refspec to make the name unique?\n\nYou can always use a more fully-qualified name to disambiguate (e.g.,\n\"tags/foo\", or \"refs/tags/foo\").\n\n> - for merging \"git merge --no-ff refs/branches/test\" works, but\n> generates a not so nice default merge message. (\"merged  commit\n> refs/branches/test\" instead of \"merged branch test\")\n\nDid you mean \"refs/heads/test\"?\n\nI would have thought we would full-qualify the refname first, and then\nuse that to determine the message. Doing a simple test, it looks like\n\"git merge foo\" gets you \"Merge branch 'foo'\", but \"git merge heads/foo\"\nwill get you \"Merge branch 'heads/foo'\". We should be able to do better\nin the latter case.\n\n> - how to drop a remote tag/branch (\"git push origin :test\" does not work)\n\nDoes \"git push origin :heads/foo\" (or :tags/foo) not work?\n\n-Peff\n"},{"id":"187588","messageId":"4F6CB649.8080006@tu-clausthal.de","threadId":"30035","inReplyTo":"20120323171219.GB12881@sigill.intra.peff.net","subject":"Re: howto handle name clashes","fromName":"Sven Strickroth","fromEmail":"sven.strickroth@tu-clausthal.de","sentAt":"2012-03-23T17:43:37Z","receivedAt":"2012-03-23T17:43:37Z","isPatch":false,"sender":{"key":"sven.strickroth@tu-clausthal.de","avatar":null},"body":"Am 23.03.2012 18:12 schrieb Jeff King:\n>> - for merging \"git merge --no-ff refs/branches/test\" works, but\n>> generates a not so nice default merge message. (\"merged  commit\n>> refs/branches/test\" instead of \"merged branch test\")\n> \n> Did you mean \"refs/heads/test\"?\n\nyes. Your example was the correct one. Thanks for spotting my problem.\n\n>> - how to drop a remote tag/branch (\"git push origin :test\" does not work)\n> \n> Does \"git push origin :heads/foo\" (or :tags/foo) not work?\n\nseems to work. Thanks.\n\nReally problematic is checkout:\n\"git checkout heads/foo\" creates a detached HEAD (is this intended).\nHowever, \"git checkout heads/foo -B foo\" can be used.\n\nIs there a git command to find out if a name is ambiguous?\n\"git rev-parse foo\" outputs \"warning: refname 'test' is ambiguous.\", but\nthe return code is zero.\n\n-- \nBest regards,\n Sven Strickroth\n ClamAV, a GPL anti-virus toolkit   http://www.clamav.net\n PGP key id F5A9D4C4 @ any key-server\n"},{"id":"187595","messageId":"7vlimrtbrg.fsf@alter.siamese.dyndns.org","threadId":"30035","inReplyTo":"4F6C7539.3080607@tu-clausthal.de","subject":"Re: howto handle name clashes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-23T18:25:55Z","receivedAt":"2012-03-23T18:25:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sven Strickroth <sven.strickroth@tu-clausthal.de> writes:\n\n> how to handle name clashes for branches and tags? Is there anything I\n> can add to the refspec to make the name unique?\n>\n> E.g.\n> - for merging \"git merge --no-ff refs/branches/test\" works, but\n> generates a not so nice default merge message. (\"merged  commit\n> refs/branches/test\" instead of \"merged branch test\")\n\nThat's the price you pay for naming different things the same and having\nto disambiguate it.\n\n> - how to drop a remote tag/branch (\"git push origin :test\" does not work)\n\n\"git push origin :refs/tags/test\"\n\nIt is sad that some people teach new people shorthand without telling them\nthat what they are teaching are merely shorthand and cause confusion like\nthis.\n"},{"id":"187597","messageId":"20120323182941.GA14236@sigill.intra.peff.net","threadId":"30035","inReplyTo":"4F6CB649.8080006@tu-clausthal.de","subject":"Re: howto handle name clashes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-23T18:29:52Z","receivedAt":"2012-03-23T18:29:52Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 23, 2012 at 06:43:37PM +0100, Sven Strickroth wrote:\n\n> Really problematic is checkout:\n> \"git checkout heads/foo\" creates a detached HEAD (is this intended).\n> However, \"git checkout heads/foo -B foo\" can be used.\n\nCheckout is unlike regular ref lookup in that it prefers branches to\nother forms (because it is fundamentally a branch operation). So \"git\ncheckout foo\" should always choose \"refs/heads/foo\". We do still seem to\ngive the ambiguity warning, though, which seems like overkill.\n\nI think that generally people would want to get rid of ambiguous refs as\nsoon as they notice them, as they are a recipe for disaster. So the\nwarning being annoying has not been considered a huge problem.\n\n> Is there a git command to find out if a name is ambiguous?\n> \"git rev-parse foo\" outputs \"warning: refname 'test' is ambiguous.\", but\n> the return code is zero.\n\nI think you could do:\n\n  case \"$(git show-ref --tags --heads $name | wc -l)\" in\n  0) echo \"$name does not exist\" ;;\n  1) echo \"$name is unambiguous\" ;;\n  *) echo \"$name is ambiguous\" ;;\n  esac\n\nYou could also get a list of all ambiguous refs like this:\n\n  git for-each-ref --format='%(refname:short)' refs/heads refs/tags |\n  egrep '^(heads|tags)'\n\nThe \":short\" modifier will shorten names unambiguously, so it ends up\nleaving the \"heads\" and \"tags\" in for ambiguous names.\n\n-Peff\n"},{"id":"187623","messageId":"4F6D132F.6020504@tu-clausthal.de","threadId":"30035","inReplyTo":"20120323171219.GB12881@sigill.intra.peff.net","subject":"Re: howto handle name clashes","fromName":"Sven Strickroth","fromEmail":"sven.strickroth@tu-clausthal.de","sentAt":"2012-03-24T00:19:59Z","receivedAt":"2012-03-24T00:19:59Z","isPatch":false,"sender":{"key":"sven.strickroth@tu-clausthal.de","avatar":null},"body":"Am 23.03.2012 18:12 schrieb Jeff King:\n>> - how to drop a remote tag/branch (\"git push origin :test\" does not\n>> work)\n>\n> Does \"git push origin :heads/foo\" (or :tags/foo) not work?\n\nwell, \":heads/foo\" does not work. Imagine I want to drop a remote branch\nwhich is ambiguous (e.g. a tag with same name exists) on the repository:\n\n\"git push origin :food\"\n\ngives me: \"error: dst refspec food matches more than one.\"\n\nHowever, deleting the remote tag (:tags/foo) works with your suggestion.\n\n\"git push origin :refs/remotes/origin/foo\" showed success (and warning\n\"remote: warning: Allowing deletion of corrupt ref.\"), but did not work.\n\n-- \nBest regards,\n Sven Strickroth\n ClamAV, a GPL anti-virus toolkit   http://www.clamav.net\n PGP key id F5A9D4C4 @ any key-server\n"}]}