Bug: 'git stash --staged' crashes with binary files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stage a binary file and run 'git stash --staged'. The stash is created but
the command fails to remove changes from the index:

$ echo -n "\0" >file

$ git add file

$ git stash --staged
Saved working directory and index state WIP on main: e7911b6 Whatever
error: cannot apply binary patch to 'file' without full index line
error: file: patch does not apply
Cannot remove worktree changes

$ git status
...
Changes to be committed:
        new file:   file

The "remove from the index" step seems not to be binary-compatible.

The below patch adds a reproducing test.

diff --git t/t3903-stash.sh t/t3903-stash.sh
index 376cc8f4ab..5e3ea64f38 100755
--- t/t3903-stash.sh
+++ t/t3903-stash.sh
@@ -392,6 +392,13 @@ setup_stash()
     git stash pop &&
     test bar,bar4 = $(cat file),$(cat file2)
 '
+test_expect_success 'stash --staged with binary file' '
+    echo -n "\0" >file &&
+    git add file &&
+    git stash --staged &&
+    git stash pop &&
+    test "\0" = $(cat file)
+'

 test_expect_success 'dont assume push with non-option args' '
     test_must_fail git stash -q drop 2>err &&



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux