git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Slight inconsistency between ref delete commands.

From
Jeff King <peff@peff.net>
Date
May 21, 2014, 16:49 UTC
Message-ID
<20140521164941.GB2040@sigill.intra.peff.net>
In-Reply-To
<871tvn5shp.fsf@osv.gnss.ru>
On Wed, May 21, 2014 at 02:35:46PM +0400, Sergei Organov wrote:
Show 7 quoted lines
> 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.

> $ 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.

> $ git update-ref -d && echo success
Here we cannot do the same "zero or more" behavior, because of:
> usage: git update-ref [options] -d <refname> [<oldval>]
...we need to be able to take an optional "<oldval>" for each argument.
> 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
Previous: Sergei Organov
Message 2 of 2 in “Slight inconsistency between ref delete commands.”
  1. Sergei OrganovMay 21, 2014
  2. Jeff KingMay 21, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.