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

Re: Stash missing, but not. Can apply, but not drop or list the stash.

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Sep 23, 2008, 23:08 UTC
Message-ID
<klevRMI-z5Id8iuqn2rqrKQZ8LdPNE4lABeC502X9y1Es5wwQ-s8GA@cipher.nrlssc.navy.mil>
In-Reply-To
<1222204981.28575.1275592473@webmail.messagingengine.com>
mattjackets wrote:
> I have a strange stash problem.  There is a single stash in the repo.
> 
> git stash apply 0  --  works, but results in a conflict.
The correct form is 'git stash apply stash@{0}'

'git stash apply 0' is doing the right thing for the wrong reason. For example, 'git stash apply 1' would not do the right thing.

This is unrelated to your issue, but it seems you have uncovered a flaw which should be fixed.

In git stash, when your command line above is used, eventually the following command is executed:

    git rev-parse --revs-only --no-flags --default refs/stash 0

'git rev-parse' fails to resolve revision "0" and prints out nothing and then falls back to printing the revision of "refs/stash". This is not what is desired by stash.

Either rev-parse needs to error out in this case, or 'git stash' needs to be changed so that '--default refs/stash' is not used here. Possibly, something like what is done inside drop_stash().

Show 11 quoted lines
>  Lets just go
> ahead and drop the stash...
> 
> git stash list  --  shows nothing.  huh?  Lets go ahead with the drop
> anyway and hope it works...
> 
> $ git stash drop stash@{0}
> fatal: Log .git/logs/refs/stash is empty.
> stash@{0}: not a valid stashed state
> 
> sure enough, .git/logs/refs/stash is empty

Right, it must exist since you actually got the error message 'fatal: Log .git/logs/refs/stash is empty', but it contains nothing. Not sure how that happened.

> git stash clear  --  does nothing
It correctly removes .git/refs/stash for me.
> I'm at a loss.  I can apply the stash cleanly to older revisions, and
> gitk still shows the stash branch.  How can I fix this?  is it safe to
> simply delete the stash branch as if it was any other branch?

In this case yes it would be safe to just do 'rm .git/refs/stash', but like I said, 'git stash clear' worked for me.

-brandon
Previous: mattjacketsNext: Brandon Casey
Message 2 of 5 in “Stash missing, but not. Can apply, but not drop or list the stash.”
  1. mattjacketsSep 23, 2008
  2. Brandon CaseySep 23, 2008
  3. git-stash.sh: don't default to refs/stash if invalid ref suppliedBrandon Casey, Sep 23, 2008
  4. regression: stash show -p (was [PATCH maint] git-stash.sh: don't default to refs/stash if invalid ref supplied)Brandon Casey, Oct 1, 2008
  5. git-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c1)Brandon Casey, Oct 2, 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.