git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] stash: prevent warning about null bytes in input

From
Kevin Daudt <me@ikke.info>
Date
Aug 14, 2017, 05:08 UTC
Message-ID
<20170814050801.7158-1-me@ikke.info>

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, remove null bytes from the input.

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>
---
 git-stash.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-stash.sh b/git-stash.sh
index 9b6c2da7b..0dcca3cd6 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -39,7 +39,7 @@ fi
 no_changes () {
 	git diff-index --quiet --cached HEAD --ignore-submodules -- "$@" &&
 	git diff-files --quiet --ignore-submodules -- "$@" &&
-	(test -z "$untracked" || test -z "$(untracked_files)")
+	(test -z "$untracked" || test -z "$(untracked_files | tr -d '\0')")
 }
 
 untracked_files () {
-- 
2.14.0.rc1.33.g384a8b271c
Next: Junio C Hamano
Message 1 of 5 in “stash: prevent warning about null bytes in input”
  1. stash: prevent warning about null bytes in inputKevin Daudt, Aug 14, 2017
  2. Junio C HamanoAug 14, 2017
  3. Kevin DaudtAug 14, 2017
  4. Junio C HamanoAug 14, 2017
  5. stash: prevent warning about null bytes in inputKevin Daudt, Aug 14, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.