git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: Pure renames/copies
Date: Mon, 21 Nov 2005 14:10:23 -0800	[thread overview]
Message-ID: <438245CF.9030501@zytor.com> (raw)
In-Reply-To: <7vd5ktoe52.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

Junio C Hamano wrote:
> "H. Peter Anvin" <hpa@zytor.com> writes:
> 
> 
>>Okay, in that post Linus suggests that -M without an argument should be 
>>== 100% (1.0), thus avoiding having to mess up the meaning of -M100 as 
>>0.100.  It seems like a really odd thing to have -M100 mean something 
>>that's completely out of line with the rest of the meaning.
> 
> True, but it might be too late to change that; I suspect people
> expect -M to do a bit more than pure renames by now.
> 

Okay, how about the following?  It lets both -M1.0 and -M100% work, 
while keeping everything else compatible, and avoiding artificial 
special cases.

	-hpa

[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 932 bytes --]

diff --git a/diff.c b/diff.c
index 0391e8c..df62d2b 100644
--- a/diff.c
+++ b/diff.c
@@ -843,11 +843,19 @@ static int parse_num(const char **cp_p)
 
 	cnt = num = 0;
 	scale = 1;
-	while ('0' <= (ch = *cp) && ch <= '9') {
-		if (cnt++ < 5) {
-			/* We simply ignore more than 5 digits precision. */
-			scale *= 10;
-			num = num * 10 + ch - '0';
+	for(;;) {
+		ch = *cp;
+		if ( ch == '.' ) {
+			scale = 1;
+		} else if ( ch == '%' ) {
+			scale = 100;
+		} else if ( ch >= '0' && ch <= '9' ) {
+			if ( scale < 100000 ) {
+				scale *= 10;
+				num = (num*10) + (ch-'0');
+			}
+		} else {
+			break;
 		}
 		cp++;
 	}
@@ -856,7 +864,7 @@ static int parse_num(const char **cp_p)
 	/* user says num divided by scale and we say internally that
 	 * is MAX_SCORE * num / scale.
 	 */
-	return (MAX_SCORE * num / scale);
+	return (num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale);
 }
 
 int diff_scoreopt_parse(const char *opt)

  reply	other threads:[~2005-11-21 22:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-21 12:01 Pure renames/copies Santi Béjar
2005-11-21 18:37 ` Linus Torvalds
2005-11-21 19:31   ` Junio C Hamano
2005-11-21 19:50   ` Junio C Hamano
2005-11-21 21:01     ` H. Peter Anvin
2005-11-21 21:33       ` Junio C Hamano
2005-11-21 21:37         ` H. Peter Anvin
2005-11-21 22:00           ` Junio C Hamano
2005-11-21 22:10             ` H. Peter Anvin [this message]
2005-11-21 22:17               ` H. Peter Anvin
2005-11-22  9:03     ` Santi Bejar

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=438245CF.9030501@zytor.com \
    --to=hpa@zytor.com \
    --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).