Skip to content

Commit 206a6ae

Browse files
mlocatigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3013dff commit 206a6ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-filter-branch.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,12 +627,12 @@ then
627627
print H "$_:$f\n" or die;
628628
}
629629
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)
631631
if test -n "$state_commit"
632632
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")
634634
else
635-
state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" )
635+
state_commit=$(echo "Sync" | git commit-tree "$state_tree" )
636636
fi
637637
git update-ref "$state_branch" "$state_commit"
638638
fi

0 commit comments

Comments
 (0)