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

similarity index vs. whitespaces

From
Mike Hommey <mh@glandium.org>
Date
Apr 13, 2023, 01:56 UTC
Message-ID
<20230413015640.h6npzp47tnob7bq2@glandium.org>
Hi,

I hit an interesting case of copy-detection "failure" after renaming a python script and changing indentation in it at the same time: git show -C wouldn't detect it as a rename unless I lowered the similarity index significantly. But from a human perspective, the similarity index feels wrong.

Here's a small illustrative example: $ git init qux $ cd qux $ cat > qux <<EOF a b c d e f EOF $ git add qux $ git commit -a -m qux $ git mv qux hoge $ sed -i 's/[cde]/ \0/' hoge $ git commit -a -m hoge $ git diff -C HEAD^!

diff --git a/hoge b/hoge
new file mode 100644
index 0000000..9ab6fcc
--- /dev/null
+++ b/hoge
@@ -0,0 +1,6 @@
+a
+b
+  c
+  d
+  e
+f
diff --git a/qux b/qux
deleted file mode 100644
index 0fdf397..0000000
--- a/qux
+++ /dev/null
@@ -1,6 +0,0 @@
-a
-b
-c
-d
-e
-f

$ git diff -C10% HEAD^!
diff --git a/qux b/hoge
similarity index 33%
rename from qux
rename to hoge
index 0fdf397..9ab6fcc 100644
--- a/qux
+++ b/hoge
@@ -1,6 +1,6 @@
 a
 b
-c
-d
-e
+  c
+  d
+  e
 f

From a human perspective 33% similarity feels way too low here. I know
it's essentially counting lines in the diff, but that feels limited.

What do you think?

Mike
Next: Chris Torek
Message 1 of 2 in “similarity index vs. whitespaces”
  1. Mike HommeyApr 13, 2023
  2. Chris TorekApr 13, 2023

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.