From: Pierre Habouzit <madcoder@debian.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: davidel@xmailserver.org, Francis Galiegue <fg@one2team.net>,
Git ML <git@vger.kernel.org>
Subject: Re: [PATCH 0/3] Teach Git about the patience diff algorithm
Date: Tue, 06 Jan 2009 12:39:43 +0100 [thread overview]
Message-ID: <20090106113943.GA28659@artemis.corp> (raw)
In-Reply-To: <20090106111712.GB30766@artemis.corp>
[-- Attachment #1.1: Type: text/plain, Size: 2784 bytes --]
On Tue, Jan 06, 2009 at 11:17:12AM +0000, Pierre Habouzit wrote:
> On jeu, jan 01, 2009 at 04:38:09 +0000, Johannes Schindelin wrote:
> >
> > Nothing fancy, really, just a straight-forward implementation of the
> > heavily under-documented and under-analyzed paience diff algorithm.
>
> Btw, what is the status of this series ? I see it neither in pu nor in
> next. And I would gladly see it included in git.
Johannes: I've not had time to investigate, but when finding what I
present in the end of this mail, I ran:
git log -p > log-normal
git log -p --patience > log-patience
in git.git.
I saw that patience diff is slower than normal diff, which is expected,
but I had to kill the latter command because it leaks like hell. I've
not investigated yet (And yes I'm running your latest posted series).
> On jeu, jan 01, 2009 at 07:45:21 +0000, Linus Torvalds wrote:
> > On Thu, 1 Jan 2009, Johannes Schindelin wrote:
> > >
> > > Nothing fancy, really, just a straight-forward implementation of the
> > > heavily under-documented and under-analyzed paience diff algorithm.
> >
> > Exactly because the patience diff is so under-documented, could you
> > perhaps give a few examples of how it differs in the result, and why it's
> > so wonderful? Yes, yes, I can google, and no, no, nothing useful shows up
> > except for *totally* content-free fanboisms.
> >
> > So could we have some actual real data on it?
> I've checked in many projects I have under git, the differences between
> git log -p and git log -p --patience. The patience algorithm is really
> really more readable with it involves code moves with changes in the
> moved sections. If the section you move across is smaller than the moved
> ones, the patience algorithm will show the moved code as removed where
> it was and added where it now is, changes included. The current diff
> will rather move the smaller invariend section you move across and
> present mangled diffs involving the function prototypes making it less
> than readable.
Actually git.git has a canonical example of this in 214a34d22.
For those not having the --patience diff applied locally, attached are
the two patches git show / git show --patience give. It's of course a
matter of taste, but I like the patience version a lot more.
I'm also curious to see what a merge conflict with such a move would
look like (e.g. inverting some of the added arguments to the factorized
function of 214a34d22 or something similar). I'm somehow convinced that
it would generate a nicer conflict somehow.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #1.2: 214a34d22.normal --]
[-- Type: text/plain, Size: 2323 bytes --]
commit 214a34d22ec59ec7e1166772f06ecf8799f96c96
Author: Florian Weimer <fw@deneb.enyo.de>
Date: Sun Aug 31 17:45:04 2008 +0200
git-svn: Introduce SVN::Git::Editor::_chg_file_get_blob
Signed-off-by: Florian Weimer <fw@deneb.enyo.de>
Acked-by: Eric Wong <normalperson@yhbt.net>
diff --git a/git-svn.perl b/git-svn.perl
index 0479f41..2c3e13f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3663,28 +3663,35 @@ sub change_file_prop {
$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
}
-sub chg_file {
- my ($self, $fbat, $m) = @_;
- if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
- $self->change_file_prop($fbat,'svn:executable','*');
- } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
- $self->change_file_prop($fbat,'svn:executable',undef);
- }
- my $fh = Git::temp_acquire('git_blob');
- if ($m->{mode_b} =~ /^120/) {
+sub _chg_file_get_blob ($$$$) {
+ my ($self, $fbat, $m, $which) = @_;
+ my $fh = Git::temp_acquire("git_blob_$which");
+ if ($m->{"mode_$which"} =~ /^120/) {
print $fh 'link ' or croak $!;
$self->change_file_prop($fbat,'svn:special','*');
- } elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
+ } elsif ($m->{mode_a} =~ /^120/ && $m->{"mode_$which"} !~ /^120/) {
$self->change_file_prop($fbat,'svn:special',undef);
}
- my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
- croak "Failed to read object $m->{sha1_b}" if ($size < 0);
+ my $blob = $m->{"sha1_$which"};
+ return ($fh,) if ($blob =~ /^0{40}$/);
+ my $size = $::_repository->cat_blob($blob, $fh);
+ croak "Failed to read object $blob" if ($size < 0);
$fh->flush == 0 or croak $!;
seek $fh, 0, 0 or croak $!;
my $exp = ::md5sum($fh);
seek $fh, 0, 0 or croak $!;
+ return ($fh, $exp);
+}
+sub chg_file {
+ my ($self, $fbat, $m) = @_;
+ if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
+ $self->change_file_prop($fbat,'svn:executable','*');
+ } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
+ $self->change_file_prop($fbat,'svn:executable',undef);
+ }
+ my ($fh, $exp) = _chg_file_get_blob $self, $fbat, $m, 'b';
my $pool = SVN::Pool->new;
my $atd = $self->apply_textdelta($fbat, undef, $pool);
my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);
[-- Attachment #1.3: 214a34d22.patience --]
[-- Type: text/plain, Size: 2290 bytes --]
commit 214a34d22ec59ec7e1166772f06ecf8799f96c96
Author: Florian Weimer <fw@deneb.enyo.de>
Date: Sun Aug 31 17:45:04 2008 +0200
git-svn: Introduce SVN::Git::Editor::_chg_file_get_blob
Signed-off-by: Florian Weimer <fw@deneb.enyo.de>
Acked-by: Eric Wong <normalperson@yhbt.net>
diff --git a/git-svn.perl b/git-svn.perl
index 0479f41..2c3e13f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3663,6 +3663,27 @@ sub change_file_prop {
$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
}
+sub _chg_file_get_blob ($$$$) {
+ my ($self, $fbat, $m, $which) = @_;
+ my $fh = Git::temp_acquire("git_blob_$which");
+ if ($m->{"mode_$which"} =~ /^120/) {
+ print $fh 'link ' or croak $!;
+ $self->change_file_prop($fbat,'svn:special','*');
+ } elsif ($m->{mode_a} =~ /^120/ && $m->{"mode_$which"} !~ /^120/) {
+ $self->change_file_prop($fbat,'svn:special',undef);
+ }
+ my $blob = $m->{"sha1_$which"};
+ return ($fh,) if ($blob =~ /^0{40}$/);
+ my $size = $::_repository->cat_blob($blob, $fh);
+ croak "Failed to read object $blob" if ($size < 0);
+ $fh->flush == 0 or croak $!;
+ seek $fh, 0, 0 or croak $!;
+
+ my $exp = ::md5sum($fh);
+ seek $fh, 0, 0 or croak $!;
+ return ($fh, $exp);
+}
+
sub chg_file {
my ($self, $fbat, $m) = @_;
if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
@@ -3670,21 +3691,7 @@ sub chg_file {
} elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
$self->change_file_prop($fbat,'svn:executable',undef);
}
- my $fh = Git::temp_acquire('git_blob');
- if ($m->{mode_b} =~ /^120/) {
- print $fh 'link ' or croak $!;
- $self->change_file_prop($fbat,'svn:special','*');
- } elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
- $self->change_file_prop($fbat,'svn:special',undef);
- }
- my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
- croak "Failed to read object $m->{sha1_b}" if ($size < 0);
- $fh->flush == 0 or croak $!;
- seek $fh, 0, 0 or croak $!;
-
- my $exp = ::md5sum($fh);
- seek $fh, 0, 0 or croak $!;
-
+ my ($fh, $exp) = _chg_file_get_blob $self, $fbat, $m, 'b';
my $pool = SVN::Pool->new;
my $atd = $self->apply_textdelta($fbat, undef, $pool);
my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-01-06 11:41 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 0:40 libxdiff and patience diff Pierre Habouzit
2008-11-04 3:17 ` Davide Libenzi
2008-11-04 8:33 ` Pierre Habouzit
2008-11-04 5:39 ` Johannes Schindelin
2008-11-04 8:30 ` Pierre Habouzit
2008-11-04 14:34 ` Johannes Schindelin
2008-11-04 15:23 ` Pierre Habouzit
2008-11-04 15:57 ` Johannes Schindelin
2008-11-04 16:15 ` Pierre Habouzit
2009-01-01 16:38 ` [PATCH 0/3] Teach Git about the patience diff algorithm Johannes Schindelin
2009-01-01 16:38 ` [PATCH 1/3] Implement " Johannes Schindelin
2009-01-01 16:39 ` [PATCH 2/3] Introduce the diff option '--patience' Johannes Schindelin
2009-01-01 16:39 ` [PATCH 3/3] bash completions: Add the --patience option Johannes Schindelin
2009-01-01 19:45 ` [PATCH 0/3] Teach Git about the patience diff algorithm Linus Torvalds
2009-01-01 20:00 ` Linus Torvalds
2009-01-02 18:17 ` Johannes Schindelin
2009-01-02 18:49 ` Linus Torvalds
2009-01-02 19:07 ` Johannes Schindelin
2009-01-02 18:51 ` Jeff King
2009-01-02 21:59 ` [PATCH 1/3 v2] Implement " Johannes Schindelin
2009-01-02 21:59 ` Johannes Schindelin
2009-01-01 20:46 ` [PATCH 0/3] Teach Git about " Adeodato Simó
2009-01-02 1:56 ` Linus Torvalds
2009-01-02 10:55 ` Clemens Buchacher
2009-01-02 10:58 ` Clemens Buchacher
2009-01-02 16:42 ` Linus Torvalds
2009-01-02 18:46 ` Johannes Schindelin
2009-01-02 19:03 ` Linus Torvalds
2009-01-02 19:22 ` Johannes Schindelin
2009-01-02 19:39 ` Jeff King
2009-01-02 19:50 ` Jeff King
2009-01-02 20:52 ` Jeff King
2009-01-02 23:05 ` Linus Torvalds
2009-01-03 16:24 ` Bazaar's patience diff as GIT_EXTERNAL_DIFF Adeodato Simó
2009-01-02 21:59 ` [PATCH 0/3] Teach Git about the patience diff algorithm Johannes Schindelin
2009-01-08 19:55 ` Adeodato Simó
2009-01-08 20:06 ` Adeodato Simó
2009-01-09 6:54 ` Junio C Hamano
2009-01-09 13:07 ` Johannes Schindelin
2009-01-09 15:59 ` Adeodato Simó
2009-01-09 18:09 ` Linus Torvalds
2009-01-09 18:13 ` Linus Torvalds
2009-01-09 20:53 ` Junio C Hamano
2009-01-10 11:36 ` Johannes Schindelin
2009-01-02 11:03 ` Junio C Hamano
2009-01-02 18:50 ` Adeodato Simó
2009-01-06 11:17 ` Pierre Habouzit
2009-01-06 11:39 ` Pierre Habouzit [this message]
2009-01-06 19:40 ` Johannes Schindelin
2009-01-07 14:39 ` Pierre Habouzit
2009-01-07 17:01 ` Johannes Schindelin
2009-01-07 17:04 ` [PATCH v3 1/3] Implement " Johannes Schindelin
2009-01-07 18:10 ` Davide Libenzi
2009-01-07 18:32 ` Johannes Schindelin
2009-01-07 20:09 ` Davide Libenzi
2009-01-07 20:19 ` Johannes Schindelin
2009-01-07 18:59 ` Linus Torvalds
2009-01-07 20:00 ` Johannes Schindelin
2009-01-07 20:11 ` Davide Libenzi
2009-01-07 20:15 ` [PATCH 0/3] Teach Git about " Sam Vilain
2009-01-07 20:25 ` Linus Torvalds
2009-01-08 2:31 ` Sam Vilain
2009-01-07 20:38 ` Johannes Schindelin
2009-01-07 20:48 ` Junio C Hamano
2009-01-07 22:00 ` Johannes Schindelin
2009-01-07 22:45 ` Pierre Habouzit
2009-01-07 23:03 ` Johannes Schindelin
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=20090106113943.GA28659@artemis.corp \
--to=madcoder@debian.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=davidel@xmailserver.org \
--cc=fg@one2team.net \
--cc=git@vger.kernel.org \
--cc=torvalds@linux-foundation.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).