Skip to content

Commit 89ee180

Browse files
committed
Reword to be more portable and self-documenting
This requires xxd now, but it honors its /bin/sh hashbang line, no longer assuming printf understands \xNN in a format string.
1 parent 9436f3f commit 89ee180

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

gix-worktree/tests/fixtures/make_traverse_dotgit_slashes.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ date >vulnerable
1212
EOF
1313
}
1414

15-
# Initialize the repository.
1615
repo="$1"
1716
git init -- "$repo"
1817
cd -- "$repo"
19-
branch="$(git symbolic-ref --short HEAD)"
2018

21-
# Create the blob of the payload.
2219
blob_hash="$(emit_payload | git hash-object -w --stdin)"
23-
escaped_blob_hash="$(printf '%s' "$blob_hash" | sed 's/../\\x&/g')"
20+
printf '%s' "$blob_hash" | xxd -r -p >blob-hash-bytes
2421

25-
# Create the top-level tree object referencing the blob with the stange name.
2622
tree_hash="$(
27-
printf '%s %s\0'"$escaped_blob_hash" "$filemode" "$filename" |
23+
printf '%s %s\0' "$filemode" "$filename" |
24+
cat - blob-hash-bytes |
2825
git hash-object -t tree -w --stdin
2926
)"
3027

31-
# Commit the tree as an initial commit, setting the default branch to it.
28+
rm blob-hash-bytes
29+
3230
commit_hash="$(git commit-tree -m 'Initial commit' "$tree_hash")"
31+
branch="$(git symbolic-ref --short HEAD)"
3332
git branch -f -- "$branch" "$commit_hash"
3433
git show

0 commit comments

Comments
 (0)