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

[PATCH] filter-branch tests/docs: avoid \t in sed regexes

From
Thomas Rast <trast@student.ethz.ch>
Date
Jul 29, 2010, 13:24 UTC
Message-ID
<0bb511ca2d155ea7e37850a78375da1803032d6c.1280409717.git.trast@student.ethz.ch>
In-Reply-To
<AANLkTin5sv8NQ_8NZkQpW9HG4zYZDZHNF80EWK8Km4Mr@mail.gmail.com>

Using \t to represent a tab character is not portable beyond GNU sed (see e.g. GNU sed's info pages). Use printf to generate the tab instead.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 Adam Mercer wrote:
> > What OS is this?
> This was on Mac OS X 10.6. Where sed is BSD sed.

That's very funny however, since it means that nobody should ever have had a successful test run on OS X with the preinstalled tools. What gives?

 Documentation/git-filter-branch.txt |    3 ++-
 t/t7003-filter-branch.sh            |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 020028c..7e3ff8e 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -357,8 +357,9 @@ git filter-branch ... D..H --not C
 To move the whole tree into a subdirectory, or remove it from there:
 
 ---------------------------------------------------------------
+export TAB="$(printf '\t')"
 git filter-branch --index-filter \
-	'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
+	'git ls-files -s | sed "s-$TAB\"*-&newsubdir/-" |
 		GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
 			git update-index --index-info &&
 	 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 0da13a8..e90da6d 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -140,10 +140,11 @@ test_expect_success 'more setup' '
 	git merge branch
 '
 
+export TAB="$(printf '\t')"
 test_expect_success 'use index-filter to move into a subdirectory' '
 	git branch directorymoved &&
 	git filter-branch -f --index-filter \
-		 "git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
+		 "git ls-files -s | sed \"s-$TAB-&newsubdir/-\" |
 	          GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
 			git update-index --index-info &&
 		  mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
-- 
1.7.2.1.342.g676a4
Previous: Adam MercerNext: Tomas Carnecky
Message 4 of 13 in “Using filter-branch to move repo contents in subdirectory”
  1. Adam MercerJul 29, 2010
  2. Thomas RastJul 29, 2010
  3. Adam MercerJul 29, 2010
  4. filter-branch tests/docs: avoid \t in sed regexesThomas Rast, Jul 29, 2010
  5. Tomas CarneckyJul 29, 2010
  6. Thomas RastJul 29, 2010
  7. Tomas CarneckyJul 29, 2010
  8. t7005: fix subdirectory-filter testThomas Rast, Jul 29, 2010
  9. Thomas RastJul 29, 2010
  10. Adam MercerAug 9, 2010
  11. Adam MercerAug 11, 2010
  12. Jeff KingAug 11, 2010
  13. Adam MercerAug 11, 2010

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.