# [PATCH] filter-branch: add example to move everything into a subdirectory

3 messages from 2007-06-21 to 2007-06-23. Participants: Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/8675

## Johannes Schindelin, 2007-06-21 17:05

Subject: [PATCH] filter-branch: add example to move everything into a subdirectory
Message-ID: <Pine.LNX.4.64.0706211805010.4059@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0706211805010.4059%40racer.site

```

This is based on Jeff King's example in

	20070621130137.GB4487@coredump.intra.peff.net

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-filter-branch.sh     |    8 ++++++++
 t/t7003-filter-branch.sh |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ffb31d6..297e09e 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -181,6 +181,14 @@
 #
 #	git-filter-branch ... new-H C..H --not D
 #	git-filter-branch ... new-H D..H --not C
+#
+# 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' directorymoved
 
 # Testsuite: TODO
 
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 0fabe49..f00c262 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -99,4 +99,12 @@ test_expect_success 'subdirectory filter result looks okay' '
 	! git show sub:subdir
 '
 
+test_expect_success 'use index-filter to move into a subdirectory' '
+	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" directorymoved &&
+	test -z "$(git diff HEAD directorymoved:newsubdir)"'
+
 test_done
-- 
1.5.2.2.2822.g027a6-dirty

```

## Junio C Hamano, 2007-06-23 06:22

Subject: Re: [PATCH] filter-branch: add example to move everything into a subdirectory
Message-ID: <7vwsxv8a1a.fsf@assigned-by-dhcp.pobox.com>
URL: https://gitlist.dev/e/7vwsxv8a1a.fsf%40assigned-by-dhcp.pobox.com
In-Reply-To: <Pine.LNX.4.64.0706211805010.4059@racer.site>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index ffb31d6..297e09e 100644
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -181,6 +181,14 @@

Keeping your private repository out of sync with me is Ok, but
can you fix the filemode when you have chance?  The warning I
get every time I apply a patch from you to this file about mode
mismatch somewhat annoys me.

Thanks.

```

## Johannes Schindelin, 2007-06-23 11:03

Subject: Re: [PATCH] filter-branch: add example to move everything into a subdirectory
Message-ID: <Pine.LNX.4.64.0706231201440.4059@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0706231201440.4059%40racer.site
In-Reply-To: <7vwsxv8a1a.fsf@assigned-by-dhcp.pobox.com>

```
Hi,

On Fri, 22 Jun 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> > index ffb31d6..297e09e 100644
> > --- a/git-filter-branch.sh
> > +++ b/git-filter-branch.sh
> > @@ -181,6 +181,14 @@
> 
> Keeping your private repository out of sync with me is Ok, but can you 
> fix the filemode when you have chance?  The warning I get every time I 
> apply a patch from you to this file about mode mismatch somewhat annoys 
> me.

I am sorry! I did not even realize that I was _so_ out of sync. ATM AFAICT 
there is only the "skip" hack in my repo.

Ciao,
Dscho

```
