summaryrefslogtreecommitdiff
path: root/t/t3905-stash-include-untracked.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2021-05-12 20:16:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-12 23:48:59 (GMT)
commit1ff595d218d9175eee1db753844044c2746d0515 (patch)
treed9d03e88268610d8068991429bab02d7fdfa4dc1 /t/t3905-stash-include-untracked.sh
parentaa2b05d9f66f5c167a7a377e2a0990f4af835e71 (diff)
downloadgit-1ff595d218d9175eee1db753844044c2746d0515.zip
git-1ff595d218d9175eee1db753844044c2746d0515.tar.gz
git-1ff595d218d9175eee1db753844044c2746d0515.tar.bz2
stash show: fix segfault with --{include,only}-untracked
When `git stash show --include-untracked` or `git stash show --only-untracked` is run on a stash that doesn't include an untracked entry, a segfault occurs. This happens because we do not check whether the untracked entry is actually present and just attempt to blindly dereference it. Ensure that the untracked entry is present before actually attempting to dereference it. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3905-stash-include-untracked.sh')
-rwxr-xr-xt/t3905-stash-include-untracked.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 2e67967..1c97659 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -405,4 +405,19 @@ test_expect_success 'stash show --include-untracked errors on duplicate files' '
test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err
'
+test_expect_success 'stash show --{include,only}-untracked on stashes without untracked entries' '
+ git reset --hard &&
+ git clean -xf &&
+ >tracked &&
+ git add tracked &&
+ git stash &&
+
+ git stash show >expect &&
+ git stash show --include-untracked >actual &&
+ test_cmp expect actual &&
+
+ git stash show --only-untracked >actual &&
+ test_must_be_empty actual
+'
+
test_done