git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Improved example "To move the whole tree into a subdirectory..." to not fail when early commits are empty.
@ 2016-06-21  5:57 Brett Randall
  0 siblings, 0 replies; only message in thread
From: Brett Randall @ 2016-06-21  5:57 UTC (permalink / raw)
  To: gitster, git; +Cc: Brett Randall

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:

	mv: cannot stat <redacted>/index.new': No such file or directory

This 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.

See http://stackoverflow.com/questions/7798142/error-combining-git-repositories-into-subdirs for an example and explanation.

Signed-off-by: Brett Randall <javabrett@gmail.com>
---
 Documentation/git-filter-branch.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 003731f..271d5b0 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -385,7 +385,7 @@ 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
+	 if [ -f "$GIT_INDEX_FILE.new" ]; then mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"; fi' HEAD
 ---------------------------------------------------------------
 
 
-- 
2.8.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-21  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-21  5:57 [PATCH] Improved example "To move the whole tree into a subdirectory..." to not fail when early commits are empty Brett Randall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).