[RFC/PATCH 2/2] docs/filter-branch: clean up newsubdir example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Over the years, this simple example has ended up quite hard
to read because of the number of special cases that must be
handled. Let's simplify it a bit:

  1. Use the new "index-info --clear" to avoid the need for
     a temporary index.

  2. Use "-z" and "perl -0" to avoid dealing with quoting
     issues. As a bonus, using perl means that "\t" will
     work consistently in regexps (the previous example
     using sed was reported to fail on OS X).

  3. Change the indentation to keep one logical unit per
     line and avoid extra backslash-escaping.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 Documentation/git-filter-branch.txt |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 0f2f117..3df138f 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -358,11 +358,11 @@ git filter-branch ... D..H --not C
 To move the whole tree into a subdirectory, or remove it from there:
 
 ---------------------------------------------------------------
-git filter-branch --index-filter \
-	'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
-		GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
-			git update-index --index-info &&
-	 mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
+git filter-branch --index-filter '
+	git ls-files -sz |
+	perl -0pe "s{\t}{\tnewsubdir/}" |
+	git update-index -z --clear --index-info
+' HEAD
 ---------------------------------------------------------------
 
 
-- 
1.7.9.6.8.g992e5
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]