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

[PATCH 6/6] t5000: test long filenames

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
May 20, 2013, 09:58 UTC
Message-ID
<1369043909-59207-7-git-send-email-rene.scharfe@lsrfire.ath.cx>
In-Reply-To
<1369043909-59207-1-git-send-email-rene.scharfe@lsrfire.ath.cx>

Add a file with a long name to the test archive in order to check entries with pax extended headers. Also add a check for tar versions that doen't understand this format. Those versions should extract the headers as a regular files. Add code to check_tar() to interpret the path header if present, so that our tests work even with those tar versions.

It's important to use the fallback code only if needed to still be able to detect git archive errorously creating pax headers as regular file entries (with a suitable tar version, of course).

The archive used to check for pax header support in tar was generated using GNU tar 1.26 and its option --format=pax.

Tested successfully on NetBSD 6.1, which has a tar version lacking pax header support.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 t/t5000-tar-tree.sh |  46 ++++++++++++++++++++++++++++++++++++++++++++++
 t/t5000/pax.tar     | Bin 0 -> 10240 bytes
 2 files changed, 46 insertions(+)
 create mode 100644 t/t5000/pax.tar
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index a1f35d2..c2023b1 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -30,6 +30,32 @@ GUNZIP=${GUNZIP:-gzip -d}
 
 SUBSTFORMAT=%H%n
 
+test_lazy_prereq TAR_NEEDS_PAX_FALLBACK '
+	(
+		mkdir pax &&
+		cd pax &&
+		"$TAR" xf "$TEST_DIRECTORY"/t5000/pax.tar &&
+		test -f PaxHeaders.1791/file
+	)
+'
+
+get_pax_header() {
+	file=$1
+	header=$2=
+
+	while read len rest
+	do
+		if test "$len" = $(echo "$len $rest" | wc -c)
+		then
+			case "$rest" in
+			$header*)
+				echo "${rest#$header}"
+				;;
+			esac
+		fi
+	done <"$file"
+}
+
 check_tar() {
 	tarfile=$1.tar
 	listfile=$1.lst
@@ -40,6 +66,24 @@ check_tar() {
 		(mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
 	'
 
+	test_expect_success TAR_NEEDS_PAX_FALLBACK ' interpret pax headers' '
+		(
+			cd $dir &&
+			for header in *.paxheader
+			do
+				data=${header%.paxheader}.data &&
+				if test -h $data -o -e $data
+				then
+					path=$(get_pax_header $header path) &&
+					if test -n "$path"
+					then
+						mv "$data" "$path"
+					fi
+				fi
+			done
+		)
+	'
+
 	test_expect_success ' validate filenames' '
 		(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
 		test_cmp a.lst $listfile
@@ -54,6 +98,8 @@ test_expect_success \
     'populate workdir' \
     'mkdir a &&
      echo simple textfile >a/a &&
+     ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
+     echo long filename >a/four$hundred &&
      mkdir a/bin &&
      cp /bin/sh a/bin &&
      printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
diff --git a/t/t5000/pax.tar b/t/t5000/pax.tar
new file mode 100644
index 0000000000000000000000000000000000000000..d91173714991fded560fcd6a8aaec6aa6ec7f5e8
GIT binary patch
literal 10240
zcmeIy%?g4*5Ww+0_Y^*X&3@?Sp?k+(L29F*2+YXGPl*s(6d@sk|6W#S)Sdakm@c<v
zvkB!sRJT<7LN5=eb5OG`X;<!?>h^Yh?xL+x+Gv-HHCB5i+IVkN(#%@Lz{l>lx~$rg
z2GWzmuipCRCcpUG2dyNR`g93vZSz%O3b*p9Sn-k>pDo&KIhx%KXMfulr%w}@f7;`7
zyU`e%|L&jgG5=zmO1_@SxRf~Zp8x84t>bJTc^pGH_qWm2pU!{O2LS{SKmY**5I_I{
l1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|00D->}cmml}KZ5`O

literal 0
HcmV?d00001
-- 
1.8.2.3
Previous: René ScharfeNext: Eric Sunshine
Message 11 of 15 in “t5000: add test for pax extended header generation”
  1. 0/6 t5000: add test for pax extended header generationRené Scharfe, May 20, 2013
  2. 1/6 t5000: integrate export-subst tests into regular testsRené Scharfe, May 20, 2013
  3. Eric SunshineMay 20, 2013
  4. René ScharfeMay 20, 2013
  5. 2/6 t5000, t5003: create directories for extracted files lazilyRené Scharfe, May 20, 2013
  6. 3/6 t5000: factor out check_tarRené Scharfe, May 20, 2013
  7. Eric SunshineMay 20, 2013
  8. René ScharfeMay 20, 2013
  9. 4/6 t5000: use check_tar for prefix testRené Scharfe, May 20, 2013
  10. 5/6 t5000: simplify tar-tree testsRené Scharfe, May 20, 2013
  11. 6/6 t5000: test long filenamesRené Scharfe, May 20, 2013
  12. Eric SunshineMay 20, 2013
  13. (unknown)Marty Landman, May 20, 2013
  14. René ScharfeMay 20, 2013
  15. Junio C HamanoMay 20, 2013

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.