{"thread":{"id":"36722","subject":"Slight inconsistency between ref delete commands.","startedAt":"2014-05-21T10:35:46Z","lastAt":"2014-05-21T16:49:41Z","messageCount":2,"participants":["Sergei Organov","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242372","messageId":"871tvn5shp.fsf@osv.gnss.ru","threadId":"36722","inReplyTo":null,"subject":"Slight inconsistency between ref delete commands.","fromName":"Sergei Organov","fromEmail":"osv@javad.com","sentAt":"2014-05-21T10:35:46Z","receivedAt":"2014-05-21T10:35:46Z","isPatch":false,"sender":{"key":"osv@javad.com","avatar":null},"body":"Hello,\n\nWas writing conversion script from CVS to git for my repo and noticed\nslight inconsistency in git-tag, git-branch, and git-update-ref behavior:\n\n$ git --version\ngit version 1.9.3\n$ git tag -d && echo success\nsuccess\n$ git branch -d && echo success\nfatal: branch name required\n$ git update-ref -d && echo success\nusage: git update-ref [options] -d <refname> [<oldval>]\n   or: git update-ref [options]    <refname> <newval> [<oldval>]\n   or: git update-ref [options] --stdin [-z]\n\n    -m <reason>           reason of the update\n    -d                    delete the reference\n    --no-deref            update <refname> not the one it points to\n    -z                    stdin has NUL-terminated arguments\n    --stdin               read updates from stdin\n\n\nNoticed when used xargs without -r switch, like this:\n\ngit for-each-ref --format=\"%(refname)\" \"refs/tags/*-merge\" | xargs -n 1 git update-ref -d\n\n-- Sergey.\n"},{"id":"242386","messageId":"20140521164941.GB2040@sigill.intra.peff.net","threadId":"36722","inReplyTo":"871tvn5shp.fsf@osv.gnss.ru","subject":"Re: Slight inconsistency between ref delete commands.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-05-21T16:49:41Z","receivedAt":"2014-05-21T16:49:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 21, 2014 at 02:35:46PM +0400, Sergei Organov wrote:\n\n> Was writing conversion script from CVS to git for my repo and noticed\n> slight inconsistency in git-tag, git-branch, and git-update-ref behavior:\n> \n> $ git --version\n> git version 1.9.3\n> $ git tag -d && echo success\n> success\n\nThis makes sense to me. \"tag -d\" takes zero or more tags and deletes\nthem.\n\n> $ git branch -d && echo success\n> fatal: branch name required\n\nHere I think \"branch -d\" is being overly picky. It should behave the\nsame as tag. I'd welcome a patch for that.\n\n> $ git update-ref -d && echo success\n\nHere we cannot do the same \"zero or more\" behavior, because of:\n\n> usage: git update-ref [options] -d <refname> [<oldval>]\n\n...we need to be able to take an optional \"<oldval>\" for each argument.\n\n> Noticed when used xargs without -r switch, like this:\n> \n> git for-each-ref --format=\"%(refname)\" \"refs/tags/*-merge\" | xargs -n 1 git update-ref -d\n\nI know this is a side note to the inconsistency you found, but it would\nbe nice to be able to do that with a single update-ref invocation. Not\nonly for simplicity, but also because it would be more efficient\n(deleting a packed ref has to rewrite the whole packed-refs file; we can\nget away with one rewrite if we know we are deleting multiple refs).\n\nRecently-ish, update-ref learned a \"--stdin\" mode, which I think you\ncould use like:\n\n  git for-each-ref --format='delete %(refname)' refs/tags/*-merge |\n  git update-ref --stdin\n\n-Peff\n"}]}