Re: git stash apply segfaulting when called in subdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 25 Jul 2007, Junio C Hamano wrote:

> Uwe Kleine-König  <ukleinek@xxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
> > 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

It does... And here is a test case:

-- snipsnap --
[PATCH] Test "stash apply" in a subdirectory

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>

---

 t/t3903-stash.sh |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 392ac1c..9e363fd 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -66,4 +66,18 @@ test_expect_success 'apply stashed changes (including index)' '
 	test 1 = $(git show HEAD:file)
 '
 
+test_expect_success 'apply in subdir' '
+	git --git-dir=new init &&
+	cd new &&
+	mkdir dir &&
+	echo one > file &&
+	echo two > dir/file &&
+	git add file dir/file &&
+	git commit -m first &&
+	echo three >> file &&
+	git stash &&
+	cd dir &&
+	git stash apply
+'
+
 test_done

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux