Slight inconsistency between ref delete commands.
Hello,
Was writing conversion script from CVS to git for my repo and noticed slight inconsistency in git-tag, git-branch, and git-update-ref behavior:
$ git --version git version 1.9.3 $ git tag -d && echo success success $ git branch -d && echo success fatal: branch name required $ git update-ref -d && echo success usage: git update-ref [options] -d <refname> [<oldval>] or: git update-ref [options] <refname> <newval> [<oldval>] or: git update-ref [options] --stdin [-z]
-m <reason> reason of the update
-d delete the reference
--no-deref update <refname> not the one it points to
-z stdin has NUL-terminated arguments
--stdin read updates from stdinNoticed when used xargs without -r switch, like this:
git for-each-ref --format="%(refname)" "refs/tags/*-merge" | xargs -n 1 git update-ref -d
-- Sergey.
Quoted 7 lines · Sergei Organov
Was writing conversion script from CVS to git for my repo and noticed slight inconsistency in git-tag, git-branch, and git-update-ref behavior:
$ git --version git version 1.9.3 $ git tag -d && echo success success
This makes sense to me. "tag -d" takes zero or more tags and deletes them.
Quoted 2 lines
$ git branch -d && echo success fatal: branch name required
Here I think "branch -d" is being overly picky. It should behave the same as tag. I'd welcome a patch for that.
Quoted 1 line
$ git update-ref -d && echo success
Here we cannot do the same "zero or more" behavior, because of:
Quoted 1 line
usage: git update-ref [options] -d <refname> [<oldval>]
...we need to be able to take an optional "<oldval>" for each argument.
Quoted 3 lines
Noticed when used xargs without -r switch, like this:
git for-each-ref --format="%(refname)" "refs/tags/*-merge" | xargs -n 1 git update-ref -d
I know this is a side note to the inconsistency you found, but it would be nice to be able to do that with a single update-ref invocation. Not only for simplicity, but also because it would be more efficient (deleting a packed ref has to rewrite the whole packed-refs file; we can get away with one rewrite if we know we are deleting multiple refs).
Recently-ish, update-ref learned a "--stdin" mode, which I think you could use like:
git for-each-ref --format='delete %(refname)' refs/tags/*-merge | git update-ref --stdin
-Peff