threads / patch / 8675

patchfilter-branch: add example to move everything into a subdirectory

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

## tl;dr

3 messages between Jun 21, 2007 and Jun 23, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Johannes Schindelin· Jun 21, 2007, 17:05 UTC · lore
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(-)
Show changes to 2 files +16 −0

git-filter-branch.sh, t/t7003-filter-branch.sh

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· Jun 23, 2007, 06:22 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 5 quoted lines
> 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· Jun 23, 2007, 11:03 UTC · re: Junio C Hamano · lore

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

Hi,
On Fri, 22 Jun 2007, Junio C Hamano wrote:
Show 12 quoted lines
> 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

← back to recent threads