filter-branch: use printf instead of echo -e
In order to echo a tab character, it's better to use printf instead of "echo -e", because it's more portable (for instance, "echo -e" doesn't work as expected on a Mac). This solves the "fatal: Not a valid object name" error in git-filter-branch when using the --state-branch option. Furthermore, let's switch from "/bin/echo" to just "echo", so that the built-in echo command is used where available. Signed-off-by: Michele Locati <michele@locati.it> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michele Locati committed
Mar 19, 2018 at 16:52 UTC
206a6ae01355e4d5d0e01e6d99d960fcc907e6b3
1 file changed
+3
-3
git-filter-branch.sh
+3
-3
@@ -627,12 +627,12 @@ then
627
print H "$_:$f\n" or die;
628
}
629
close(H) or die;' || die "Unable to save state")
630
- state_tree=$(/bin/echo -e "100644 blob $state_blob\tfilter.map" | git mktree)
630
+ state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree)
631
if test -n "$state_commit"
632
then
633
- state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" -p "$state_commit")
633
+ state_commit=$(echo "Sync" | git commit-tree "$state_tree" -p "$state_commit")
634
else
635
- state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" )
635
+ state_commit=$(echo "Sync" | git commit-tree "$state_tree" )
636
fi
637
git update-ref "$state_branch" "$state_commit"
638
fi