diff options
-rw-r--r-- | builtin/stash.c | 4 | ||||
-rwxr-xr-x | t/t3903-stash.sh | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index 86cd0b456e..f4ec21e515 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1147,8 +1147,8 @@ static int stash_staged(struct stash_info *info, struct strbuf *out_patch, } cp_diff_tree.git_cmd = 1; - strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD", - oid_to_hex(&info->w_tree), "--", NULL); + strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "--binary", + "-U1", "HEAD", oid_to_hex(&info->w_tree), "--", NULL); if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) { ret = -1; goto done; diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 686747e55a..a62b3a3d40 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -318,6 +318,15 @@ test_expect_success 'stash --staged' ' test bar,bar4 = $(cat file),$(cat file2) ' +test_expect_success 'stash --staged with binary file' ' + printf "\0" >file && + git add file && + git stash --staged && + git stash pop && + printf "\0" >expect && + test_cmp expect file +' + test_expect_success 'dont assume push with non-option args' ' test_must_fail git stash -q drop 2>err && test_i18ngrep -e "subcommand wasn'\''t specified; '\''push'\'' can'\''t be assumed due to unexpected token '\''drop'\''" err |