Skip to content

Commit 8aed803

Browse files
committed
Merge branch 'tg/stash-in-c-show-default-to-p-fix'
A regression fix. * tg/stash-in-c-show-default-to-p-fix: stash: setup default diff output format if necessary
2 parents 0ba1ba4 + 8e407bc commit 8aed803

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

builtin/stash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,10 @@ static int show_stash(int argc, const char **argv, const char *prefix)
761761
free_stash_info(&info);
762762
usage_with_options(git_stash_show_usage, options);
763763
}
764+
if (!rev.diffopt.output_format) {
765+
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
766+
diff_setup_done(&rev.diffopt);
767+
}
764768

765769
rev.diffopt.flags.recursive = 1;
766770
setup_diff_pager(&rev.diffopt);

t/t3903-stash.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,24 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
612612
test_cmp expected actual
613613
'
614614

615+
test_expect_success 'stash show --patience shows diff' '
616+
git reset --hard &&
617+
echo foo >>file &&
618+
STASH_ID=$(git stash create) &&
619+
git reset --hard &&
620+
cat >expected <<-EOF &&
621+
diff --git a/file b/file
622+
index 7601807..71b52c4 100644
623+
--- a/file
624+
+++ b/file
625+
@@ -1 +1,2 @@
626+
baz
627+
+foo
628+
EOF
629+
git stash show --patience ${STASH_ID} >actual &&
630+
test_cmp expected actual
631+
'
632+
615633
test_expect_success 'drop: fail early if specified stash is not a stash ref' '
616634
git stash clear &&
617635
test_when_finished "git reset --hard HEAD && git stash clear" &&

0 commit comments

Comments
 (0)