{"id":76,"date":"2005-12-29T18:14:12","date_gmt":"2005-12-30T01:14:12","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/?p=76"},"modified":"2005-12-29T18:16:05","modified_gmt":"2005-12-30T01:16:05","slug":"death-diffying-moves","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/76\/death-diffying-moves","title":{"rendered":"Death-Diffying Moves"},"content":{"rendered":"<p>One of the aspects of being a professional software developer that is a <em>real grind<\/em> is the tedious, careful double-checking we must do in order to reduce the odds that our work will lead to some major metropolitan area bursting into flames.<\/p>\n<p>\nDouble-checking means diffing.\n<\/p>\n<p>\nDiffing is hard. Even with somewhat friendly tools at our disposal, it&#8217;s a tedious, annoying pain in the butt. It doesn&#8217;t help that diff tools don&#8217;t seem to have improved much in the past 10 years, and are still obnoxiously finicky when it comes to issues like line-endings, encodings, etc.\n<\/p>\n<p>\nBut the worst part of diff tasks, as with most things, is simply getting started. I am particularly averse to working on things that are hard to start. While diffing from Xcode can be really easy just hit a keyboard shortcut to see a comparison with the last checked-in copy, for instance), diffing arbitrary files in the Finder usually follows a pattern more like this:\n<\/p>\n<ol>\n<li>Launch a diff-comparison tool like <a href=\"http:\/\/www.barebones.com\/products\/bbedit\/index.shtml\">BBEdit<\/a> or <a href=\"file:\/\/\/Developer\/Applications\/Utilities\/FileMerge.app\">FileMerge<\/a>.<\/li>\n<li>Navigate to File A in the Finder. Drag it to the diff-tool.<\/li>\n<li>Navigate to File B in the Finder. Drag it to the diff-tool.<\/li>\n<li>Tell the diff-tool you&#8217;re ready to compare!<\/li>\n<\/ol>\n<p>Well, that&#8217;s too many steps for me. So I wrote an AppleScript to apply some rather straightforward logic to the selected items in the Finder, and open your favorite diff-tool for you with the comparison process started. The logic of the script is simple enough:\n<\/p>\n<ol>\n<li>Are there two items selected in front window? Compare them.<\/li>\n<li>Is there exactly one item selected in the front window and one item selected in the second-to-front window? Compare them.<\/li>\n<\/ol>\n<p>\nHere, &#8220;compare them&#8221; means pull an Xcode-like move and launch the &#8220;diff opener tool&#8221; of your choice. I&#8217;ve included in the script the paths to two &#8220;secret tools&#8221; used by Xcode for opening with BBEdit and FileMerge. If you want to use a different tool you&#8217;ll have to find a way of invoking it directly with two full paths, or write a helper tool that can do the trick for you.\n<\/p>\n<p>\nThis simple script makes a great Cmd-Opt-C shortcut in the Finder. It&#8217;s the same shortcut I use for &#8220;compare with latest&#8221; in Xcode. Now when I see two files in the Finder that I want to compare, I just select them both and trigger the script. Wham!\n<\/p>\n<p>\nFeel free to download the script: <a href=\"http:\/\/www.red-sweater.com\/AppleScript\/CompareFiles.zip\">Compare Files<\/a>. Let me know if you have any suggestions for improving it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the aspects of being a professional software developer that is a real grind is the tedious, careful double-checking we must do in order to reduce the odds that our work will lead to some major metropolitan area bursting into flames. Double-checking means diffing. Diffing is hard. Even with somewhat friendly tools at our [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6,12,5],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-applescript","category-fastscripts","category-usability","category-xcode"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}