{"thread":{"id":"45294","subject":"difflame improvements","startedAt":"2017-03-05T16:19:01Z","lastAt":"2017-03-05T16:19:01Z","messageCount":1,"participants":["Edmundo Carmona Antoranz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"313297","messageId":"CAOc6etbwE3wyVEUKJq8WCPe=hYBobWo-RtDonH46XCHF157+BQ@mail.gmail.com","threadId":"45294","inReplyTo":null,"subject":"difflame improvements","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2017-03-05T16:18:54Z","receivedAt":"2017-03-05T16:19:01Z","isPatch":false,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Hi!\n\nSince my last post the biggest improvement is the ability to detect\nthat the user has requested a \"reverse\" analysis.\n\nUnder \"normal\" circumstances a user would ask difflame to get the diff\nfrom an ancestor (call \"difflame treeish1 treeish2\" so that merge-base\nof treeish1 treeish2 equals treeish1). In this case the blame result\nis done using straight blame output for added lines and additional\nanalysis to detect where a line was deleted (analysis has improved a\nlot in this regard.... I haven't heard anything from Peff, though).\nBut if the user requests the opposite (call \"difflame treeish1\ntreeish2\" so that merge-base of treeish1 treeish2 is treeish2) then\nthe analysis has to be driven \"in reverse\".\n\nHere's one example taken from difflame itself:\n\nnormal \"forward\" call (hope output doesn't get butchered):\n\n$ ./difflame.py HEAD~3 HEAD~2\ndiff --git a/difflame.py b/difflame.py\nindex e70154a..04c7577 100755\n--- a/difflame.py\n+++ b/difflame.py\n@@ -365,7 +365,7 @@ def get_full_revision_id(revision):\n e5b218e4 (Edmundo 2017-02-01 365)         # we already had the revision\n 50528377 (Edmundo 2017-03-04 366)         return REVISIONS_ID_CACHE[revision]\n d1d11d8a (Edmundo 2017-02-02 367)     # fallback to get it from git\n       b1a6693 use rev-list to get revision IDs\n-b1a6693 (Edmundo 2017-03-04 368)     full_revision =\nrun_git_command([\"show\", \"--pretty=%H\", revision]).split(\"\\n\")[0]\n+b1a66932 (Edmundo 2017-03-04 368)     full_revision =\nrun_git_command([\"rev-list\", \"--max-count=1\",\nrevision]).split(\"\\n\")[0]\n 50528377 (Edmundo 2017-03-04 369)     REVISIONS_ID_CACHE[revision] =\nfull_revision\n e5b218e4 (Edmundo 2017-02-01 370)     return full_revision\n 91b7d3f5 (Edmundo 2017-01-31 371)\n\n\"reverse\" call:\n$ ./difflame.py HEAD~2 HEAD~3\ndiff --git a/difflame.py b/difflame.py\nindex 04c7577..e70154a 100755\n--- a/difflame.py\n+++ b/difflame.py\n@@ -365,7 +365,7 @@ def get_full_revision_id(revision):\n e5b218e4 (Edmundo 2017-02-01 365)         # we already had the revision\n 50528377 (Edmundo 2017-03-04 366)         return REVISIONS_ID_CACHE[revision]\n d1d11d8a (Edmundo 2017-02-02 367)     # fallback to get it from git\n       b1a6693 use rev-list to get revision IDs\n-b1a66932 (Edmundo 2017-03-04 368)     full_revision =\nrun_git_command([\"rev-list\", \"--max-count=1\",\nrevision]).split(\"\\n\")[0]\n+b1a6693 (Edmundo 2017-03-04 368)     full_revision =\nrun_git_command([\"show\", \"--pretty=%H\", revision]).split(\"\\n\")[0]\n 50528377 (Edmundo 2017-03-04 369)     REVISIONS_ID_CACHE[revision] =\nfull_revision\n e5b218e4 (Edmundo 2017-02-01 370)     return full_revision\n 91b7d3f5 (Edmundo 2017-01-31 371)\n\nNotice how the revision reported in both difflame calls is the same:\n\n$ git show b1a66932\ncommit b1a66932704245fd653f8d48c0a718f168f334a7\nAuthor: Edmundo Carmona Antoranz <whocares@gmail.com>\nDate:   Sat Mar 4 13:59:50 2017 -0600\n\n   use rev-list to get revision IDs\n\ndiff --git a/difflame.py b/difflame.py\nindex e70154a..04c7577 100755\n--- a/difflame.py\n+++ b/difflame.py\n@@ -365,7 +365,7 @@ def get_full_revision_id(revision):\n        # we already had the revision\n        return REVISIONS_ID_CACHE[revision]\n    # fallback to get it from git\n-    full_revision = run_git_command([\"show\", \"--pretty=%H\",\nrevision]).split(\"\\n\")[0]\n+    full_revision = run_git_command([\"rev-list\", \"--max-count=1\",\nrevision]).split(\"\\n\")[0]\n    REVISIONS_ID_CACHE[revision] = full_revision\n    return full_revision\n\n\nIf this \"detection\" to perform reverse analysis hadn't been done, then\nthere wouldn't be a lot of useful information because there are no\nrevisions in HEAD~2..HEAD~3 and so the output would have been\nsomething like:\n\ndiff --git a/difflame.py b/difflame.py\nindex 04c7577..e70154a 100755\n--- a/difflame.py\n+++ b/difflame.py\n@@ -365,7 +365,7 @@ def get_full_revision_id(revision):\n e5b218e4 (Edmundo 2017-02-01 365)         # we already had the revision\n 50528377 (Edmundo 2017-03-04 366)         return REVISIONS_ID_CACHE[revision]\n d1d11d8a (Edmundo 2017-02-02 367)     # fallback to get it from git\n       b1a6693 use rev-list to get revision IDs\n%b1a6693 (Edmundo 2017-03-04 368)     full_revision =\nrun_git_command([\"rev-list\", \"--max-count=1\",\nrevision]).split(\"\\n\")[0]\n       e5b218e printing hints for deleted lines\n+e5b218e4 (Edmundo 2017-02-01 368)     full_revision =\nrun_git_command([\"show\", \"--pretty=%H\", revision]).split(\"\\n\")[0]\n 50528377 (Edmundo 2017-03-04 369)     REVISIONS_ID_CACHE[revision] =\nfull_revision\n e5b218e4 (Edmundo 2017-02-01 370)     return full_revision\n 91b7d3f5 (Edmundo 2017-01-31 371)\n\nNotice how both the added line and the deleted line are reporting the\n_wrong_ revision. It should be b1a66932 in all cases.\n\n\nOne question that has been bugging me for a while is what to do in\ncases where treeish1, treeish2 are not \"direct\" descendants\" (as in\nmerge-base treeish1 treeish2 is something other than treeish1 or\ntreeish2). Suppose a line was added on an ancestor of treeish1 but it\nhasn't been merged into treeish2. In this case if we diff\ntreeish1..treeish2 we will get a _deleted_ line. However analysis to\nfind a deleting revision in treeish1..treeish2 will fail. I'm\nwondering if it would be ok in this case to blame the deleted line on\nthe ancestor if treeish1 where the line was _added_.\n\nAnother thing I added is the support to use tags.\n\nBest regards!\n"}]}