git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Sojka <sojkam1@fel.cvut.cz>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, Michal Sojka <sojkam1@fel.cvut.cz>
Subject: [PATCH 1/2] filter-branch: Fix to allow replacing submodules with another content
Date: Mon, 25 Jan 2010 14:06:24 +0100	[thread overview]
Message-ID: <1264424786-26231-2-git-send-email-sojkam1@fel.cvut.cz> (raw)
In-Reply-To: <1264424786-26231-1-git-send-email-sojkam1@fel.cvut.cz>

When git filter-branch is used to replace a submodule with another
content, it always fails on the first commit. Consider a repository with
submod directory containing a submodule. If I want to remove the
submodule and replace it with a file, the following command fails.

git filter-branch --tree-filter 'rm -rf submod &&
				 git rm -q submod &&
				 mkdir submod &&
				 touch submod/file'

The error message is:
error: submod: is a directory - add files inside instead

The reason is that git diff-index, which generates the first part of the
list of files updated by the tree filter, emits also the removed
submodule even if it was replaced by a real directory.

Adding --ignored-submodules solves the problem for me and
tests in t7003-filter-branch.sh pass correctly.

If somebody wants to replace one revision of the module with another, it
can be done with --index-filter. Using --tree-filter for this has no
sense since --tree-filter "git submodule update --init" fails with
  Clone of '/tmp/submod' into submodule path 'submod' failed
so that the revision must be replaced only in index.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
---
 git-filter-branch.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 195b5ef..d4ac7fb 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -331,7 +331,7 @@ while read commit parents; do
 			die "tree filter failed: $filter_tree"
 
 		(
-			git diff-index -r --name-only $commit &&
+			git diff-index -r --name-only --ignore-submodules $commit && 
 			git ls-files --others
 		) > "$tempdir"/tree-state || exit
 		git update-index --add --replace --remove --stdin \
-- 
1.6.6

  reply	other threads:[~2010-01-25 13:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25 13:06 filter-branch fix and tests Michal Sojka
2010-01-25 13:06 ` Michal Sojka [this message]
2010-01-25 13:06 ` [PATCH 2/2] filter-branch: Add tests for submodules Michal Sojka
     [not found] ` <alpine.DEB.1.00.1001261939420.4641@intel-tinevez-2-302>
2010-01-27 15:49   ` [PATCH] filter-branch fix and tests Michal Sojka
2010-01-27 16:18     ` Johannes Sixt
2010-01-27 23:41       ` Michal Sojka
2010-01-27 23:55         ` [PATCHv3] filter-branch: Add tests for submodules Michal Sojka
2010-01-28  0:14           ` Junio C Hamano
2010-01-28  9:02             ` Michal Sojka
2010-01-28  9:08               ` [PATCHv4 1/2] filter-branch: Fix to allow replacing submodules with another content Michal Sojka
2010-01-28  9:08               ` [PATCHv4 2/2] filter-branch: Add tests for submodules in tree-filter Michal Sojka
2010-01-28 21:57                 ` Junio C Hamano
2010-01-29 15:20                   ` Michal Sojka
2010-01-29 15:27                     ` [PATCHv5 1/2] filter-branch: Fix to allow replacing submodules with another content Michal Sojka
2010-01-29 15:27                     ` [PATCHv5 2/2] filter-branch: Add tests for submodules in tree-filter Michal Sojka

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=1264424786-26231-2-git-send-email-sojkam1@fel.cvut.cz \
    --to=sojkam1@fel.cvut.cz \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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).