git/list[1] front-page[2] threads[3] people[4] search[5] about
 

difflame improvements

From
Edmundo Carmona Antoranz <eantoranz@gmail.com>
Date
Feb 15, 2017, 05:19 UTC
Message-ID
<CAOc6etYz6+FzDRbkLS2SB9=F9DP18=6uLKdfCN3D3yd2Gug-tw@mail.gmail.com>
Hi!

I've been working on detecting revisions where a "real" deletion was made and I think I advanced a lot in that front. I still have to work on many scenarios (renamed files, for example... also performance) but at least I'm using a few runs against git-scm history and the results are "promising":

23:05 $ git blame -s --reverse -L 25,40 HEAD~20..HEAD -- versioncmp.c 066fb0494e 25) static int initialized; 066fb0494e 26) 066fb0494e 27) /* 8ec68d1ae2 28) * p1 and p2 point to the first different character in two strings. If 8ec68d1ae2 29) * either p1 or p2 starts with a prerelease suffix, it will be forced 8ec68d1ae2 30) * to be on top. 8ec68d1ae2 31) * 8ec68d1ae2 32) * If both p1 and p2 start with (different) suffix, the order is 8ec68d1ae2 33) * determined by config file. 066fb0494e 34) * 8ec68d1ae2 35) * Note that we don't have to deal with the situation when both p1 and 8ec68d1ae2 36) * p2 start with the same suffix because the common part is already 8ec68d1ae2 37) * consumed by the caller. 066fb0494e 38) * 066fb0494e 39) * Return non-zero if *diff contains the return value for versioncmp() 066fb0494e 40) */

Lines 28-33:
23:05 $ git show --summary 8ec68d1ae2
commit 8ec68d1ae2863823b74d67c5e92297e38bbf97bc
Merge: e801be066 c48886779
Author: Junio C Hamano <>
Date:   Mon Jan 23 15:59:21 2017 -0800
    Merge branch 'vn/diff-ihc-config'
    "git diff" learned diff.interHunkContext configuration variable
    that gives the default value for its --inter-hunk-context option.
    * vn/diff-ihc-config:
      diff: add interhunk context config option

And this is not telling me the _real_ revision where the lines were _deleted_ so it's not very helpful, as Peff has already mentioned.

Running difflame:

23:06 $ time ~/proyectos/git/difflame/difflame.py -bp=-s -w HEAD~20 HEAD -- versioncmp.c

diff --git a/versioncmp.c b/versioncmp.c
index 80bfd109f..9f81dc106 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -24,42 +24,83 @@
.
.
.
+b17846432d  33) static void find_better_matching_suffix(const char
*tagname, const char *suffix,
+b17846432d  34)                                        int
suffix_len, int start, int conf_pos,
+b17846432d  35)                                        struct
suffix_match *match)
+b17846432d  36) {
b17846432d  37)        /*
       c026557a3 versioncmp: generalize version sort suffix reordering
-c026557a3 (SZEDER 28)  * p1 and p2 point to the first different
character in two strings. If
-c026557a3 (SZEDER 29)  * either p1 or p2 starts with a prerelease
suffix, it will be forced
-c026557a3 (SZEDER 30)  * to be on top.
-c026557a3 (SZEDER 31)  *
-c026557a3 (SZEDER 32)  * If both p1 and p2 start with (different)
suffix, the order is
-c026557a3 (SZEDER 33)  * determined by config file.
       b17846432 versioncmp: factor out helper for suffix matching
+b17846432d  38)         * A better match either starts earlier or
starts at the same offset
+b17846432d  39)         * but is longer.
+b17846432d  40)         */
+b17846432d  41)        int end = match->len < suffix_len ?
match->start : match->start-1;
.
.
.

Same range of (deleted) lines:

23:10 $ git --show --name-status c026557a3
commit c026557a37361b7019acca28f240a19f546739e9
Author: SZEDER Gábor <>
Date:   Thu Dec 8 15:24:01 2016 +0100

   versioncmp: generalize version sort suffix reordering

   The 'versionsort.prereleaseSuffix' configuration variable, as its name
   suggests, is supposed to only deal with tagnames with prerelease
.
.
.


   Signed-off-by: SZEDER Gábor <>
   Signed-off-by: Junio C Hamano <>

M       Documentation/config.txt
M       Documentation/git-tag.txt
M       t/t7004-tag.sh
M       versioncmp.c


This is the revision where the deletion happened.

That's it for the time being.
Next: Jeff King
Message 1 of 4 in “difflame improvements”
  1. Edmundo Carmona AntoranzFeb 15, 2017
  2. Jeff KingFeb 17, 2017
  3. Edmundo Carmona AntoranzFeb 17, 2017
  4. Edmundo Carmona AntoranzFeb 19, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.