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

Re: [PATCH WIP] git-stash: add new 'drop' subcommand

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 6, 2008, 23:53 UTC
Message-ID
<alpine.LSU.1.00.0802062333080.8543@racer.site>
In-Reply-To
<47A9DE06.9050307@nrlssc.navy.mil>
Hi,
On Wed, 6 Feb 2008, Brandon Casey wrote:
> This allows a single stash entry to be deleted. It takes an optional 
> argument which is a stash reflog entry. If no arguments are supplied, it 
> drops the most recent stash entry.

Just to repeat my opinion: "drop" is not useful. I think 'git stash pop "$1"' = 'git stash apply "$1" && git stash drop "$1"' would be a sane interface.

And this means that a multiple drop would become uninteresting.

As for your reflog delete with multiple arguments... Right. This needs a change in the callback data cmd_reflog_expire_cb, recno needs to become a pointer to an int, instead of an int. Then, cmd_delete() has to allocate argc + 1 int values, setting the last to -1. It has to shift the recno pointer in the loop to the respective next element of this allocated array. The values need to be sorted after the loop in ascending order. Then, in a loop from the last to the second entry, the _difference_ array[i] - array[i-1] has to be stored in array[i]. Also, recno has to be reset to the first element in the array. Then, expire_reflog_ent() has to be changed to check "recno && *recno >= 0", and if "--*(cb->cmd->recno) == 0", it not only has to prune, but before that increment cb->cmd->recno, so it points to the next element of the array.

Also, I think that "reflog delete" should probably just realise when it deleted the last element, and update the ref with the new last element (or delete it if none is left).

Ciao, Dscho

Previous: Junio C Hamano
Message 9 of 9 in “git-stash: alias 'list' to 'ls' and 'clear' to 'rm'”
  1. git-stash: alias 'list' to 'ls' and 'clear' to 'rm'Tim Stoakes, Feb 5, 2008
  2. Wincent ColaiutaFeb 5, 2008
  3. Tim StoakesFeb 5, 2008
  4. Wincent ColaiutaFeb 5, 2008
  5. Johannes SchindelinFeb 5, 2008
  6. git-stash: add new 'drop' subcommandBrandon Casey, Feb 6, 2008
  7. Paolo BonziniFeb 6, 2008
  8. Junio C HamanoFeb 6, 2008
  9. Johannes SchindelinFeb 6, 2008

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.