[RFC/PATCH 2/2] docs/filter-branch: clean up newsubdir example
- From
Jeff King <peff@peff.net>
- Date
- Apr 16, 2012, 16:03 UTC
- Message-ID
- <20120416160300.GB1350@sigill.intra.peff.net>
- In-Reply-To
- <20120416152737.GB14724@sigill.intra.peff.net>
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@peff.net> --- 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