patchette

tests: corpus grows an odd-bytes branch

commit eebc221b284bd0da4c8e4461fbdc300822e7fe97 · parent d1e3ee7b43 · browse this tree
Ximianth, 2026-10-18 12:25:30 UTC

Content that git config or attributes could perturb: trailing
whitespace, CRLF, a binary file, a non-ASCII path with a space, a
symlink, a mode change, and a C edit giving two nearby hunks with
function-name hints and blank context lines.  The second commit is the
one that matters: creations have no context to perturb.

The roundtrip now carries it through both dialects, SHA-exact.
diff --git a/tests/lib.sh b/tests/lib.sh
index c91c667..6fc8495 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -131,6 +131,7 @@ tick() {
 ## jj `change-id` style, an empty commit, a body with a blank line, and a
 ## message without a final newline.
 ## `docs-polish` exists to make the layout's branch mapping visible.
+## `odd-bytes` carries content that git config or attributes could perturb.
 ##
 ## - @param $1 output directory; created.  Gets `upstream/`, `dev/`, and a
 ##   sourceable `FACTS` file recording the base SHA and branch tips.
@@ -228,9 +229,41 @@ make_corpus() (
 	tick
 	git commit -q -m "Polish the readme"
 
+	# --- third branch: content that git config or attributes could bite on ---
+	# Trailing whitespace, CRLF, binary, a non-ASCII path with a space, a
+	# symlink, a mode change, and C code whose edit makes nearby hunks with
+	# function-name hints and blank context lines.  The second commit is the
+	# one that matters: creations have no context to perturb.
+	git switch -qc odd-bytes main
+	mkdir odd
+	printf 'clean line\ntrailing   \nclean again\n' >odd/trailing.txt
+	printf 'one\r\ntwo\r\n' >odd/crlf.txt
+	printf 'bin\0ary\0\1\2' >odd/blob.bin
+	printf 'na\xc3\xafve\n' >"odd/naïve file.txt"
+	printf '#!/bin/sh\necho hi\n' >odd/run.sh
+	ln -s trailing.txt odd/link
+	{
+		printf '#include <stdio.h>\n\nint gear(int n)\n{\n\tint x = n;\n\n\tx = x * 2;\n\treturn x;\n}\n'
+		for i in 1 2 3 4 5 6 7 8; do printf '/* filler %s */\n' "$i"; done
+		printf 'int hum(void)\n{\n\tint y = 1;\n\n\ty = y + 1;\n\n\treturn y;\n}\n'
+	} >odd/tool.c
+	git add -A
+	tick
+	git commit -q -m "Add odd bytes"
+	sed -i 's/x = x \* 2;/x = x * 3;/; s/y = y + 1;/y = y + 2;/' odd/tool.c
+	printf 'more trailing \t\n' >>odd/trailing.txt
+	printf 'three\r\n' >>odd/crlf.txt
+	printf '\3\0' >>odd/blob.bin
+	printf 'still na\xc3\xafve\n' >>"odd/naïve file.txt"
+	chmod +x odd/run.sh
+	git add -A
+	tick
+	git commit -q -m "Stir odd bytes"
+
 	{
 		printf 'base=%s\n' "$base"
 		printf 'tip_topic_fancy=%s\n' "$(git rev-parse topic/fancy)"
 		printf 'tip_docs_polish=%s\n' "$(git rev-parse docs-polish)"
+		printf 'tip_odd_bytes=%s\n' "$(git rev-parse odd-bytes)"
 	} >"$out/FACTS"
 )
diff --git a/tests/test-roundtrip.sh b/tests/test-roundtrip.sh
index dd1324d..bd0a503 100755
--- a/tests/test-roundtrip.sh
+++ b/tests/test-roundtrip.sh
@@ -15,8 +15,8 @@ source "$work/corpus/FACTS"
 for sigil in quote tab; do
 	p="$work/$sigil"
 
-	"$PATCHETTE" export "--sigil=$sigil" "$work/corpus/dev" "$p/patches" "$base" topic/fancy docs-polish >/dev/null
-	"$PATCHETTE" export "--sigil=$sigil" "$work/corpus/dev" "$p/again" "$base" topic/fancy docs-polish >/dev/null
+	"$PATCHETTE" export "--sigil=$sigil" "$work/corpus/dev" "$p/patches" "$base" topic/fancy docs-polish odd-bytes >/dev/null
+	"$PATCHETTE" export "--sigil=$sigil" "$work/corpus/dev" "$p/again" "$base" topic/fancy docs-polish odd-bytes >/dev/null
 	EXPECT success "$sigil: export is regeneration-stable (two runs byte-identical)" -- \
 		diff -r "$p/patches" "$p/again"
 
@@ -41,6 +41,8 @@ for sigil in quote tab; do
 		"$(git -C "$p/fresh" rev-parse refs/heads/topic/fancy)" "$tip_topic_fancy"
 	EXPECT equal "$sigil: import reproduces the exact docs-polish tip" -- \
 		"$(git -C "$p/fresh" rev-parse refs/heads/docs-polish)" "$tip_docs_polish"
+	EXPECT equal "$sigil: import reproduces the exact odd-bytes tip" -- \
+		"$(git -C "$p/fresh" rev-parse refs/heads/odd-bytes)" "$tip_odd_bytes"
 
 	EXPECT success "$sigil: fsck --strict clean on the replayed repo" -- \
 		git -C "$p/fresh" fsck --strict