Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-16 15:05:24 +0300
committerJunio C Hamano <gitster@pobox.com>2021-05-16 15:05:24 +0300
commita8a2491e629f9f886705d8bca6e134cd15076810 (patch)
tree7ddad481b9dd099ac6ce983c2fae4c14d0772aef
parent16f91451fae2f3b12cbbc372bd6a5104e8109076 (diff)
parent1ff595d218d9175eee1db753844044c2746d0515 (diff)
Merge branch 'dl/stash-show-untracked-fixup'
The code to handle options recently added to "git stash show" around untracked part of the stash segfaulted when these options were used on a stash entry that does not record untracked part. * dl/stash-show-untracked-fixup: stash show: fix segfault with --{include,only}-untracked t3905: correct test title
-rw-r--r--builtin/stash.c8
-rwxr-xr-xt/t3905-stash-include-untracked.sh17
2 files changed, 22 insertions, 3 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index d68ed784d2..56a33fb83a 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -902,10 +902,14 @@ static int show_stash(int argc, const char **argv, const char *prefix)
diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt);
break;
case UNTRACKED_ONLY:
- diff_root_tree_oid(&info.u_tree, "", &rev.diffopt);
+ if (info.has_u)
+ diff_root_tree_oid(&info.u_tree, "", &rev.diffopt);
break;
case UNTRACKED_INCLUDE:
- diff_include_untracked(&info, &rev.diffopt);
+ if (info.has_u)
+ diff_include_untracked(&info, &rev.diffopt);
+ else
+ diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt);
break;
}
log_tree_diff_flush(&rev);
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 8314ab21d4..5bed8fd2fd 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -367,7 +367,7 @@ test_expect_success 'stash show --only-untracked only shows untracked files' '
test_cmp expect actual
'
-test_expect_success 'stash show --no-include-untracked cancels --{include,show}-untracked' '
+test_expect_success 'stash show --no-include-untracked cancels --{include,only}-untracked' '
git reset --hard &&
git clean -xf &&
>untracked &&
@@ -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