{"thread":{"id":"42678","subject":"[PATCH] Improved example \"To move the whole tree into a subdirectory...\" to not fail when early commits are empty.","startedAt":"2016-06-21T08:26:46Z","lastAt":"2016-06-21T08:26:46Z","messageCount":1,"participants":["Brett Randall"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"289734","messageId":"20160621055702.28044-1-javabrett@gmail.com","threadId":"42678","inReplyTo":null,"subject":"[PATCH] Improved example \"To move the whole tree into a subdirectory...\" to not fail when early commits are empty.","fromName":"Brett Randall","fromEmail":"javabrett@gmail.com","sentAt":"2016-06-21T05:57:02Z","receivedAt":"2016-06-21T08:26:46Z","isPatch":true,"sender":{"key":"javabrett@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1103477?v=4"},"body":"Previously this example would fail if the oldest commit(s) in any filtered branch is/are empty (no files) because the index would not change, and the mv would fail with:\n\n\tmv: cannot stat <redacted>/index.new': No such file or directory\n\nThis commonly occurs with histories created from git-svn-clone.  The updated example checks whether the index file has been created before attempting the mv.  The empty commit is retained.\n\nSee http://stackoverflow.com/questions/7798142/error-combining-git-repositories-into-subdirs for an example and explanation.\n\nSigned-off-by: Brett Randall <javabrett@gmail.com>\n---\n Documentation/git-filter-branch.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 003731f..271d5b0 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -385,7 +385,7 @@ git filter-branch --index-filter \\\n \t'git ls-files -s | sed \"s-\\t\\\"*-&newsubdir/-\" |\n \t\tGIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n \t\t\tgit update-index --index-info &&\n-\t mv \"$GIT_INDEX_FILE.new\" \"$GIT_INDEX_FILE\"' HEAD\n+\t if [ -f \"$GIT_INDEX_FILE.new\" ]; then mv \"$GIT_INDEX_FILE.new\" \"$GIT_INDEX_FILE\"; fi' HEAD\n ---------------------------------------------------------------\n \n \n-- \n2.8.4\n\n"}]}