Re: git diff --patience

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git diff --patience
Date: 2010-10-01 14:15:30
Message-ID: 4CA5A6B202000025000362BD@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com>wrote:

>> There is a very simple example posted on some of the blog posts
>> that goes something like
>>
>> aaaaaaaa
>> aaaaaaaa
>> aaaaaaaa
>> bbbbbbbb
>> bbbbbbbb
>> bbbbbbbb
>> xyz
>>
>> and the "xyz" is moved to the front. In this corner case, the
>> patience diff is a lot worse.
>>
>
> Sorry, but that example didn't make much sense to me. Can you
> please elaborate, or maybe share those blog posts you are referring
to.

I tried it out. Here are the results:

git diff --color
diff --git a/a1 b/a1
index bd0586b..32736d1 100644
--- a/a1
+++ b/a1
@@ -1,7 +1,7 @@
+xyz
aaaaaaaa
aaaaaaaa
aaaaaaaa
bbbbbbbb
bbbbbbbb
bbbbbbbb
-xyz
git diff --color --patience
diff --git a/a1 b/a1
index bd0586b..32736d1 100644
--- a/a1
+++ b/a1
@@ -1,7 +1,7 @@
-aaaaaaaa
-aaaaaaaa
-aaaaaaaa
-bbbbbbbb
-bbbbbbbb
-bbbbbbbb
xyz
+aaaaaaaa
+aaaaaaaa
+aaaaaaaa
+bbbbbbbb
+bbbbbbbb
+bbbbbbbb

This is because lines which only occur once in a file are the
"anchors" around which lines which occur multiple times move --
after keeping intact any leading and trailing lines which match
between the files. An interesting exercise it so think about what
real-life lines you could have which would have multiple occurrences
in this pattern, and think about whether you would then prefer the
--patience output, especially if this were part of a larger file.
Even in this supposed "worst case" example, I'm not at all sure I
wouldn't prefer --patience, personally, even though more lines are
flagged.

-Kevin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2010-10-01 14:16:43 Re: is sync rep stalled?
Previous Message Hitoshi Harada 2010-10-01 14:11:08 Re: wip: functions median and percentile