@ -601,4 +601,28 @@ test_expect_success 'stash apply shows status same as git status (relative to cu
@@ -601,4 +601,28 @@ test_expect_success 'stash apply shows status same as git status (relative to cu
test_cmp expect actual
'
cat > expect << EOF
diff --git a/HEAD b/HEAD
new file mode 100644
index 0000000..fe0cbee
--- /dev/null
+++ b/HEAD
@@ -0,0 +1 @@
+file-not-a-ref
EOF
test_expect_success 'stash where working directory contains "HEAD" file' '
git stash clear &&
git reset --hard &&
echo file-not-a-ref > HEAD &&
git add HEAD &&
test_tick &&
git stash &&
git diff-files --quiet &&
git diff-index --cached --quiet HEAD &&
test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
@ -17,6 +17,7 @@ test_expect_success 'stash save --include-untracked some dirty working directory
@@ -17,6 +17,7 @@ test_expect_success 'stash save --include-untracked some dirty working directory
echo 3 > file &&
test_tick &&
echo 1 > file2 &&
echo 1 > HEAD &&
mkdir untracked &&
echo untracked >untracked/untracked &&
git stash --include-untracked &&
@ -35,6 +36,13 @@ test_expect_success 'stash save --include-untracked cleaned the untracked files'
@@ -35,6 +36,13 @@ test_expect_success 'stash save --include-untracked cleaned the untracked files'
'
cat > expect.diff <<EOF
diff --git a/HEAD b/HEAD
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/HEAD
@@ -0,0 +1 @@
+1
diff --git a/file2 b/file2
new file mode 100644
index 0000000..d00491f
@ -51,14 +59,16 @@ index 0000000..5a72eb2
@@ -51,14 +59,16 @@ index 0000000..5a72eb2
+untracked
EOF
cat > expect.lstree <<EOF
HEAD
file2
untracked
EOF
test_expect_success 'stash save --include-untracked stashed the untracked files' '
test "!" -f file2 &&
test ! -e untracked &&
git diff HEAD stash^3 -- file2 untracked >actual &&
test_path_is_missing file2 &&
test_path_is_missing untracked &&
test_path_is_missing HEAD &&
git diff HEAD stash^3 -- HEAD file2 untracked >actual &&