{"id":722,"date":"2013-12-13T08:18:51","date_gmt":"2013-12-13T16:18:51","guid":{"rendered":"http:\/\/galencharlton.com\/blog\/?p=722"},"modified":"2013-12-13T08:18:51","modified_gmt":"2013-12-13T16:18:51","slug":"koha-dev-tidbit-2-pinpoint-the-difference","status":"publish","type":"post","link":"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/","title":{"rendered":"Koha Dev Tidbit #2: Pinpoint the difference"},"content":{"rendered":"<p>This morning I reviewed and pushed the patch for Koha <a href=\"http:\/\/bugs.koha-community.org\/bugzilla3\/show_bug.cgi?id=11174\">bug 11174<\/a>.  The patch, by Zeno Tajoli, removes one character each from two files.<\/p>\n<p>One character?  That should be easy to eyeball, right?<\/p>\n<p>Not quite &#8212; the character in question was part of a parameter name in a very long URL.  I don&#8217;t know about you, but it can take me a while to spot such a difference.<\/p>\n<p>Here is an example.  Can you spot the exact difference in less than 2 seconds?<\/p>\n<pre class=\"crayon:false\" style=\"background-color:lavender\">\r\n$ git diff --color\r\n\r\n<strong>diff --git a\/INSTALL b\/INSTALL\r\nindex ffe69ae..e92b1a3 100644\r\n--- a\/INSTALL\r\n+++ b\/INSTALL<\/strong>\r\n<span style=\"color:blue\">@@ -94,7 +94,7 @@<\/span> Use the packaged version or install from CPAN\r\n  sudo make upgrade\r\n \r\n Koha 3.4.x or later  no longer stores items in biblio records.\r\n<span style=\"color:red\">-If you are upgrading from an older version ou will need to do the<\/span>\r\n<span style=\"color:green\">+If you are upgrading from an older version you will need to do the<\/span>\r\n following two steps, they can take a long time (several hours) to\r\n complete for large databases\r\n<\/pre>\n<p>Now imagine doing this if the change occurs in the 100th character of a line that is 150 characters long.<\/p>\n<p>Fortunately, <code>git diff<\/code>, as well as other commands like <code>git show<\/code> that display diffs, accepts several switches that let you display the differences in terms of words, not lines.  These switches include <code>--word-diff<\/code> and <code>--color-words<\/code>.  For example:<\/p>\n<pre class=\"crayon:false\" style=\"background-color:lavender\">\r\n$ git diff --color-words\r\n\r\n<strong>diff --git a\/INSTALL b\/INSTALL\r\nindex ffe69ae..e92b1a3 100644\r\n--- a\/INSTALL\r\n+++ b\/INSTALL<\/strong>\r\n<span style=\"color:blue\">@@ -94,7 +94,7 @@<\/span> Use the packaged version or install from CPAN\r\n  sudo make upgrade\r\n \r\nKoha 3.4.x or later  no longer stores items in biblio records.\r\nIf you are upgrading from an older version <span style=\"color:red\">ou<\/span><span style=\"color:green\">you<\/span> will need to do the\r\nfollowing two steps, they can take a long time (several hours) to\r\ncomplete for large databases\r\n<\/pre>\n<p>The difference is much easier to see now &#8212; at least if you&#8217;re not red-green color-blind.  You can <a href=\"http:\/\/nathanhoad.net\/how-to-colours-in-git\" target=\"_blank\">change the colors<\/a> or not use colors at all:<\/p>\n<pre class=\"crayon:false\" style=\"background-color:lavender\">\r\n$ git diff --word-diff\r\n\r\ndiff --git a\/INSTALL b\/INSTALL\r\nindex ffe69ae..e92b1a3 100644\r\n--- a\/INSTALL\r\n+++ b\/INSTALL\r\n@@ -94,7 +94,7 @@ Use the packaged version or install from CPAN\r\n sudo make upgrade\r\n\r\nKoha 3.4.x or later  no longer stores items in biblio records.\r\nIf you are upgrading from an older version [-ou-]{+you+} will need to do the\r\nfollowing two steps, they can take a long time (several hours) to\r\ncomplete for large databases\r\n<\/pre>\n<p>Going back to the bug I mentioned, <code>--word-diff<\/code> wasn&#8217;t quite enough, though.  By default, Git considers words to be delimited by whitespace, but the patch in question removed a character from the middle of a very long URL.  To make the change pop out, I had to tell Git to highlight single-character changes.  One way to do this is the <code>--word-diff-regex<\/code> or by passing the regex to <code>--color-words.<\/code>  Here&#8217;s the final example:<\/p>\n<pre class=\"crayon:false\" style=\"background-color:lavender\">\r\n$ git diff --color-words=.\r\n\r\n<strong>diff --git a\/INSTALL b\/INSTALL\r\nindex ffe69ae..e92b1a3 100644\r\n--- a\/INSTALL\r\n+++ b\/INSTALL<\/strong>\r\n<span style=\"color:blue\">@@ -94,7 +94,7 @@<\/span> Use the packaged version or install from CPAN\r\n  sudo make upgrade\r\n \r\nKoha 3.4.x or later  no longer stores items in biblio records.\r\nIf you are upgrading from an older version <span style=\"color:green; font-weight:bold\">y<\/span>ou will need to do the\r\nfollowing two steps, they can take a long time (several hours) to\r\ncomplete for large databases\r\n<\/pre>\n<p>And there we have it &#8212; the difference, pinpointed.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-722\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>This morning I reviewed and pushed the patch for Koha bug 11174. The patch, by Zeno Tajoli, removes one character each from two files. One&#8230;<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-722\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/12\/koha-dev-tidbit-2-pinpoint-the-difference\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"Koha Dev Tidbit #2: Pinpoint the difference #kohails","jetpack_is_tweetstorm":false},"categories":[10,11],"tags":[49],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gJ9y-bE","_links":{"self":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/722"}],"collection":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":18,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":740,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/722\/revisions\/740"}],"wp:attachment":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}