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
This commit is contained in:
@ -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);
|
diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt);
|
||||||
break;
|
break;
|
||||||
case UNTRACKED_ONLY:
|
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;
|
break;
|
||||||
case UNTRACKED_INCLUDE:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
log_tree_diff_flush(&rev);
|
log_tree_diff_flush(&rev);
|
||||||
|
@ -367,7 +367,7 @@ test_expect_success 'stash show --only-untracked only shows untracked files' '
|
|||||||
test_cmp expect actual
|
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 reset --hard &&
|
||||||
git clean -xf &&
|
git clean -xf &&
|
||||||
>untracked &&
|
>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_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
|
test_done
|
||||||
|
Reference in New Issue
Block a user