Discussion:
[BUG] Possible issue with word-diff option
Éric Alber
2014-10-23 18:54:15 UTC
Permalink
Hi,

I'm currently developing a local web based GUI for git in the same
fashion as mercurial's 'hg serve': git-webui
(https://github.com/alberthier/git-webui)
I tried to add word-diff highlighting in my diff visualization panels.
I used the '--word-diff=porcelain' option of 'git show' and 'git
diff'.

Unfortunately I ran into an issue so I want to make sure I understand
properly the format
Here is how I interpret this output:
- A line of the diff no longer corresponds to a line in the source
file. A line of the source file, is represented between two leading
'~' markers
- A line starting with a '+' or '-' is respectively an added or
removed line fragment
- A line starting with a ' ' (space) is an unchanged line fragment

The problem is visible with the git-webui repository itself:

git clone https://github.com/alberthier/git-webui
git show --word-diff=porcelain ed934a7 # This is the head
of the 'word-diff' branch
# search for the first occurrence of 'fragment'

In the source code, several lines have been replaced with the
following single line:

var fragment = line.substr(1);

But in the diff, 'fragment' and 'line.substr(1);' don't apprear in the
same '~' block.
I get:

~
var
-pre
+fragment
=
-$('<pre class="diff-view-line">').appendTo(view)[0];
~
[ some removed lines....]
~
- }
+line.substr(1);
~

By reading this output, it looks like 'var fragment = ' and
'line.substr(1);' aren't on the same line.
I would have expected:

~
var
-pre
+fragment
=
-$('<pre class="diff-view-line">').appendTo(view)[0];
+line.substr(1);
~
[ some removed lines....]

Is there something I miss or is this a bug of git's word-diff algorithm ?

Regards,

Eric
Éric Alber
2014-10-23 20:01:40 UTC
Permalink
I forgot to mention the version :
I tested with Ubuntu's git 1.9.1 and a 2.1.0 version I built myself
Post by Éric Alber
Hi,
I'm currently developing a local web based GUI for git in the same
fashion as mercurial's 'hg serve': git-webui
(https://github.com/alberthier/git-webui)
I tried to add word-diff highlighting in my diff visualization panels=
=2E
Post by Éric Alber
I used the '--word-diff=3Dporcelain' option of 'git show' and 'git
diff'.
Unfortunately I ran into an issue so I want to make sure I understand
properly the format
- A line of the diff no longer corresponds to a line in the source
file. A line of the source file, is represented between two leading
'~' markers
- A line starting with a '+' or '-' is respectively an added or
removed line fragment
- A line starting with a ' ' (space) is an unchanged line fragment
git clone https://github.com/alberthier/git-webui
git show --word-diff=3Dporcelain ed934a7 # This is the hea=
d
Post by Éric Alber
of the 'word-diff' branch
# search for the first occurrence of 'fragment'
In the source code, several lines have been replaced with the
var fragment =3D line.substr(1);
But in the diff, 'fragment' and 'line.substr(1);' don't apprear in th=
e
Post by Éric Alber
same '~' block.
~
var
-pre
+fragment
=3D
-$('<pre class=3D"diff-view-line">').appendTo(view)[0];
~
[ some removed lines....]
~
- }
+line.substr(1);
~
By reading this output, it looks like 'var fragment =3D ' and
'line.substr(1);' aren't on the same line.
~
var
-pre
+fragment
=3D
-$('<pre class=3D"diff-view-line">').appendTo(view)[0];
+line.substr(1);
~
[ some removed lines....]
Is there something I miss or is this a bug of git's word-diff algorit=
hm ?
Post by Éric Alber
Regards,
Eric
Continue reading on narkive:
Loading...