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

recent 'unpack_trees()'-related changes break 'git stash'

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 15, 2008, 01:41 UTC
Message-ID
<20080315014133.GB32265@neumann>
Hi,

t3903-stash.sh _sometimes_ fails at the 'drop middle stash' testcase. After playing around with it this evening I was able to narrow it down, and turned out that it has nothing to do with 'git stash drop', but something is broken behind 'stash'.

Unfortunately, I can't reproduce the bug reliably. Here is a testcase, that sometimes fails:

test_description='Test git-stash'
. ./test-lib.sh
test_expect_success 'try to catch some rare occurring stash bug' '
	echo 1 > file &&
	git add file &&
	test_tick &&
	git commit -m initial &&
	echo 2 > file &&
	test_tick &&
	git stash &&
	test 2 = $(git stash show stash@{0} | wc -l) &&
	echo "after first show test"
	echo 3 > file &&
	git stash &&
	test 2 = $(git stash show stash@{0} | wc -l) &&
	echo "after second show test"
'
test_done

and here is a loop to run the above testcase until it fails (take care, it deletes ./trash at the beginning!):

ret=0
i=0
while test $ret = 0 ; do
	rm -rf ./trash
	./mystashtest.sh --verbose
	ret=$?
	i=$((++i))
done
echo "test failed at ${i}. run"
Both should go into t/ directory.

The testcase usually fails during the first 25 run, but sometimes it runs more than 100 times before failing. The test fails because the second 'git stash' sometimes does something wrong: there is no difference between stash@{0} and the clean working tree. There is no error message from 'git stash' upon failure. During all the test runs I never saw a failure occuring at the first 'git stash'.

I ran bisect using these scripts, and it turned out that the bug was introduced by 34110cd4 (Make 'unpack_trees()' have a separate source and destination index, 2008-03-06).

I have tried whether it has already been fixed in next or pu, but those branches are affected, too.

Best, Gábor

Next: Linus Torvalds
Message 1 of 8 in “recent 'unpack_trees()'-related changes break 'git stash'”
  1. SZEDER GáborMar 15, 2008
  2. Fix recent 'unpack_trees()'-related changes breaking 'git stash'Linus Torvalds, Mar 15, 2008
  3. Linus TorvaldsMar 15, 2008
  4. Szeder GáborMar 15, 2008
  5. Junio C HamanoMar 15, 2008
  6. Szeder GáborMar 15, 2008
  7. Linus TorvaldsMar 15, 2008
  8. git-stash: use git-read-tree --index-output optionしらいしななこ, Mar 30, 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.