From: Mike Hommey <mh@glandium.org>
To: git@vger.kernel.org
Subject: similarity index vs. whitespaces
Date: Thu, 13 Apr 2023 10:56:40 +0900 [thread overview]
Message-ID: <20230413015640.h6npzp47tnob7bq2@glandium.org> (raw)
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 reply other threads:[~2023-04-13 1:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 1:56 Mike Hommey [this message]
2023-04-13 2:35 ` similarity index vs. whitespaces Chris Torek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230413015640.h6npzp47tnob7bq2@glandium.org \
--to=mh@glandium.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).