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

Re: [RFC PATCH 1/2] add a --delete option to git push

From
Jeff King <peff@peff.net>
Date
Aug 14, 2009, 05:21 UTC
Message-ID
<20090814052153.GA2881@coredump.intra.peff.net>
In-Reply-To
<1250226349-20397-2-git-send-email-srabbelier@gmail.com>
On Thu, Aug 13, 2009 at 10:05:48PM -0700, Sverre Rabbelier wrote:
> Those new to git have a hard time learning how to delete a remote
> ref. This makes it easier for them to find out how by providing a
> flag to git push.

Should this also impact refs read from the config? E.g., if I do "git push --delete" will it try to impact matching refs (which is almost certainly a mistake), or refs I have in my remote.$X.push (which is probably also a mistake)?

>From reading your patch, it looks like it just touches the command-line.

I think that's the right thing to do, but I think it makes sense to think half a second to make sure.

And with the way you have it, "git push --delete" will silently ignore the --delete and push configured refspecs. Probably it should say "--delete is useless without refspecs on the command line".

>     Currently `git push --delete master:master` results in a somewhat
>     cryptic error message. It seems unlikely however, that those new
>     to git would use the 'old:new' notation, so I haven't bothered
>     guarding against it and settled for documenting it.

It seems like it would be simple enough to just check whether the refspec contains a colon; if so, silently leave it alone. That could also protect configured refspecs, as mentioned above, but I wouldn't rule out somebody have a single-name refspec in their config (in fact, I think "remote.$X.push = HEAD" is reasonable -- should that delete the HEAD on "git push --delete"?).

Show 5 quoted lines
> +--delete::
> +    Delete the specified refs. Prefixes all refs with ':' to tell the
> +    push machinery to delete the specified ref. As such, the refs
> +    that are to be deleted should not contain a ':' specifier.
> +

This impacts _all_ refspecs. Remember that we can have multiple refspecs on the command-line. So I can "move" a ref remotely with:

  git push :old-name old-name:new-name
but I can't do:
  git push --delete old-name old-name:new-name

Ignoring colon-less refspecs would make that work, but would not allow the similar:

  # branch has already been renamed to new-name locally
  git push --delete old-name new-name

So maybe it would make more sense for it to be "--delete <ref>" and impact only a single ref. The simple case of "git push --delete foo" would remain unchanged.

The counter-argument is that "--delete" does not necessarily need to be as powerful as the ":ref" syntax, but I don't see the downside in making it so.

-Peff
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 4 of 18 in “add a --delete option to git push”
  1. 0/2 add a --delete option to git pushSverre Rabbelier, Aug 14, 2009
  2. 1/2 add a --delete option to git pushSverre Rabbelier, Aug 14, 2009
  3. 2/2 test that git push --delete deletes the remote refSverre Rabbelier, Aug 14, 2009
  4. Jeff KingAug 14, 2009
  5. Sverre RabbelierAug 14, 2009
  6. Jeff KingAug 14, 2009
  7. Sverre RabbelierAug 14, 2009
  8. Jeff KingAug 14, 2009
  9. Junio C HamanoAug 14, 2009
  10. Jeff KingAug 14, 2009
  11. Jeff KingAug 14, 2009
  12. Sverre RabbelierAug 14, 2009
  13. Junio C HamanoAug 14, 2009
  14. Junio C HamanoAug 15, 2009
  15. Sverre RabbelierAug 16, 2009
  16. Jakub NarebskiAug 16, 2009
  17. Jakub NarebskiAug 14, 2009
  18. Jakub NarebskiAug 14, 2009

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.