{"thread":{"id":"26072","subject":"html userdiff is not showing all my changes","startedAt":"2010-12-15T03:47:12Z","lastAt":"2010-12-15T09:29:01Z","messageCount":4,"participants":["Scott Johnson","Michael J Gruber","Matthijs Kooijman"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158135","messageId":"561247.22837.qm@web110707.mail.gq1.yahoo.com","threadId":"26072","inReplyTo":null,"subject":"html userdiff is not showing all my changes","fromName":"Scott Johnson","fromEmail":"scottj75074@yahoo.com","sentAt":"2010-12-15T03:47:12Z","receivedAt":"2010-12-15T03:47:12Z","isPatch":false,"sender":{"key":"scottj75074@yahoo.com","avatar":null},"body":"I am attempting to do a word diff of an html source file. Part of the removed \nhtml is disappearing from the diff when I enable the fancy html word diff.\n\nHere's the output from basic `git diff`:\ndiff --git a/adv_layout_source.html b/adv_layout_source.html\nindex 18a81dd..c4ed609 100644\n--- a/adv_layout_source.html\n+++ b/adv_layout_source.html\n@@ -42,8 +42,8 @@\n       <ul>\n         <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n         <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n-        <li class=\"yws-maps\"><em></em><a href=\"#\">yws-maps</a></li>\n-        <li class=\"ydn-delicious\"><em></em><a href=\"#\">ydn-delicious</a></li>\n+        <li><em></em><a href=\"#\">yws-maps</a></li>\n+        <li><em></em><a href=\"#\">ydn-delicious</a></li>\n         <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n         <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n       </ul>\n\n\nHere's the default `git diff --word-diff`:\ndiff --git a/adv_layout_source.html b/adv_layout_source.html\nindex 18a81dd..c4ed609 100644\n--- a/adv_layout_source.html\n+++ b/adv_layout_source.html\n@@ -42,8 +42,8 @@\n      <ul>\n        <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n        <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n        [-<li class=\"yws-maps\"><em></em><a-]{+<li><em></em><a+} \nhref=\"#\">yws-maps</a></li>\n        [-<li class=\"ydn-delicious\"><em></em><a-]{+<li><em></em><a+} \nhref=\"#\">ydn-delicious</a></li>\n        <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n        <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n      </ul>\n\nWhich is correct, but less than ideal because it highlights much more than the \nactual changes.\n\nSo I create a .gitattributes file with one line:\n*.html diff=html\n\nAnd rerun `git diff --word-diff`:\ndiff --git a/adv_layout_source.html b/adv_layout_source.html\nindex 18a81dd..c4ed609 100644\n--- a/adv_layout_source.html\n+++ b/adv_layout_source.html\n@@ -42,8 +42,8 @@\n      <ul>\n        <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n        <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n        <li[-class=\"yws-maps\"-]><em></em><a href=\"#\">yws-maps</a></li>\n        <li><em></em><a href=\"#\">ydn-delicious</a></li>\n        <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n        <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n      </ul>\n\nYikes! What happened to the second line of changes? The removed code is not \ndisplayed at all.\n\nThis is running git 1.7.3.3.\n\nI suspect the problem is in the html patterns in userdiff.c, but I don't \nunderstand the word-diff-regex well enough to fix it.\n"},{"id":"158149","messageId":"4D08850D.3010402@drmicha.warpmail.net","threadId":"26072","inReplyTo":"561247.22837.qm@web110707.mail.gq1.yahoo.com","subject":"Re: html userdiff is not showing all my changes","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-15T09:06:21Z","receivedAt":"2010-12-15T09:06:21Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Scott Johnson venit, vidit, dixit 15.12.2010 04:47:\n> I am attempting to do a word diff of an html source file. Part of the removed \n> html is disappearing from the diff when I enable the fancy html word diff.\n> \n> Here's the output from basic `git diff`:\n> diff --git a/adv_layout_source.html b/adv_layout_source.html\n> index 18a81dd..c4ed609 100644\n> --- a/adv_layout_source.html\n> +++ b/adv_layout_source.html\n> @@ -42,8 +42,8 @@\n>        <ul>\n>          <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n>          <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n> -        <li class=\"yws-maps\"><em></em><a href=\"#\">yws-maps</a></li>\n> -        <li class=\"ydn-delicious\"><em></em><a href=\"#\">ydn-delicious</a></li>\n> +        <li><em></em><a href=\"#\">yws-maps</a></li>\n> +        <li><em></em><a href=\"#\">ydn-delicious</a></li>\n>          <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n>          <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n>        </ul>\n> \n> \n> Here's the default `git diff --word-diff`:\n> diff --git a/adv_layout_source.html b/adv_layout_source.html\n> index 18a81dd..c4ed609 100644\n> --- a/adv_layout_source.html\n> +++ b/adv_layout_source.html\n> @@ -42,8 +42,8 @@\n>       <ul>\n>         <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n>         <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n>         [-<li class=\"yws-maps\"><em></em><a-]{+<li><em></em><a+} \n> href=\"#\">yws-maps</a></li>\n>         [-<li class=\"ydn-delicious\"><em></em><a-]{+<li><em></em><a+} \n> href=\"#\">ydn-delicious</a></li>\n>         <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n>         <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n>       </ul>\n> \n> Which is correct, but less than ideal because it highlights much more than the \n> actual changes.\n> \n> So I create a .gitattributes file with one line:\n> *.html diff=html\n> \n> And rerun `git diff --word-diff`:\n> diff --git a/adv_layout_source.html b/adv_layout_source.html\n> index 18a81dd..c4ed609 100644\n> --- a/adv_layout_source.html\n> +++ b/adv_layout_source.html\n> @@ -42,8 +42,8 @@\n>       <ul>\n>         <li class=\"ydn-patterns\"><em></em><a href=\"#\">ydn-patterns</a></li>\n>         <li class=\"ydn-mail\"><em></em><a href=\"#\">ydn-mail</a></li>\n>         <li[-class=\"yws-maps\"-]><em></em><a href=\"#\">yws-maps</a></li>\n>         <li><em></em><a href=\"#\">ydn-delicious</a></li>\n>         <li class=\"yws-flickr\"><em></em><a href=\"#\">yws-flickr</a></li>\n>         <li class=\"yws-events\"><em></em><a href=\"#\">yws-events</a></li>\n>       </ul>\n> \n> Yikes! What happened to the second line of changes? The removed code is not \n> displayed at all.\n> \n> This is running git 1.7.3.3.\n> \n> I suspect the problem is in the html patterns in userdiff.c, but I don't \n> understand the word-diff-regex well enough to fix it.\n\nThe wordRegex should really only control what comprises a word, i.e. the\ngranularity of --word-diff. (Where do we insert additional line-breaks\nbefore running ordinary diff?)\n\nIf a wordRegex can make parts of diff disappear than there is problem\ndeeper in the diff machinery. Can you trim this down to a minimal example?\n\nMichael\n"},{"id":"158151","messageId":"20101215091250.GO3069@login.drsnuggles.stderr.nl","threadId":"26072","inReplyTo":"4D08850D.3010402@drmicha.warpmail.net","subject":"Re: html userdiff is not showing all my changes","fromName":"Matthijs Kooijman","fromEmail":"matthijs@stdin.nl","sentAt":"2010-12-15T09:12:50Z","receivedAt":"2010-12-15T09:12:50Z","isPatch":false,"sender":{"key":"matthijs@stdin.nl","avatar":"https://avatars.githubusercontent.com/u/194491?v=4"},"body":"Hi Michael,\n\n> If a wordRegex can make parts of diff disappear than there is problem\n> deeper in the diff machinery.\nIt can do exactly that. The word regex determines what is a word, but\neverything else is counted as \"whitespace\". The word diff view shows\nonly differences in words, not in whitespace (which is intentional,\nsince whitespace changes in things like LaTeX or HTML are not\ninteresting). Note that it doesn't show whitespace _differences_, but it\ndoes show the whitespace itself (taken from the \"new\" version of the\nfile).\n\n\nSo, if the word regex somehow doesn't match the second line at all (or\nat least not the differen part), the differences could get ignored.\n\n> Can you trim this down to a minimal example?\nThat would be useful in any case.\n\nGr.\n\nMatthijs\n"},{"id":"158152","messageId":"4D088A5D.60705@drmicha.warpmail.net","threadId":"26072","inReplyTo":"20101215091250.GO3069@login.drsnuggles.stderr.nl","subject":"Re: html userdiff is not showing all my changes","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-15T09:29:01Z","receivedAt":"2010-12-15T09:29:01Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Matthijs Kooijman venit, vidit, dixit 15.12.2010 10:12:\n> Hi Michael,\n> \n>> If a wordRegex can make parts of diff disappear than there is problem\n>> deeper in the diff machinery.\n> It can do exactly that. The word regex determines what is a word, but\n> everything else is counted as \"whitespace\". The word diff view shows\n> only differences in words, not in whitespace (which is intentional,\n> since whitespace changes in things like LaTeX or HTML are not\n> interesting). Note that it doesn't show whitespace _differences_, but it\n> does show the whitespace itself (taken from the \"new\" version of the\n> file).\n\nYep, I just found out myself experimenting with a wordRegex for csv.\nSeems like quite a \"Gimme rope\" feature...\n\nSo, it's the regex.\n\n> So, if the word regex somehow doesn't match the second line at all (or\n> at least not the differen part), the differences could get ignored.\n> \n>> Can you trim this down to a minimal example?\n> That would be useful in any case.\n\nWhat strikes me is that both lines are semantically identical, yet one\nis treated correctly and the other isn't.\n\nMichael\n"}]}