mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
stash: prevent warning about null bytes in input
The `no_changes` function calls the `untracked_files` function through command substitution. `untracked_files` will return null bytes because it runs ls-files with the '-z' option. Bash since version 4.4 warns about these null bytes. As they are not required for the test that is being done, make sure `untracked_files` does not output null bytes when not required. This is achieved by adding a parameter to the `untracked_files` function to specify wither `-z` should be passed to ls-files or not. This warning is triggered when running git stash save -u resulting in two warnings: git-stash: line 43: warning: command substitution: ignored null byte in input Signed-off-by: Kevin Daudt <me@ikke.info> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4d7268b888
commit
5fc92f8828
11
git-stash.sh
11
git-stash.sh
@ -43,9 +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 @@ 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" &&
|
||||
|
Loading…
Reference in New Issue
Block a user