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

Re: git stash apply segfaulting when called in subdir

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 25, 2007, 22:28 UTC
Message-ID
<7v1wewdsoz.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070725212311.GA13325@cassiopeia>
Uwe Kleine-König  <ukleinek@informatik.uni-freiburg.de> writes:
Show 22 quoted lines
> zeisberg@cassiopeia:/tmp$ mkdir repo; cd repo; git init
> Initialized empty Git repository in .git/
>
> zeisberg@cassiopeia:/tmp/repo$ mkdir dir; echo one > file; echo two > dir/file
>
> zeisberg@cassiopeia:/tmp/repo$ git add file dir/file
>
> zeisberg@cassiopeia:/tmp/repo$ git commit -m tralala
> Created initial commit 265b7d7: tralala
>  2 files changed, 2 insertions(+), 0 deletions(-)
>  create mode 100644 dir/file
>  create mode 100644 file
>
> zeisberg@cassiopeia:/tmp/repo$ echo three >> file
>
> zeisberg@cassiopeia:/tmp/repo$ git stash
> Saved "WIP on master: 265b7d7... tralala"
> HEAD is now at 265b7d7... tralala
>
> zeisberg@cassiopeia:/tmp/repo$ cd dir; git stash apply
> error: missing object referenced by '696146c2a44d7fc4d5ae4a71589c4c0d84f59789'
> /home/zeisberg/usr/bin/git-stash: line 111: 13618 Segmentation fault      git-merge-recursive $b_tree -- $c_tree $w_tree

This probably is a merge-recursive bug, but in the meantime, I think this should fix it.

---
 git-stash.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index de13dd1..d9cd42d 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -6,6 +6,7 @@ USAGE='[ | list | show | apply | clear]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
+cd_to_toplevel
 
 TMP="$GIT_DIR/.git-stash.$$"
 trap 'rm -f "$TMP-*"' 0
Previous: Uwe Kleine-KönigNext: Johannes Schindelin
Message 2 of 7 in “git stash apply segfaulting when called in subdir”
  1. Uwe Kleine-KönigJul 25, 2007
  2. Junio C HamanoJul 25, 2007
  3. Johannes SchindelinJul 25, 2007
  4. Jeff KingJul 26, 2007
  5. Johannes SchindelinJul 26, 2007
  6. Jeff KingJul 26, 2007
  7. Steven WalterJul 25, 2007

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.