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

Re: [PATCH] git stash: Avoid data loss when saving a stash

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 28, 2013, 19:37 UTC
Message-ID
<7vbo6qni1d.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130628150532.GD12252@machine.or.cz>
Petr Baudis <pasky@ucw.cz> writes:
Show 10 quoted lines
> diff --git a/git-stash.sh b/git-stash.sh
> index 1e541a2..3cb9b05 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -258,6 +262,12 @@ save_stash () {
>  		say "$(gettext "No local changes to save")"
>  		exit 0
>  	fi
> +	if test -z "$untracked$force" -a -n "$(git ls-files --killed | head -n 1)"; then
> +		say "$(gettext "The following untracked files would NOT be saved but need to be removed by stash save:")"

I think "ls-files --killed" was not adjusted for the new world order when submodules were introduced. With this change, you see t7402 break, even though "git status" would say

# Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working # directory) # # modified: file # modified: submodule (new commits)

The path "submodule" in HEAD and the index is already submodule, so "stash save" that reverts to the original state will _not_ have to kill it, but the new check triggers it.

Exactly the same breakage this patch introduces triggers in t7610, too.

I think another patch to teach "ls-files --killed" what to do with submodules is needed as a preliminary step before this patch.

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 10 in “git stash: Avoid data loss when saving a stash”
  1. git stash: Avoid data loss when saving a stashPetr Baudis, Jun 28, 2013
  2. Junio C HamanoJun 28, 2013
  3. Junio C HamanoJun 28, 2013
  4. Junio C HamanoJun 28, 2013
  5. Petr BaudisJun 30, 2013
  6. Junio C HamanoJun 30, 2013
  7. Petr BaudisJul 6, 2013
  8. 0/2 Safety for "stash save"Junio C Hamano, Jul 1, 2013
  9. 1/2 treat_directory(): do not declare submodules to be untrackedJunio C Hamano, Jul 1, 2013
  10. 2/2 git stash: avoid data loss when "git stash save" kills a directoryJunio C Hamano, Jul 1, 2013

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.