On Mon, Feb 01, 2010 at 11:48:27AM +0000, Ivo Anjo wrote: > 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 > > > The problem is with filenames that use complex utf8 (non-ascii?) chars: Yes, that is definitely the problem. update-index unquotes its input, as you would expect, but the sed munging does not take the quote into account. You can fix it by doing: sed "s-\t\"*-&newsubdir/-" instead. Here is a patch to fix the documentation. I am slightly unsure of whether it should be applied. These examples are supposed to be simple and readable to help the user understand what the filters can do. And this makes it somewhat less simple for the sake of a special case. But at the same time, users are going to cut-and-paste these examples (I know I have), and the special case is not _that_ special, especially for non-English speakers. And having it in the example helps make people aware that quoted paths are a reality. So I think on balance it is probably better to fix it. Note also that another way of "fixing" this would be to set core.quotepath to false (which is something you probably want to do anyway if you are using utf8 characters in your filenames). And I put "fix" in quotes because you still may run across quoted paths, but they will be much less common; you will only see them if you have control characters or other insanity in your paths. -- >8 -- Subject: [PATCH] docs: fix filter-branch example for quoted paths If there is a quoted path, update-index will correctly unquote it. However, we must take care to put our new prefix inside the double-quote. Signed-off-by: Jeff King <peff@xxxxxxxx> --- Documentation/git-filter-branch.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index cfaba2a..020028c 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -358,7 +358,7 @@ 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 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 -- 1.7.0.rc1.16.g21332.dirty -- 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