From 66913284f06da58e2243acfad951a57501b8d813 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 24 Apr 2009 17:46:15 -0400 Subject: progress bar: round to the nearest instead of truncating down Often the throughput output is requested when the data read so far is one smaller than multiple of 1024; because 1023/1024 is ~0.999, it often shows up as 0.99 because the code currently truncates. Signed-off-by: Junio C Hamano --- progress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'progress.c') diff --git a/progress.c b/progress.c index 55a8687ad1..621c34edc2 100644 --- a/progress.c +++ b/progress.c @@ -121,13 +121,13 @@ static void throughput_string(struct throughput *tp, off_t total, (int)(total >> 30), (int)(total & ((1 << 30) - 1)) / 10737419); } else if (total > 1 << 20) { + int x = total + 5243; /* for rounding */ l -= snprintf(tp->display, l, ", %u.%2.2u MiB", - (int)(total >> 20), - ((int)(total & ((1 << 20) - 1)) * 100) >> 20); + x >> 20, ((x & ((1 << 20) - 1)) * 100) >> 20); } else if (total > 1 << 10) { + int x = total + 5; /* for rounding */ l -= snprintf(tp->display, l, ", %u.%2.2u KiB", - (int)(total >> 10), - ((int)(total & ((1 << 10) - 1)) * 100) >> 10); + x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10); } else { l -= snprintf(tp->display, l, ", %u bytes", (int)total); } -- cgit v1.3 From 03aa8ff3be3b35522b2e378651e65e0e86778018 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 14 Sep 2009 02:41:16 -0400 Subject: Nicolas Pitre has a new email address Due to problems at cam.org, my nico@cam.org email address is no longer valid. From now on, nico@fluxnic.net should be used instead. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- .mailmap | 1 + diff-delta.c | 2 +- git.spec.in | 2 +- patch-delta.c | 2 +- progress.c | 2 +- test-delta.c | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) (limited to 'progress.c') diff --git a/.mailmap b/.mailmap index 373476bdc0..975e6758ef 100644 --- a/.mailmap +++ b/.mailmap @@ -41,6 +41,7 @@ Michele Ballabio Nanako Shiraishi Nanako Shiraishi Nguyễn Thái Ngọc Duy + Philippe Bruhat Ramsay Allan Jones René Scharfe diff --git a/diff-delta.c b/diff-delta.c index a4e28df714..464ac3ffc0 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -4,7 +4,7 @@ * This code was greatly inspired by parts of LibXDiff from Davide Libenzi * http://www.xmailserver.org/xdiff-lib.html * - * Rewritten for GIT by Nicolas Pitre , (C) 2005-2007 + * Rewritten for GIT by Nicolas Pitre , (C) 2005-2007 * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/git.spec.in b/git.spec.in index 4be0834f0b..ab224f7eae 100644 --- a/git.spec.in +++ b/git.spec.in @@ -233,7 +233,7 @@ rm -rf $RPM_BUILD_ROOT * Tue Mar 27 2007 Eygene Ryabinkin - Added the git-p4 package: Perforce import stuff. -* Mon Feb 13 2007 Nicolas Pitre +* Mon Feb 13 2007 Nicolas Pitre - Update core package description (Git isn't as stupid as it used to be) * Mon Feb 12 2007 Junio C Hamano diff --git a/patch-delta.c b/patch-delta.c index ef748ce96d..e02e13bd4e 100644 --- a/patch-delta.c +++ b/patch-delta.c @@ -2,7 +2,7 @@ * patch-delta.c: * recreate a buffer from a source and the delta produced by diff-delta.c * - * (C) 2005 Nicolas Pitre + * (C) 2005 Nicolas Pitre * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/progress.c b/progress.c index 621c34edc2..132ed95a3d 100644 --- a/progress.c +++ b/progress.c @@ -1,7 +1,7 @@ /* * Simple text-based progress display module for GIT * - * Copyright (c) 2007 by Nicolas Pitre + * Copyright (c) 2007 by Nicolas Pitre * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/test-delta.c b/test-delta.c index 3d885ff37e..af40a3c49e 100644 --- a/test-delta.c +++ b/test-delta.c @@ -1,7 +1,7 @@ /* * test-delta.c: test code to exercise diff-delta.c and patch-delta.c * - * (C) 2005 Nicolas Pitre + * (C) 2005 Nicolas Pitre * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as -- cgit v1.3 From 583371af1f88e9cd48fedbb6bbb147d8091fd591 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Tue, 13 Oct 2009 23:02:04 -0400 Subject: change throughput display units with fast links Switch to MiB/s when the connection is fast enough (i.e. on a LAN). Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- progress.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'progress.c') diff --git a/progress.c b/progress.c index 132ed95a3d..3971f49f4d 100644 --- a/progress.c +++ b/progress.c @@ -131,7 +131,13 @@ static void throughput_string(struct throughput *tp, off_t total, } else { l -= snprintf(tp->display, l, ", %u bytes", (int)total); } - if (rate) + + if (rate > 1 << 10) { + int x = rate + 5; /* for rounding */ + snprintf(tp->display + sizeof(tp->display) - l, l, + " | %u.%2.2u MiB/s", + x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10); + } else if (rate) snprintf(tp->display + sizeof(tp->display) - l, l, " | %u KiB/s", rate); } -- cgit v1.3