1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-06 15:46:41 +02:00

Merge branch 'aj/stash-staged-fix' into next

"git stash -S" did not handle binary files correctly, which has
been corrected.

* aj/stash-staged-fix:
  stash: fix "--staged" with binary files
This commit is contained in:
Junio C Hamano 2024-04-23 15:07:01 -07:00
commit d49e9dade0
2 changed files with 11 additions and 2 deletions

View File

@ -1205,8 +1205,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;

View File

@ -393,6 +393,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_grep -e "subcommand wasn'\''t specified; '\''push'\'' can'\''t be assumed due to unexpected token '\''drop'\''" err