Merge branch 'kd/stash-with-bash-4.4' into next
authorJunio C Hamano <gitster@pobox.com>
Sun, 20 Aug 2017 06:07:16 +0000 (23:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 Aug 2017 06:07:16 +0000 (23:07 -0700)
bash 4.4 or newer gave a warning on NUL byte in command
substitution done in "git stash"; this has been squelched.

* kd/stash-with-bash-4.4:
stash: prevent warning about null bytes in input

1  2 
git-stash.sh
diff --combined git-stash.sh
index d7bc3224bf852f9840c3ca295492a73d75884a88,5f09a47f0aa9abd85f1d4ed5a5892d23d0230aba..8b2ce9afdab6d67e8b9af5fc97a30dc6941323f2
@@@ -43,9 -43,16 +43,16 @@@ no_changes () 
  }
  
  untracked_files () {
+       if test "$1" = "-z"
+       then
+               shift
+               z=-z
+       else
+               z=
+       fi
        excl_opt=--exclude-standard
        test "$untracked" = "all" && excl_opt=
-       git ls-files -o -z $excl_opt -- "$@"
+       git ls-files -o $z $excl_opt -- "$@"
  }
  
  clear_stash () {
@@@ -114,7 -121,7 +121,7 @@@ create_stash () 
                # Untracked files are stored by themselves in a parentless commit, for
                # ease of unpacking later.
                u_commit=$(
-                       untracked_files "$@" | (
+                       untracked_files -z "$@" | (
                                GIT_INDEX_FILE="$TMPindex" &&
                                export GIT_INDEX_FILE &&
                                rm -f "$TMPindex" &&
@@@ -300,12 -307,6 +307,12 @@@ push_stash () 
  
        if test -z "$patch_mode"
        then
 +              test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION=
 +              if test -n "$untracked"
 +              then
 +                      git clean --force --quiet -d $CLEAN_X_OPTION -- "$@"
 +              fi
 +
                if test $# != 0
                then
                        git reset -q -- "$@"
                else
                        git reset --hard -q
                fi
 -              test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION=
 -              if test -n "$untracked"
 -              then
 -                      git clean --force --quiet -d $CLEAN_X_OPTION -- "$@"
 -              fi
  
                if test "$keep_index" = "t" && test -n "$i_tree"
                then
@@@ -574,7 -580,7 +581,7 @@@ apply_stash () 
  
        if test -n "$u_tree"
        then
 -              GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" &&
 +              GIT_INDEX_FILE="$TMPindex" git read-tree "$u_tree" &&
                GIT_INDEX_FILE="$TMPindex" git checkout-index --all &&
                rm -f "$TMPindex" ||
                die "$(gettext "Could not restore untracked files from stash entry")"