Git development
 help / color / mirror / Atom feed
* [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
@ 2008-02-15 16:56 Remi Vanicat
  2008-02-15 17:50 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Remi Vanicat @ 2008-02-15 16:56 UTC (permalink / raw)
  To: git

git filter-branch --tree-filter has a problem with filename with
accentuated letter:

$ git add foo/baré
$ git commit -m "adding a file with an accent"
Created initial commit b27ae97: adding a file with an accent
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "foo/bar\303\251"
$ git filter-branch --tree-filter "rm -rf foo"
Rewrite b27ae977459379e4e7eee1a3d523f908903ea6ae (1/1)
WARNING: Ref 'refs/heads/master' is unchanged

there the foo/baré file still exists, but:
$ git filter-branch --tree-filter "rm -rf foo; git add -u"
will suppress the said file from history.

The culprit seem to be those line of filter-branch: (around line 279) 
		git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
			xargs -0 git update-index --add --replace --remove
git diff-index giving the filename as "foo/bar\303\251"


-- 
Rémi Vanicat

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-15 16:56 [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename Remi Vanicat
@ 2008-02-15 17:50 ` Junio C Hamano
  2008-02-15 18:12   ` Johannes Schindelin
  2008-02-16  6:34   ` Remi Vanicat
  0 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2008-02-15 17:50 UTC (permalink / raw)
  To: Remi Vanicat; +Cc: git

Remi Vanicat <vanicat@debian.org> writes:

> The culprit seem to be those line of filter-branch: (around line 279) 
> 		git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
> 			xargs -0 git update-index --add --replace --remove
> git diff-index giving the filename as "foo/bar\303\251"

I have to wonder in what century filter-branch was written ;-)

Shouldn't those two lines be:

	git diff-index -r --name-only $commit |
        git update-index --add --replace --remove --stdin

these days, without any of the cut and cruft?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-15 17:50 ` Junio C Hamano
@ 2008-02-15 18:12   ` Johannes Schindelin
  2008-02-15 22:21     ` Junio C Hamano
  2008-02-16  6:34   ` Remi Vanicat
  1 sibling, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2008-02-15 18:12 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Remi Vanicat, git

Hi,

On Fri, 15 Feb 2008, Junio C Hamano wrote:

> Remi Vanicat <vanicat@debian.org> writes:
> 
> > The culprit seem to be those line of filter-branch: (around line 279) 
> > 		git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
> > 			xargs -0 git update-index --add --replace --remove
> > git diff-index giving the filename as "foo/bar\303\251"
> 
> I have to wonder in what century filter-branch was written ;-)
> 
> Shouldn't those two lines be:
> 
> 	git diff-index -r --name-only $commit |
>         git update-index --add --replace --remove --stdin
> 
> these days, without any of the cut and cruft?

Maybe even using "-z" in both cases?

Having said that, I do not understand why the old code did not work.  Will 
have a look later today.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-15 18:12   ` Johannes Schindelin
@ 2008-02-15 22:21     ` Junio C Hamano
  2008-02-16  3:09       ` Johannes Schindelin
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2008-02-15 22:21 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Remi Vanicat, git

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

>> I have to wonder in what century filter-branch was written ;-)
>> 
>> Shouldn't those two lines be:
>> 
>> 	git diff-index -r --name-only $commit |
>>         git update-index --add --replace --remove --stdin
>> 
>> these days, without any of the cut and cruft?
>
> Maybe even using "-z" in both cases?
>
> Having said that, I do not understand why the old code did not work.  Will 
> have a look later today.

The reason mine does not have to use -z is because both end
knows how to C-quote paths under non-z mode.

Now you mention it, it certainly is a bit puzzling why the old
one did not work.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-15 22:21     ` Junio C Hamano
@ 2008-02-16  3:09       ` Johannes Schindelin
  2008-02-16 12:48         ` Johannes Schindelin
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2008-02-16  3:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Remi Vanicat, git

Hi,

On Fri, 15 Feb 2008, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Having said that, I do not understand why the old code did not work.  
> > Will have a look later today.
> 
> Now you mention it, it certainly is a bit puzzling why the old one did 
> not work.

Okay, so I will not manage today.  Tomorrow is another day.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-15 17:50 ` Junio C Hamano
  2008-02-15 18:12   ` Johannes Schindelin
@ 2008-02-16  6:34   ` Remi Vanicat
  2008-02-16  7:54     ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Remi Vanicat @ 2008-02-16  6:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Remi Vanicat, git

Junio C Hamano <gitster@pobox.com> writes:

> Remi Vanicat <vanicat@debian.org> writes:
>
>> The culprit seem to be those line of filter-branch: (around line 279) 
>> 		git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
>> 			xargs -0 git update-index --add --replace --remove
>> git diff-index giving the filename as "foo/bar\303\251"
>
> I have to wonder in what century filter-branch was written ;-)
>
> Shouldn't those two lines be:
>
> 	git diff-index -r --name-only $commit |
>         git update-index --add --replace --remove --stdin

That solve the bug for me.
-- 
Rémi Vanicat

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-16  6:34   ` Remi Vanicat
@ 2008-02-16  7:54     ` Junio C Hamano
  2008-02-16  8:26       ` Remi Vanicat
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2008-02-16  7:54 UTC (permalink / raw)
  To: Remi Vanicat; +Cc: git, Johannes Schindelin

Not just those two lines but the next two lines were also very
old fashioned.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * Could you try this one?

 git-filter-branch.sh     |    9 +++++----
 t/t7003-filter-branch.sh |   14 ++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ff716ca..49e13f0 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -276,10 +276,11 @@ while read commit parents; do
 		eval "$filter_tree" < /dev/null ||
 			die "tree filter failed: $filter_tree"
 
-		git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
-			xargs -0 git update-index --add --replace --remove
-		git ls-files -z --others | \
-			xargs -0 git update-index --add --replace --remove
+		(
+			git diff-index -r --name-only $commit
+			git ls-files --others
+		) |
+		git update-index --add --replace --remove --stdin
 	fi
 
 	eval "$filter_index" < /dev/null ||
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 5f60b22..868babc 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -165,4 +165,18 @@ test_expect_success '"map" works in commit filter' '
 	git rev-parse --verify master
 '
 
+test_expect_success 'Name needing quotes' '
+
+	git checkout -b rerere A &&
+	mkdir foo &&
+	name="れれれ" &&
+	>foo/$name &&
+	git add foo &&
+	git commit -m "Adding a file" &&
+	git filter-branch --tree-filter "rm -fr foo" &&
+	! git ls-files --error-unmatch "foo/$name" &&
+	test $(git rev-parse --verify rerere) != $(git rev-parse --verify A)
+
+'
+
 test_done

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-16  7:54     ` Junio C Hamano
@ 2008-02-16  8:26       ` Remi Vanicat
  0 siblings, 0 replies; 9+ messages in thread
From: Remi Vanicat @ 2008-02-16  8:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Remi Vanicat, git, Johannes Schindelin

Junio C Hamano <gitster@pobox.com> writes:

> Not just those two lines but the next two lines were also very
> old fashioned.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
>  * Could you try this one?

It work both on my real word case and on my tests git repositories. 


-- 
Rémi Vanicat

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename
  2008-02-16  3:09       ` Johannes Schindelin
@ 2008-02-16 12:48         ` Johannes Schindelin
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2008-02-16 12:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Remi Vanicat, git

Hi,

On Sat, 16 Feb 2008, Johannes Schindelin wrote:

> On Fri, 15 Feb 2008, Junio C Hamano wrote:
> 
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > 
> > > Having said that, I do not understand why the old code did not work.  
> > > Will have a look later today.
> > 
> > Now you mention it, it certainly is a bit puzzling why the old one did 
> > not work.
> 
> Okay, so I will not manage today.  Tomorrow is another day.

Ah, now I understand.  The accents are shown quoted, but xargs does not 
know how to unquote them.  Cute.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-02-16 12:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15 16:56 [BUG] git filter-branch failed to suppress a file with an accentuated letter in the filename Remi Vanicat
2008-02-15 17:50 ` Junio C Hamano
2008-02-15 18:12   ` Johannes Schindelin
2008-02-15 22:21     ` Junio C Hamano
2008-02-16  3:09       ` Johannes Schindelin
2008-02-16 12:48         ` Johannes Schindelin
2008-02-16  6:34   ` Remi Vanicat
2008-02-16  7:54     ` Junio C Hamano
2008-02-16  8:26       ` Remi Vanicat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox