* [bug] filter-branch skipping removed files
@ 2008-03-30 14:35 Jean-François Veillette
2008-03-30 23:05 ` Jean-François Veillette
0 siblings, 1 reply; 9+ messages in thread
From: Jean-François Veillette @ 2008-03-30 14:35 UTC (permalink / raw)
To: Git
I'm experimenting with git filter-branch to simplify the change
history. I would like to rewrite the history and remove unwanted
files and reformat the sources to remove all the change's noises
(whitespace changes, code reformat).
But the new history miss some commits of removed files.
I was preparing a simple test (down bellow) when I thought, why not
try to fix it (my first journey inside git).
It turn out I was able to fix the problem, it was almost too easy:
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 22b6ed4..26ebb6c 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -277,7 +277,7 @@ while read commit parents; do
die "env filter failed: $filter_env"
if [ "$filter_tree" ]; then
- git checkout-index -f -u -a ||
+ git checkout-index -d -f -u -a ||
die "Could not checkout the index"
# files that $commit removed are now still in the working tree;
# remove them, else they would be added again
It was my first try, just because I noticed that git-clean was giving
a 'warning' of non removed directory. At that point I just wanted to
remove the warning ... but that was enough to fix the problem !
I don't know if it's a real fix, but at least it does correct the
problem I'm having.
I have no idea of the implication of what I just touched. the 'real'
problem might very well be somewhere else.
Here is a simple test that show the problem.
$: mkdir test ; cd test
$: git init
Initialized empty Git repository in .git/
$: echo 'line A' > a.txt
$: echo 'line B' > b.txt
$: mkdir subdir
$: echo 'line subA' > subdir/a.txt
$: echo 'line subB' > subdir/b.txt
$: git add *
$: git commit -m 'first commit'
Created initial commit f264d57: first commit
4 files changed, 4 insertions(+), 0 deletions(-)
create mode 100644 a.txt
create mode 100644 b.txt
create mode 100644 subdir/a.txt
create mode 100644 subdir/b.txt
$: git rm b.txt subdir/b.txt
rm 'b.txt'
rm 'subdir/b.txt'
$: git commit -m 'remove b files'
Created commit b064598: remove b files
2 files changed, 0 insertions(+), 2 deletions(-)
delete mode 100644 b.txt
delete mode 100644 subdir/b.txt
$: echo 'line AA' >> a.txt
$: echo 'line subAA' >> subdir/a.txt
$: git add *
$: git commit -m 'modified a files'
Created commit 0f914cb: modified a files
2 files changed, 2 insertions(+), 0 deletions(-)
$: git rm subdir/a.txt
rm 'subdir/a.txt'
$: git commit -m 'removed all sub files'
Created commit 41c0de7: removed all sub files
1 files changed, 0 insertions(+), 2 deletions(-)
delete mode 100644 subdir/a.txt
$: ls -la
...git a.txt
$: echo 'line AAA' >> a.txt
$: git add *
$: git commit -m 'modified a.txt'
Created commit c21e292: modified a.txt
1 files changed, 1 insertions(+), 0 deletions(-)
$: git filter-branch --tree-filter 'ls -lR' # do nothing, juste
rewrite itself
Rewrite f264d57f476858aa4ddbf70358500c3be7298048 (1/5)total 16
-rw-r--r-- 1 jfv jfv 7 30 mar 09:38 a.txt
-rw-r--r-- 1 jfv jfv 7 30 mar 09:38 b.txt
drwxr-xr-x 4 jfv jfv 136 30 mar 09:38 subdir
.../subdir:
total 16
-rw-r--r-- 1 jfv jfv 10 30 mar 09:38 a.txt
-rw-r--r-- 1 jfv jfv 10 30 mar 09:38 b.txt
Rewrite b064598f57b4679febaeddda6dfbde43a935796a (2/5)total 8
-rw-r--r-- 1 jfv jfv 7 30 mar 09:38 a.txt
drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
.../subdir:
total 8
-rw-r--r-- 1 jfv jfv 10 30 mar 09:38 a.txt
Rewrite 0f914cb21ab65aac5d966a9552bfb63aa73a996a (3/5)total 8
-rw-r--r-- 1 jfv jfv 15 30 mar 09:38 a.txt
drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
.../subdir:
total 8
-rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
Rewrite 41c0de77880245c23bb56b0b1936564c7adf63de (4/5)Not removing
subdir/
total 8
-rw-r--r-- 1 jfv jfv 15 30 mar 09:38 a.txt
drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
.../subdir:
total 8
-rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
Rewrite c21e292486500afa3a0ded69f4edf30de11d42d1 (5/5)Not removing
subdir/
total 8
-rw-r--r-- 1 jfv jfv 24 30 mar 09:38 a.txt
drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
.../subdir:
total 8
-rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
Ref 'refs/heads/master' was rewritten
$: git log -p
commit c3715041ae38ccc6596986fd1927aff65a3d14bf
Author: Jean-François Veillette <jfveillette@os.ca>
Date: Sun Mar 30 09:35:01 2008 -0400
modified a.txt
diff --git a/a.txt b/a.txt
index 457599c..36d130e 100644
--- a/a.txt
+++ b/a.txt
@@ -1,2 +1,3 @@
line A
line AA
+line AAA
commit d45ccff19c3c81f8c78a22ed5c2436c7a5b99f7c
Author: Jean-François Veillette <jfveillette@os.ca>
Date: Sun Mar 30 09:33:48 2008 -0400
removed all sub files
commit 0f914cb21ab65aac5d966a9552bfb63aa73a996a
Author: Jean-François Veillette <jfveillette@os.ca>
Date: Sun Mar 30 09:33:07 2008 -0400
modified a files
diff --git a/a.txt b/a.txt
index 102c5da..457599c 100644
--- a/a.txt
+++ b/a.txt
@@ -1 +1,2 @@
line A
+line AA
diff --git a/subdir/a.txt b/subdir/a.txt
index 56e593a..b215539 100644
--- a/subdir/a.txt
+++ b/subdir/a.txt
@@ -1 +1,2 @@
line subA
+line subAA
commit b064598f57b4679febaeddda6dfbde43a935796a
Author: Jean-François Veillette <jfveillette@os.ca>
Date: Sun Mar 30 09:32:13 2008 -0400
remove b files
diff --git a/b.txt b/b.txt
deleted file mode 100644
index 346d560..0000000
--- a/b.txt
+++ /dev/null
@@ -1 +0,0 @@
-line B
diff --git a/subdir/b.txt b/subdir/b.txt
deleted file mode 100644
index 7cbec67..0000000
--- a/subdir/b.txt
+++ /dev/null
@@ -1 +0,0 @@
-line subB
commit f264d57f476858aa4ddbf70358500c3be7298048
Author: Jean-François Veillette <jfveillette@os.ca>
Date: Sun Mar 30 09:29:28 2008 -0400
first commit
diff --git a/a.txt b/a.txt
new file mode 100644
index 0000000..102c5da
--- /dev/null
+++ b/a.txt
@@ -0,0 +1 @@
+line A
diff --git a/b.txt b/b.txt
new file mode 100644
index 0000000..346d560
--- /dev/null
+++ b/b.txt
@@ -0,0 +1 @@
+line B
diff --git a/subdir/a.txt b/subdir/a.txt
new file mode 100644
index 0000000..56e593a
--- /dev/null
+++ b/subdir/a.txt
@@ -0,0 +1 @@
+line subA
diff --git a/subdir/b.txt b/subdir/b.txt
new file mode 100644
index 0000000..7cbec67
--- /dev/null
+++ b/subdir/b.txt
@@ -0,0 +1 @@
+line subB
- jfv
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [bug] filter-branch skipping removed files
2008-03-30 14:35 [bug] filter-branch skipping removed files Jean-François Veillette
@ 2008-03-30 23:05 ` Jean-François Veillette
2008-03-31 7:14 ` [PATCH] filter-branch: Test renaming directories in a tree-filter Johannes Sixt
0 siblings, 1 reply; 9+ messages in thread
From: Jean-François Veillette @ 2008-03-30 23:05 UTC (permalink / raw)
To: Git
> It turn out I was able to fix the problem, it was almost too easy:
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 22b6ed4..493c81e 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -281,7 +281,7 @@ while read commit parents; do
die "Could not checkout the index"
# files that $commit removed are now still in the
working tree;
# remove them, else they would be added again
- git clean -q -f -x
+ git clean -d -q -f -x
eval "$filter_tree" < /dev/null ||
die "tree filter failed: $filter_tree"
Previously wrong diff, use the one above instead.
why? : changed the installed copy, tested, then reapplied the '-d'
diff (from memory) to the wrong line in my git workarea to get the diff.
- jfv
> It was my first try, just because I noticed that git-clean was
> giving a 'warning' of non removed directory. At that point I just
> wanted to remove the warning ... but that was enough to fix the
> problem !
> I don't know if it's a real fix, but at least it does correct the
> problem I'm having.
> I have no idea of the implication of what I just touched. the
> 'real' problem might very well be somewhere else.
>
>
> Here is a simple test that show the problem.
>
> $: mkdir test ; cd test
> $: git init
> Initialized empty Git repository in .git/
> $: echo 'line A' > a.txt
> $: echo 'line B' > b.txt
> $: mkdir subdir
> $: echo 'line subA' > subdir/a.txt
> $: echo 'line subB' > subdir/b.txt
> $: git add *
> $: git commit -m 'first commit'
> Created initial commit f264d57: first commit
> 4 files changed, 4 insertions(+), 0 deletions(-)
> create mode 100644 a.txt
> create mode 100644 b.txt
> create mode 100644 subdir/a.txt
> create mode 100644 subdir/b.txt
> $: git rm b.txt subdir/b.txt
> rm 'b.txt'
> rm 'subdir/b.txt'
> $: git commit -m 'remove b files'
> Created commit b064598: remove b files
> 2 files changed, 0 insertions(+), 2 deletions(-)
> delete mode 100644 b.txt
> delete mode 100644 subdir/b.txt
> $: echo 'line AA' >> a.txt
> $: echo 'line subAA' >> subdir/a.txt
> $: git add *
> $: git commit -m 'modified a files'
> Created commit 0f914cb: modified a files
> 2 files changed, 2 insertions(+), 0 deletions(-)
> $: git rm subdir/a.txt
> rm 'subdir/a.txt'
> $: git commit -m 'removed all sub files'
> Created commit 41c0de7: removed all sub files
> 1 files changed, 0 insertions(+), 2 deletions(-)
> delete mode 100644 subdir/a.txt
> $: ls -la
> ...git a.txt
> $: echo 'line AAA' >> a.txt
> $: git add *
> $: git commit -m 'modified a.txt'
> Created commit c21e292: modified a.txt
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
>
>
> $: git filter-branch --tree-filter 'ls -lR' # do nothing, juste
> rewrite itself
> Rewrite f264d57f476858aa4ddbf70358500c3be7298048 (1/5)total 16
> -rw-r--r-- 1 jfv jfv 7 30 mar 09:38 a.txt
> -rw-r--r-- 1 jfv jfv 7 30 mar 09:38 b.txt
> drwxr-xr-x 4 jfv jfv 136 30 mar 09:38 subdir
>
> .../subdir:
> total 16
> -rw-r--r-- 1 jfv jfv 10 30 mar 09:38 a.txt
> -rw-r--r-- 1 jfv jfv 10 30 mar 09:38 b.txt
> Rewrite b064598f57b4679febaeddda6dfbde43a935796a (2/5)total 8
> -rw-r--r-- 1 jfv jfv 7 30 mar 09:38 a.txt
> drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
>
> .../subdir:
> total 8
> -rw-r--r-- 1 jfv jfv 10 30 mar 09:38 a.txt
> Rewrite 0f914cb21ab65aac5d966a9552bfb63aa73a996a (3/5)total 8
> -rw-r--r-- 1 jfv jfv 15 30 mar 09:38 a.txt
> drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
>
> .../subdir:
> total 8
> -rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
> Rewrite 41c0de77880245c23bb56b0b1936564c7adf63de (4/5)Not removing
> subdir/
> total 8
> -rw-r--r-- 1 jfv jfv 15 30 mar 09:38 a.txt
> drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
>
> .../subdir:
> total 8
> -rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
> Rewrite c21e292486500afa3a0ded69f4edf30de11d42d1 (5/5)Not removing
> subdir/
> total 8
> -rw-r--r-- 1 jfv jfv 24 30 mar 09:38 a.txt
> drwxr-xr-x 3 jfv jfv 102 30 mar 09:38 subdir
>
> .../subdir:
> total 8
> -rw-r--r-- 1 jfv jfv 21 30 mar 09:38 a.txt
>
> Ref 'refs/heads/master' was rewritten
>
>
>
> $: git log -p
> commit c3715041ae38ccc6596986fd1927aff65a3d14bf
> Author: Jean-François Veillette <jfveillette@os.ca>
> Date: Sun Mar 30 09:35:01 2008 -0400
>
> modified a.txt
>
> diff --git a/a.txt b/a.txt
> index 457599c..36d130e 100644
> --- a/a.txt
> +++ b/a.txt
> @@ -1,2 +1,3 @@
> line A
> line AA
> +line AAA
>
> commit d45ccff19c3c81f8c78a22ed5c2436c7a5b99f7c
> Author: Jean-François Veillette <jfveillette@os.ca>
> Date: Sun Mar 30 09:33:48 2008 -0400
>
> removed all sub files
>
> commit 0f914cb21ab65aac5d966a9552bfb63aa73a996a
> Author: Jean-François Veillette <jfveillette@os.ca>
> Date: Sun Mar 30 09:33:07 2008 -0400
>
> modified a files
>
> diff --git a/a.txt b/a.txt
> index 102c5da..457599c 100644
> --- a/a.txt
> +++ b/a.txt
> @@ -1 +1,2 @@
> line A
> +line AA
> diff --git a/subdir/a.txt b/subdir/a.txt
> index 56e593a..b215539 100644
> --- a/subdir/a.txt
> +++ b/subdir/a.txt
> @@ -1 +1,2 @@
> line subA
> +line subAA
>
> commit b064598f57b4679febaeddda6dfbde43a935796a
> Author: Jean-François Veillette <jfveillette@os.ca>
> Date: Sun Mar 30 09:32:13 2008 -0400
>
> remove b files
>
> diff --git a/b.txt b/b.txt
> deleted file mode 100644
> index 346d560..0000000
> --- a/b.txt
> +++ /dev/null
> @@ -1 +0,0 @@
> -line B
> diff --git a/subdir/b.txt b/subdir/b.txt
> deleted file mode 100644
> index 7cbec67..0000000
> --- a/subdir/b.txt
> +++ /dev/null
> @@ -1 +0,0 @@
> -line subB
>
> commit f264d57f476858aa4ddbf70358500c3be7298048
> Author: Jean-François Veillette <jfveillette@os.ca>
> Date: Sun Mar 30 09:29:28 2008 -0400
>
> first commit
>
> diff --git a/a.txt b/a.txt
> new file mode 100644
> index 0000000..102c5da
> --- /dev/null
> +++ b/a.txt
> @@ -0,0 +1 @@
> +line A
> diff --git a/b.txt b/b.txt
> new file mode 100644
> index 0000000..346d560
> --- /dev/null
> +++ b/b.txt
> @@ -0,0 +1 @@
> +line B
> diff --git a/subdir/a.txt b/subdir/a.txt
> new file mode 100644
> index 0000000..56e593a
> --- /dev/null
> +++ b/subdir/a.txt
> @@ -0,0 +1 @@
> +line subA
> diff --git a/subdir/b.txt b/subdir/b.txt
> new file mode 100644
> index 0000000..7cbec67
> --- /dev/null
> +++ b/subdir/b.txt
> @@ -0,0 +1 @@
> +line subB
>
>
> - jfv
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] filter-branch: Test renaming directories in a tree-filter
2008-03-30 23:05 ` Jean-François Veillette
@ 2008-03-31 7:14 ` Johannes Sixt
2008-03-31 7:14 ` [PATCH] filter-branch: Fix renaming a directory in the tree-filter Johannes Sixt
0 siblings, 1 reply; 9+ messages in thread
From: Johannes Sixt @ 2008-03-31 7:14 UTC (permalink / raw)
To: Jean-François Veillette; +Cc: Junio C Hamano, Git, Johannes Sixt
This test currently fails.
If b is a directory then 'mv a b' is not a plain "rename", but really a
"move", so we must also test that the directory does not exist with the
old name in the directory with the new name.
There's also some cleanup in the corresponding "rename file" test to avoid
spurious shell syntax errors and "ambigous ref" error from 'git show' (but
these should show up only if the test would fail anyway). Plus we also
test for the non-existence of the old file.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
t/t7003-filter-branch.sh | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 6827249..53b5ce6 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
make_commit B
git checkout -b branch B
make_commit D
+ mkdir dir
+ make_commit dir/D
make_commit E
git checkout master
make_commit C
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
'
test_expect_success 'test that the file was renamed' '
- test d = $(git show HEAD:doh) &&
+ test d = "$(git show HEAD:doh --)" &&
+ ! test -f d &&
test -f doh &&
- test d = $(cat doh)
+ test d = "$(cat doh)"
+'
+
+test_expect_success 'rewrite, renaming a specific directory' '
+ git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
+'
+
+test_expect_failure 'test that the directory was renamed' '
+ test dir/d = "$(git show HEAD:diroh/d --)" &&
+ ! test -d dir &&
+ test -d diroh &&
+ ! test -d diroh/dir &&
+ test -f diroh/d &&
+ test dir/d = "$(cat diroh/d)"
'
git tag oldD HEAD~4
--
1.5.4.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 7:14 ` [PATCH] filter-branch: Test renaming directories in a tree-filter Johannes Sixt
@ 2008-03-31 7:14 ` Johannes Sixt
2008-03-31 8:03 ` Johannes Sixt
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Johannes Sixt @ 2008-03-31 7:14 UTC (permalink / raw)
To: Jean-François Veillette
Cc: Junio C Hamano, Git, Jean-François Veillette, Johannes Sixt
From: Jean-François Veillette <jean francois veillette@yahoo.ca>
Commit d89c1dfac939623a269f60d4e27e3a2929dca29c replaced a
'ls-files | xargs rm' pipeline by 'git clean'. But since 'git clean' does
not recurse and remove directories by default. Now, consider a tree-filter
that renames a directory.
1. For the first commit everything works as expected
2. Then filter-branch checks out the files for the next commit. This
leaves the new directory behind because there is no real "branch
switching" involved that would notice that the directory can be
removed.
3. Then filter-branch invokes 'git clean' to remove exactly those
left-overs. But here it does not remove the directory.
4. The next tree-filter does not work as expected because there already
exists a directory with the new name.
Just add -d to 'git clean'.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
Jean-Francois, there's no sign-off from you. Ok to add it?
-- Hannes
git-filter-branch.sh | 2 +-
t/t7003-filter-branch.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 22b6ed4..ea59015 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -281,7 +281,7 @@ while read commit parents; do
die "Could not checkout the index"
# files that $commit removed are now still in the working tree;
# remove them, else they would be added again
- git clean -q -f -x
+ git clean -d -q -f -x
eval "$filter_tree" < /dev/null ||
die "tree filter failed: $filter_tree"
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 53b5ce6..efd658a 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -53,7 +53,7 @@ test_expect_success 'rewrite, renaming a specific directory' '
git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
'
-test_expect_failure 'test that the directory was renamed' '
+test_expect_success 'test that the directory was renamed' '
test dir/d = "$(git show HEAD:diroh/d --)" &&
! test -d dir &&
test -d diroh &&
--
1.5.4.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 7:14 ` [PATCH] filter-branch: Fix renaming a directory in the tree-filter Johannes Sixt
@ 2008-03-31 8:03 ` Johannes Sixt
2008-03-31 8:40 ` Junio C Hamano
2008-03-31 11:25 ` Jean-François Veillette
2 siblings, 0 replies; 9+ messages in thread
From: Johannes Sixt @ 2008-03-31 8:03 UTC (permalink / raw)
To: Jean-François Veillette; +Cc: Junio C Hamano, Git
Johannes Sixt schrieb:
> Commit d89c1dfac939623a269f60d4e27e3a2929dca29c replaced a
> 'ls-files | xargs rm' pipeline by 'git clean'. But since 'git clean' does
s/since//
> not recurse and remove directories by default. Now, consider a tree-filter
> that renames a directory.
-- Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 7:14 ` [PATCH] filter-branch: Fix renaming a directory in the tree-filter Johannes Sixt
2008-03-31 8:03 ` Johannes Sixt
@ 2008-03-31 8:40 ` Junio C Hamano
2008-03-31 8:47 ` Johannes Sixt
2008-03-31 12:15 ` Johannes Schindelin
2008-03-31 11:25 ` Jean-François Veillette
2 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2008-03-31 8:40 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Jean-François Veillette, Git
Johannes Sixt <johannes.sixt@telecom.at> writes:
> 2. Then filter-branch checks out the files for the next commit. This
> leaves the new directory behind because there is no real "branch
> switching" involved that would notice that the directory can be
> removed.
Thanks.
It obviously is a correct fix to use "clean -d" here, but I strongly
suspect this awkwardness comes from the fact that there is no clear
invariant in this loop.
For example, if you make it the invariant that $T contains the tree that
matches the contents of the "$tempdir/t" work tree left in the previous
round of filter-tree (and obviously you would want to do this only
filter_tree is in effect), the "checkout-index + clean" would become a
proper "branch switching".
This is obviously untested, and you would need to prime $T with an empty
tree before entering the loop (but you could cheat by initializing T with
an empty string), but it might make the code a bit more readable than the
current mess. I dunno.
if [ "$filter_tree" ]; then
- git checkout-index -f -u -a ||
- die "Could not checkout the index"
- # files that $commit removed are now still in the working tree;
- # remove them, else they would be added again
- git clean -d -q -f -x
+ git read-tree -m -u $T $commit
eval "$filter_tree" < /dev/null ||
die "tree filter failed: $filter_tree"
- (
- git diff-index -r --name-only $commit
- git ls-files --others
- ) |
- git update-index --add --replace --remove --stdin
+ git add -u && git add . && T=$(git write-tree)
fi
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 8:40 ` Junio C Hamano
@ 2008-03-31 8:47 ` Johannes Sixt
2008-03-31 12:15 ` Johannes Schindelin
1 sibling, 0 replies; 9+ messages in thread
From: Johannes Sixt @ 2008-03-31 8:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jean-François Veillette, Git, Johannes Schindelin
Junio C Hamano schrieb:
> For example, if you make it the invariant that $T contains the tree that
> matches the contents of the "$tempdir/t" work tree left in the previous
> round of filter-tree (and obviously you would want to do this only
> filter_tree is in effect), the "checkout-index + clean" would become a
> proper "branch switching".
>
> This is obviously untested, and you would need to prime $T with an empty
> tree before entering the loop (but you could cheat by initializing T with
> an empty string), but it might make the code a bit more readable than the
> current mess. I dunno.
>
> if [ "$filter_tree" ]; then
> - git checkout-index -f -u -a ||
> - die "Could not checkout the index"
> - # files that $commit removed are now still in the working tree;
> - # remove them, else they would be added again
> - git clean -d -q -f -x
> + git read-tree -m -u $T $commit
> eval "$filter_tree" < /dev/null ||
> die "tree filter failed: $filter_tree"
>
> - (
> - git diff-index -r --name-only $commit
> - git ls-files --others
> - ) |
> - git update-index --add --replace --remove --stdin
> + git add -u && git add . && T=$(git write-tree)
> fi
Yes. But, ... uhm ..., I'm not that deep into these plumbings; I leave it
to Dscho to comment on this.
-- Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 7:14 ` [PATCH] filter-branch: Fix renaming a directory in the tree-filter Johannes Sixt
2008-03-31 8:03 ` Johannes Sixt
2008-03-31 8:40 ` Junio C Hamano
@ 2008-03-31 11:25 ` Jean-François Veillette
2 siblings, 0 replies; 9+ messages in thread
From: Jean-François Veillette @ 2008-03-31 11:25 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Junio C Hamano, Git
> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
> ---
> Jean-Francois, there's no sign-off from you. Ok to add it?
Yes, just take the credit for yourself, I didn't really know what I
was doing.
- jfv
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter
2008-03-31 8:40 ` Junio C Hamano
2008-03-31 8:47 ` Johannes Sixt
@ 2008-03-31 12:15 ` Johannes Schindelin
1 sibling, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2008-03-31 12:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, Jean-François Veillette, Git
Hi,
On Mon, 31 Mar 2008, Junio C Hamano wrote:
> Johannes Sixt <johannes.sixt@telecom.at> writes:
>
> > 2. Then filter-branch checks out the files for the next commit. This
> > leaves the new directory behind because there is no real "branch
> > switching" involved that would notice that the directory can be
> > removed.
>
> Thanks.
>
> It obviously is a correct fix to use "clean -d" here, but I strongly
> suspect this awkwardness comes from the fact that there is no clear
> invariant in this loop.
>
> For example, if you make it the invariant that $T contains the tree that
> matches the contents of the "$tempdir/t" work tree left in the previous
> round of filter-tree (and obviously you would want to do this only
> filter_tree is in effect), the "checkout-index + clean" would become a
> proper "branch switching".
>
> This is obviously untested, and you would need to prime $T with an empty
> tree before entering the loop (but you could cheat by initializing T
> with an empty string), but it might make the code a bit more readable
> than the current mess. I dunno.
Yes, I'd prefer this.
Originally, I wanted to clean up filter-branch a little, but then somebody
worked on a builtin version of it, which unfortunately came in after the
code freeze, and I always waited for that thing to be picked up and
enhanced. (AFAIR there were quite a few issues which made rewrite-commits
much less useful than it should be.)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-03-31 12:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-30 14:35 [bug] filter-branch skipping removed files Jean-François Veillette
2008-03-30 23:05 ` Jean-François Veillette
2008-03-31 7:14 ` [PATCH] filter-branch: Test renaming directories in a tree-filter Johannes Sixt
2008-03-31 7:14 ` [PATCH] filter-branch: Fix renaming a directory in the tree-filter Johannes Sixt
2008-03-31 8:03 ` Johannes Sixt
2008-03-31 8:40 ` Junio C Hamano
2008-03-31 8:47 ` Johannes Sixt
2008-03-31 12:15 ` Johannes Schindelin
2008-03-31 11:25 ` Jean-François Veillette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox