From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <junkio@cox.net>, David Kastrup <dak@gnu.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] diff: round down similarity index
Date: Mon, 25 Jun 2007 03:29:27 +0200 [thread overview]
Message-ID: <467F1A77.3030209@lsrfire.ath.cx> (raw)
In-Reply-To: <Pine.LNX.4.64.0706250026400.4059@racer.site>
Johannes Schindelin schrieb:
> Hi,
>
> On Mon, 25 Jun 2007, Johannes Schindelin wrote:
>
>> On Mon, 25 Jun 2007, Ren� Scharfe wrote:
>>
>>> Rounding down the printed (dis)similarity index allows us to use
>>> "100%" as a special value that indicates complete rewrites and
>>> fully equal file contents, respectively.
>>>
>>> [...]
>>>
>>> +static int similarity_index(struct diff_filepair *p)
>>> +{
>>> + int result = p->score * 100.0 / MAX_SCORE;
>>> +
>>> + /* Paranoia: guard against floating point rounding errors. */
>>> + if (p->score == MAX_SCORE)
>>> + result = 100;
>>> + else if (result == 100)
>>> + result = 99;
>>> +
>>> + return result;
>>> +}
>> Besides, AFAIR p->score is not even calculated if the files are identical,
>> because that hits a different code path.
True, ->score is set to MAX_SCORE for identical files by a different
code path than the one that actually compares the contents and
calculates a score. That doesn't matter for printing the "similarity
index nn%" line etc., though. Or is there a way for identical files to
end up with a ->score of 0 (or some other value != MAX_SCORE) that I missed?
In any case, the patch doesn't change the way the score is calculated,
i.e. its value is the same as before. It only changes how it is displayed.
René
next prev parent reply other threads:[~2007-06-25 1:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-24 22:23 [PATCH] diff: round down similarity index René Scharfe
2007-06-24 23:25 ` Johannes Schindelin
2007-06-24 23:27 ` Johannes Schindelin
2007-06-25 1:29 ` René Scharfe [this message]
2007-06-25 5:08 ` David Kastrup
2007-06-25 6:18 ` Junio C Hamano
[not found] ` <86k5tsh761.fsf@lola.quinscape.zz>
2007-06-25 10:34 ` René Scharfe
2007-06-25 10:34 ` [PATCH] diff: round down similarity index, take 2 René Scharfe
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=467F1A77.3030209@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=Johannes.Schindelin@gmx.de \
--cc=dak@gnu.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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 NNTP newsgroup(s).