Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Display percentage similarity for renamed and copied files #406

Open
dandavison opened this issue Nov 23, 2020 · 6 comments
Open

🚀 Display percentage similarity for renamed and copied files #406

dandavison opened this issue Nov 23, 2020 · 6 comments

Comments

@dandavison
Copy link
Owner

See #392. cc @phil-blain

#392 (comment)

I did not think of it on Friday, but delta would be even more excellent if the similarity index (in percent) was indicated in parenthesis on the header line, for both renamed and copied files, something like this:

$ GIT_PAGER=../delta/target/release/delta git diff --cached -C -C

copied: first_file ⟶   copied_file (100%)
─────────────────────────────────────────────────────────────────
@WhyNotHugo
Copy link

This currently gets swallowed for files that have been moved, making them very hard to miss from diffs.

For example, here, at a glance, it seems that there's only a single change on-screen:

image

The raw output does include a reference though:

> git --no-pager log -p 49352587a29cb1130d963ade600e64810d596544 | less
commit 49352587a29cb1130d963ade600e64810d596544
Author: somini <[email protected]>
Date:   Mon Dec 27 12:19:58 2021 +0000

    Move icon to the app_id location
    
    This is so that the desktop files picks it up correctly.

diff --git a/resources/meson.build b/resources/meson.build
index 3e5c97a..7c99454 100644
--- a/resources/meson.build
+++ b/resources/meson.build
@@ -15,7 +15,7 @@ resources = gnome.compile_resources(
 
 scour = find_program('scour', required: false)
 
-icon = 'wdisplays.svg'
+icon = 'network.cycles.wdisplays.svg'
 icondir = get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps'
 
 if scour.found()
diff --git a/resources/wdisplays.svg b/resources/network.cycles.wdisplays.svg
similarity index 100%
rename from resources/wdisplays.svg
rename to resources/network.cycles.wdisplays.svg

commit a9aa7472e37a44b1aaa962d3794f68553e9f81fe
Merge: 5c6568a cfc8339
Author: Arti Zirk <[email protected]>
Date:   Mon Mar 29 11:33:43 2021 +0300

    Merge remote-tracking branch 'IntinteDAO/patch-1'

commit 5c6568a5b066e86d79a55f1d5334b2096a42715c
Merge: dd7e1e2 5198a9c
Author: Arti Zirk <[email protected]>
Date:   Mon Mar 29 11:30:31 2021 +0300

    Merge remote-tracking branch 'emersion/fix-global-version'

commit 5198a9c94b40ff157c284df413be5402f1b75118
Author: Simon Ser <[email protected]>
Date:   Wed Jul 8 11:57:35 2020 +0200

    Use correct versions when binding globals
    
    Changes to protocols aren't forward-compatible. It's not possible to use

Passing similarity index 100% in regular text colour would stand out enough, IMHO.

@dandavison
Copy link
Owner Author

I have to admit I'm not quite seeing the value -- but I'm sure it's me being dense/lazy since someone has gone to the trouble of adding the feature to git! If it's 100% then there's no diff to show, so I'm not sure what value there is in showing the 100% here: copied: first_file ⟶ copied_file (100%).

And if it's <100% then there's a diff, so that will be highly visible.

Would someone mind explaining how this feature is used?

@WhyNotHugo
Copy link

WhyNotHugo commented Oct 8, 2022 via email

@mentalisttraceur
Copy link

It's nice for false positives: delete one file, write another file, have Git show it as a rename+diff, get confused ("why does git think this is a move?! did I do something wrong? ..."), notice "51% similar" ("on that's why. well, okay then I guess").

@mentalisttraceur
Copy link

Note that git allows us to change the similarity threshold when looking at logs/diffs, so knowing the degree of similarity of existing matches can help us know what to set that parameter to if we want to adjust what it dispays as a rename, etc.

@mentalisttraceur
Copy link

Oh, big reason! We don't always see the diff with a rename.

Sometimes people use git diff/git log format options which shows the file summaries (modified, added, renamed, etc) but not the hunks.

I personally have done this with git log several times in my life (I can't remember exactly why anymore, probably to get a birds eye view of how a code base evolved, but I do remember going out of my way to look up how to do it at least twice over the years).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants