git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brett Randall <javabrett@gmail.com>
To: gitster@pobox.com, git@vger.kernel.org
Cc: Brett Randall <javabrett@gmail.com>
Subject: [PATCH] Improved example "To move the whole tree into a subdirectory..." to not fail when early commits are empty.
Date: Tue, 21 Jun 2016 15:57:02 +1000	[thread overview]
Message-ID: <20160621055702.28044-1-javabrett@gmail.com> (raw)

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


                 reply	other threads:[~2016-06-21  8:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160621055702.28044-1-javabrett@gmail.com \
    --to=javabrett@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).