git stash apply segfaulting when called in subdir
Hello,
I did not do much testing and didn't look into the issue yet:
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
Best regards
Uwe
Signature · 3 lines
Uwe Kleine-König http://www.google.com/search?q=1+newton+in+kg*m+%2F+s%5E2
Quoted 3 lines · Uwe Kleine-König
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
I've been seeing this, as well.
Signature · 8 lines
-Steven Walter <[email protected]> "A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." -Robert Heinlein
Quoted 15 lines · Uwe Kleine-König
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/filezeisberg@cassiopeia:/tmp/repo$ git add file dir/filezeisberg@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 filezeisberg@cassiopeia:/tmp/repo$ echo three >> file
Quoted 7 lines
zeisberg@cassiopeia:/tmp/repo$ git stash Saved "WIP on master: 265b7d7... tralala" HEAD is now at 265b7d7... tralalazeisberg@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(-)
git-stash.sh +1 -0
@@ -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
Quoted 6 lines · Junio C Hamano
Quoted 3 lines
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_treeThis probably is a merge-recursive bug, but in the meantime, I think this should fix it.
The merge-recursive bug is simply a failure to check for invalid input. Patch to at least print and die rather than segfault is below. Technically the error could be from a tag dereference, too, so maybe the error message should be more exact?
-- >8 --
merge-recursive: don't segfault on missing input objects
This should generally never happen, but it's nicer to report an error than to segfault.
--- merge-recursive.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
merge-recursive.c +2 -0
@@ -1692,6 +1692,8 @@ static struct commit *get_ref(const char *ref)if (get_sha1 (ref, sha1))die ("Could not resolve ref '%s'" , ref); object =deref_tag (parse_object (sha1), ref,strlen (ref)); +if (!object) +die ("Object does not exist: %s" , ref);if (object->type ==OBJ_TREE )return make_virtual_commit ((struct tree *)object,better_branch_name (ref));
Signature · 1 line
1.5.3.rc3.818.gc1dc7-dirty
Hi,
Quoted 10 lines · Jeff King
Quoted 6 lines · Junio C Hamano
Quoted 3 lines
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_treeThis probably is a merge-recursive bug, but in the meantime, I think this should fix it.
The merge-recursive bug is simply a failure to check for invalid input.
No it is not.
The objects are there. But the objects cannot be found, since merge-recursive cannot go to top level.
Ciao,
Dscho
Quoted 6 lines · Johannes Schindelin
Quoted 1 line
The merge-recursive bug is simply a failure to check for invalid input.
No it is not.
The objects are there. But the objects cannot be found, since merge-recursive cannot go to top level.
Fair enough, I should have looked a little further. However, I still wonder if it's better to report an error than to segfault.
-Peff
Hi,
Quoted 38 lines · Junio C Hamano
Quoted 15 lines · Uwe Kleine-König
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/filezeisberg@cassiopeia:/tmp/repo$ git add file dir/filezeisberg@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 filezeisberg@cassiopeia:/tmp/repo$ echo three >> fileQuoted 7 lines
zeisberg@cassiopeia:/tmp/repo$ git stash Saved "WIP on master: 265b7d7... tralala" HEAD is now at 265b7d7... tralalazeisberg@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_treeThis 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(-)git-stash.sh +0
-0
git-stash.sh USAGE='[ | list | show | apply | clear]' · line 12
Quoted 7 lines
git-stash.sh +1
-0@@ -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
---
t/t3903-stash.sh | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
t/t3903-stash.sh +14 -0
@@ -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