All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Greg Brockman <gdb@MIT.EDU>,
	Ilari Liusvaara <ilari.liusvaara@elisanet.fi>,
	Elijah Newren <newren@gmail.com>
Subject: Re: jn/apply-filename-with-sp (Re: What's cooking in git.git (Aug 2010, #02; Wed, 11))
Date: Fri, 13 Aug 2010 21:27:03 -0500	[thread overview]
Message-ID: <20100814022625.GA4199@burratino> (raw)
In-Reply-To: <4C65BCD2.6000701@kdbg.org>

Johannes Sixt wrote:
> Am 13.08.2010 00:40, schrieb Jonathan Nieder:

>> Would this work?
>>
>> -- 8<  --
>> Subject: t4135 (apply): filenames with tabs are not usable on NTFS
[...]
> No, it needs this squashed in

Ah, makes sense.  Here’s another rough patch.  Patch is against
jn/apply-filename-with-sp + ab/test.  Not signed off because I am not
sure about the licensing of expand.sed (and I would rather see some
other fix instead).

-- 8< --
Subject: t4135 (apply): tweaks for Windows

Filenames with tabs are not usable on NTFS, so mimic the code setting
up the FUNNYNAMES prerequisite from v1.3.0-rc1~67 (workaround fat/ntfs
deficiences for t3600-rm.sh, 2006-03-03) and use it.  The code is not
shared in test-lib.sh to avoid wasting time on that check while
running other tests.

Backslashes is the path separator on Windows, so it cannot be used
in filenames (see v1.6.3-rc0~93^2~6, t3700: Skip a test with
backslashes in pathspec, 2009-03-13).

Filenames starting with a quotation mark do not behave well in msys
(see v1.7.0-rc0~94^2, t4030, t4031: work around bogus MSYS bash path
conversion, 2010-01-01), so skip those tests on Windows.

“expand” is not available in msysgit.  Use a sed script by Greg Ubben
to replace it.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Not-signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t4135-apply-weird-filenames.sh |   70 ++++++++++++++++++++++++++++++++------
 1 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh
index f4c7e15..08f8fe2 100755
--- a/t/t4135-apply-weird-filenames.sh
+++ b/t/t4135-apply-weird-filenames.sh
@@ -10,7 +10,7 @@ test_expect_success 'setup: empty commit' '
 	git tag preimage
 '
 
-test_expect_success 'setup: clean-up functions' '
+test_expect_success 'setup: helper functions' '
 	reset_preimage() {
 		git checkout -f preimage^0 &&
 		git read-tree -u --reset HEAD &&
@@ -20,6 +20,44 @@ test_expect_success 'setup: clean-up functions' '
 	reset_subdirs() {
 		rm -fr a b &&
 		mkdir a b
+	} &&
+
+	cat <<-\EOF >expand.sed &&
+	#! /bin/sed -f
+	#  @(#)14apr89/31aug01 expand.sed by Greg Ubben
+
+	/	/!b
+
+	# Change the text before a tab to
+	#   text<MARKER>text<TAB><8 blanks><TAB>
+	#
+	s/\([^	]*\)	/\1Q&        	/g
+
+	# Reduce the text between the marker and the tab to less
+	# than eight characters.  We have to put in 8-(length MOD 8)
+	# blanks, and this effectively does the modulo operation.
+	:a
+		s/Q[^	]\{8\}/Q/g
+	ta
+
+	# The buffer is now:
+	#   text<MARKER><(length MOD 8) characters><TAB><expansion><extra blanks><TAB>
+	#                -----------------------------------------
+	# Notice that the expansion is 8-(length MOD 8), so the
+	# underlined part is exactly nine characters.  That is how
+	# we discard the extra blanks and the tabs.
+	#
+	s/\(Q.\{9\}\) *	/\1/g
+
+	# We have now:
+	#         text<MARKER><(length MOD 8) characters><TAB><expansion>
+	#
+	# so we discard everything between the marker and the tab
+	#
+	s/Q[^	]*	//g
+	EOF
+	expand_tabs() {
+		sed -f "$TRASH_DIRECTORY/expand.sed" "$@"
 	}
 '
 
@@ -34,17 +72,25 @@ test_expect_success 'setup: test prerequisites' '
 	if diff -pruN 1 2
 	then
 		test_set_prereq FULLDIFF
+	fi &&
+
+	test_when_finished "rm -f \"tab	embedded.txt\"" &&
+	test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" &&
+	if touch -- "tab	embedded.txt" '\''"quoteembedded".txt'\''
+	then
+		test_set_prereq FUNNYNAMES
 	fi
 '
 
 try_filename() {
 	desc=$1
 	postimage=$2
-	exp1=${3:-success}
-	exp2=${4:-success}
-	exp3=${5:-success}
+	prereq=${3:-}
+	exp1=${4:-success}
+	exp2=${5:-success}
+	exp3=${6:-success}
 
-	test_expect_$exp1 "$desc, git-style file creation patch" "
+	test_expect_$exp1 $prereq "$desc, git-style file creation patch" "
 		reset_preimage &&
 		echo postimage >'$postimage' &&
 		git add -N '$postimage' &&
@@ -57,7 +103,8 @@ try_filename() {
 		test_cmp postimage.saved '$postimage'
 	"
 
-	test_expect_$exp2 UNIDIFF "$desc, traditional patch" "
+	test_expect_$exp2 ${prereq:+$prereq,}UNIDIFF \
+						"$desc, traditional patch" "
 		reset_preimage &&
 		echo preimage >'$postimage.orig' &&
 		echo postimage >'$postimage' &&
@@ -70,7 +117,8 @@ try_filename() {
 		test_cmp postimage.saved '$postimage'
 	"
 
-	test_expect_$exp3 FULLDIFF "$desc, traditional file creation patch" "
+	test_expect_$exp3 ${prereq:+$prereq,}FULLDIFF \
+				"$desc, traditional file creation patch" "
 		reset_preimage &&
 		reset_subdirs &&
 		echo postimage >b/'$postimage' &&
@@ -86,16 +134,16 @@ try_filename() {
 
 try_filename 'plain'            'postimage.txt'
 try_filename 'with spaces'      'post image.txt'
-try_filename 'with tab'         'post	image.txt'
-try_filename 'with backslash'   'post\image.txt'
-try_filename 'with quote'       '"postimage".txt' success failure success
+try_filename 'with tab'         'post	image.txt' FUNNYNAMES
+try_filename 'with backslash'   'post\image.txt' BSLASHPSPEC
+try_filename 'with quote'       '"postimage".txt' FUNNYNAMES success failure success
 
 test_expect_success FULLDIFF 'whitespace-damaged traditional patch' '
 	reset_preimage &&
 	reset_subdirs &&
 	echo postimage >b/postimage.txt &&
 	! diff -pruN a b >diff-plain.txt &&
-	expand diff-plain.txt >damaged.diff &&
+	expand_tabs diff-plain.txt >damaged.diff &&
 
 	mv postimage.txt postimage.saved &&
 	git apply -v damaged.diff &&
-- 
1.7.2.1.544.ga752d.dirty

  reply	other threads:[~2010-08-14  2:28 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11 23:35 What's cooking in git.git (Aug 2010, #02; Wed, 11) Junio C Hamano
2010-08-12  1:41 ` Jonathan Nieder
2010-08-12  2:33   ` Ævar Arnfjörð Bjarmason
2010-08-12  3:15     ` jn/commit-no-change-wo-status (Re: What's cooking in git.git (Aug 2010, #02; Wed, 11)) Jonathan Nieder
2010-08-12  5:47 ` What's cooking in git.git (Aug 2010, #02; Wed, 11) Elijah Newren
2010-08-12 15:49   ` Junio C Hamano
2010-08-12 21:12     ` Elijah Newren
2010-08-12  9:23 ` Johannes Sixt
2010-08-12  9:37   ` Greg Brockman
2010-08-12 10:11     ` Ævar Arnfjörð Bjarmason
2010-08-12 22:08     ` Junio C Hamano
2010-08-12 22:13       ` Greg Brockman
2010-08-12 22:19       ` Junio C Hamano
2010-08-12 10:20   ` Ævar Arnfjörð Bjarmason
2010-08-12 11:35     ` Erik Faye-Lund
2010-08-12 16:50       ` Ævar Arnfjörð Bjarmason
2010-08-12 17:34         ` Chris Packham
2010-08-12 18:35           ` Ævar Arnfjörð Bjarmason
2010-08-12 22:19             ` windows smoke tester (was Re: What's cooking in git.git (Aug 2010, #02; Wed, 11)) Chris Packham
2010-08-12 22:29               ` Ævar Arnfjörð Bjarmason
2010-08-12 22:58                 ` Chris Packham
2010-08-13  1:01                   ` Ævar Arnfjörð Bjarmason
2010-08-14  0:42                     ` Chris Packham
2010-08-14  0:46                       ` Ævar Arnfjörð Bjarmason
2010-08-15  0:54                       ` Tay Ray Chuan
2010-08-15  1:08                         ` Ævar Arnfjörð Bjarmason
2010-08-15 17:39                           ` Tay Ray Chuan
2010-08-12 10:21   ` What's cooking in git.git (Aug 2010, #02; Wed, 11) Ilari Liusvaara
2010-08-12 10:31     ` Johannes Sixt
2010-08-12 15:25       ` Ilari Liusvaara
2010-08-12 12:43   ` Elijah Newren
2010-08-12 22:21     ` Junio C Hamano
2010-08-12 21:58   ` Junio C Hamano
2010-08-12 22:40   ` jn/apply-filename-with-sp (Re: What's cooking in git.git (Aug 2010, #02; Wed, 11)) Jonathan Nieder
2010-08-12 22:46     ` Ævar Arnfjörð Bjarmason
2010-08-12 23:17     ` Junio C Hamano
2010-08-13  0:59       ` Ævar Arnfjörð Bjarmason
2010-08-13 21:44     ` Johannes Sixt
2010-08-14  2:27       ` Jonathan Nieder [this message]
2010-08-14 18:37         ` Johannes Sixt
2010-08-15  0:05           ` Jonathan Nieder
2010-08-19  1:45           ` [PATCH v2 0/3] apply: handle traditional patches with space in filename Jonathan Nieder
2010-08-19  1:46             ` [PATCH 1/3] apply: split quoted filename handling into new function Jonathan Nieder
2010-08-19  1:48             ` [PATCH 2/3] tests: exercise "git apply" with weird filenames Jonathan Nieder
2010-08-19  1:50             ` [PATCH 3/3] apply: handle traditional patches with space in filename Jonathan Nieder
2010-08-19 19:56             ` [PATCH v2 0/3] " Johannes Sixt
2010-08-20  6:26               ` Jonathan Nieder
2010-08-13  0:08   ` jn/svn-fe Jonathan Nieder
2010-08-13 10:18     ` jn/svn-fe Jakub Narebski
2010-08-13 21:33     ` jn/svn-fe Johannes Sixt
2010-08-13 23:47       ` [PATCH v2 jn/svn-fe 0/5] vcs-svn: Port to Windows Jonathan Nieder
2010-08-13 23:59         ` [PATCH 1/5] compat: add strtok_r() Jonathan Nieder
2010-08-14  0:01         ` [PATCH 2/5] vcs-svn: Rename dirent pool to build on Windows Jonathan Nieder
2010-08-14  0:03         ` [PATCH 3/5] vcs-svn: Avoid %z in format string Jonathan Nieder
2010-08-14  0:04         ` [PATCH 4/5] t9010 (svn-fe): use Unix-style path in URI Jonathan Nieder
2010-08-14  0:06         ` [PATCH 5/5] t9010 (svn-fe): avoid symlinks in test Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100814022625.GA4199@burratino \
    --to=jrnieder@gmail.com \
    --cc=gdb@MIT.EDU \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ilari.liusvaara@elisanet.fi \
    --cc=j6t@kdbg.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.