{"thread":{"id":"37789","subject":"[BUG] Possible issue with word-diff option","startedAt":"2014-10-23T18:54:15Z","lastAt":"2014-10-23T20:01:40Z","messageCount":2,"participants":["Éric Alber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"250995","messageId":"CAGDZK6HVevTPXVcwhHvmwdv9LZKzcv-3j-tBNV60tvhMuMhKtQ@mail.gmail.com","threadId":"37789","inReplyTo":null,"subject":"[BUG] Possible issue with word-diff option","fromName":"Éric Alber","fromEmail":"eric.alber@gmail.com","sentAt":"2014-10-23T18:54:15Z","receivedAt":"2014-10-23T18:54:15Z","isPatch":false,"sender":{"key":"eric.alber@gmail.com","avatar":null},"body":"Hi,\n\nI'm currently developing a local web based GUI for git in the same\nfashion as mercurial's 'hg serve': git-webui\n(https://github.com/alberthier/git-webui)\nI tried to add word-diff highlighting in my diff visualization panels.\nI used the '--word-diff=porcelain' option of 'git show' and 'git\ndiff'.\n\nUnfortunately I ran into an issue so I want to make sure I understand\nproperly the format\nHere is how I interpret this output:\n- A line of the diff no longer corresponds to a line in the source\nfile. A line of the source file, is represented between two leading\n'~' markers\n- A line starting with a '+' or '-' is respectively an added or\nremoved line fragment\n- A line starting with a ' ' (space) is an unchanged line fragment\n\nThe problem is visible with the git-webui repository itself:\n\ngit clone https://github.com/alberthier/git-webui\ngit show --word-diff=porcelain ed934a7            # This is the head\nof the 'word-diff' branch\n# search for the first occurrence of 'fragment'\n\nIn the source code, several lines have been replaced with the\nfollowing single line:\n\n         var fragment = line.substr(1);\n\nBut in the diff, 'fragment' and 'line.substr(1);' don't apprear in the\nsame '~' block.\nI get:\n\n~\n         var\n-pre\n+fragment\n  =\n-$('<pre class=\"diff-view-line\">').appendTo(view)[0];\n~\n[ some removed lines....]\n~\n-        }\n+line.substr(1);\n~\n\nBy reading this output, it looks like 'var fragment = ' and\n'line.substr(1);' aren't on the same line.\nI would have expected:\n\n~\n         var\n-pre\n+fragment\n  =\n-$('<pre class=\"diff-view-line\">').appendTo(view)[0];\n+line.substr(1);\n~\n[ some removed lines....]\n\nIs there something I miss or is this a bug of git's word-diff algorithm ?\n\nRegards,\n\nEric\n"},{"id":"250999","messageId":"CAGDZK6ET+jG15FTCdg5GuxbBZS5Lt_gvnH1TitAtnH6-4KBOtA@mail.gmail.com","threadId":"37789","inReplyTo":"CAGDZK6HVevTPXVcwhHvmwdv9LZKzcv-3j-tBNV60tvhMuMhKtQ@mail.gmail.com","subject":"Re: [BUG] Possible issue with word-diff option","fromName":"Éric Alber","fromEmail":"eric.alber@gmail.com","sentAt":"2014-10-23T20:01:40Z","receivedAt":"2014-10-23T20:01:40Z","isPatch":false,"sender":{"key":"eric.alber@gmail.com","avatar":null},"body":"I forgot to mention the version :\nI tested with Ubuntu's git 1.9.1 and a 2.1.0 version I built myself\n\n2014-10-23 20:54 GMT+02:00 Éric Alber <eric.alber@gmail.com>:\n> Hi,\n>\n> I'm currently developing a local web based GUI for git in the same\n> fashion as mercurial's 'hg serve': git-webui\n> (https://github.com/alberthier/git-webui)\n> I tried to add word-diff highlighting in my diff visualization panels.\n> I used the '--word-diff=porcelain' option of 'git show' and 'git\n> diff'.\n>\n> Unfortunately I ran into an issue so I want to make sure I understand\n> properly the format\n> Here is how I interpret this output:\n> - A line of the diff no longer corresponds to a line in the source\n> file. A line of the source file, is represented between two leading\n> '~' markers\n> - A line starting with a '+' or '-' is respectively an added or\n> removed line fragment\n> - A line starting with a ' ' (space) is an unchanged line fragment\n>\n> The problem is visible with the git-webui repository itself:\n>\n> git clone https://github.com/alberthier/git-webui\n> git show --word-diff=porcelain ed934a7            # This is the head\n> of the 'word-diff' branch\n> # search for the first occurrence of 'fragment'\n>\n> In the source code, several lines have been replaced with the\n> following single line:\n>\n>          var fragment = line.substr(1);\n>\n> But in the diff, 'fragment' and 'line.substr(1);' don't apprear in the\n> same '~' block.\n> I get:\n>\n> ~\n>          var\n> -pre\n> +fragment\n>   =\n> -$('<pre class=\"diff-view-line\">').appendTo(view)[0];\n> ~\n> [ some removed lines....]\n> ~\n> -        }\n> +line.substr(1);\n> ~\n>\n> By reading this output, it looks like 'var fragment = ' and\n> 'line.substr(1);' aren't on the same line.\n> I would have expected:\n>\n> ~\n>          var\n> -pre\n> +fragment\n>   =\n> -$('<pre class=\"diff-view-line\">').appendTo(view)[0];\n> +line.substr(1);\n> ~\n> [ some removed lines....]\n>\n> Is there something I miss or is this a bug of git's word-diff algorithm ?\n>\n> Regards,\n>\n> Eric\n"}]}