From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Herland Subject: [PATCHv5 2/7] Make --dirstat=0 output directories that contribute < 0.1% of changes Date: Thu, 28 Apr 2011 03:17:17 +0200 Message-ID: <1303953442-26536-3-git-send-email-johan@herland.net> References: <1303892653-3958-1-git-send-email-johan@herland.net> <1303953442-26536-1-git-send-email-johan@herland.net> Mime-Version: 1.0 Content-Type: TEXT/PLAIN Content-Transfer-Encoding: 7BIT Cc: Junio C Hamano , Linus Torvalds , Johan Herland To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Apr 28 03:17:36 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QFFrL-00051R-KP for gcvg-git-2@lo.gmane.org; Thu, 28 Apr 2011 03:17:35 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757908Ab1D1BRa (ORCPT ); Wed, 27 Apr 2011 21:17:30 -0400 Received: from smtp.getmail.no ([84.208.15.66]:46644 "EHLO smtp.getmail.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756149Ab1D1BR2 (ORCPT ); Wed, 27 Apr 2011 21:17:28 -0400 Received: from get-mta-scan02.get.basefarm.net ([10.5.16.4]) by get-mta-out02.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0LKC00GMX8X1P940@get-mta-out02.get.basefarm.net> for git@vger.kernel.org; Thu, 28 Apr 2011 03:17:25 +0200 (MEST) Received: from get-mta-scan02.get.basefarm.net (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id 9D33D1EA58D6_DB8C025B for ; Thu, 28 Apr 2011 01:17:25 +0000 (GMT) Received: from smtp.getmail.no (unknown [10.5.16.4]) by get-mta-scan02.get.basefarm.net (Sophos Email Appliance) with ESMTP id 4BD921EA38FD_DB8C025F for ; Thu, 28 Apr 2011 01:17:25 +0000 (GMT) Received: from alpha.herland ([84.215.68.234]) by get-mta-in02.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0LKC0058L8X0LO10@get-mta-in02.get.basefarm.net> for git@vger.kernel.org; Thu, 28 Apr 2011 03:17:25 +0200 (MEST) X-Mailer: git-send-email 1.7.5.rc1.3.g4d7b In-reply-to: <1303953442-26536-1-git-send-email-johan@herland.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: The expected output from --dirstat=0, is to include any directory with changes, even if those changes contribute a minuscule portion of the total changes. However, currently, directories that contribute less than 0.1% are not included, since their 'permille' value is 0, and there is an 'if (permille)' check in gather_dirstat() that causes them to be ignored. This test is obviously intended to exclude directories that contribute no changes whatsoever, but in this case, it hits too broadly. The correct check is against 'this_dir' from which the permille is calculated. Only if this value is 0 does the directory truly contribute no changes, and should be skipped from the output. This patches fixes this issue, and updates corresponding testcases to expect the new behvaior. Signed-off-by: Johan Herland --- diff.c | 4 ++-- t/t4047-diff-dirstat.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index abd9cd5..cfbfa92 100644 --- a/diff.c +++ b/diff.c @@ -1500,8 +1500,8 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir, * under this directory (sources == 1). */ if (baselen && sources != 1) { - int permille = this_dir * 1000 / changed; - if (permille) { + if (this_dir) { + int permille = this_dir * 1000 / changed; int percent = permille / 10; if (percent >= dir->percent) { fprintf(opt->file, "%s%4d.%01d%% %.*s\n", line_prefix, diff --git a/t/t4047-diff-dirstat.sh b/t/t4047-diff-dirstat.sh index eb6bf47..6ff7f9f 100755 --- a/t/t4047-diff-dirstat.sh +++ b/t/t4047-diff-dirstat.sh @@ -346,7 +346,6 @@ test_expect_success 'vanilla -X' ' test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC ' -# rearranged/text falls below 0% threshold (1 / (240 * 9 + 48 + 1) ~= 0.045 %) cat <expect_diff_dirstat 2.1% changed/ 10.8% dst/copy/changed/ @@ -355,6 +354,7 @@ cat <expect_diff_dirstat 10.8% dst/move/changed/ 10.8% dst/move/rearranged/ 10.8% dst/move/unchanged/ + 0.0% rearranged/ 10.8% src/move/changed/ 10.8% src/move/rearranged/ 10.8% src/move/unchanged/ @@ -397,7 +397,6 @@ test_expect_success '-X0' ' test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC ' -# rearranged/text falls below 0% threshold (1 / (240 * 9 + 48 + 1) ~= 0.045 %) cat <expect_diff_dirstat 2.1% changed/ 10.8% dst/copy/changed/ @@ -409,6 +408,7 @@ cat <expect_diff_dirstat 10.8% dst/move/unchanged/ 32.5% dst/move/ 65.1% dst/ + 0.0% rearranged/ 10.8% src/move/changed/ 10.8% src/move/rearranged/ 10.8% src/move/unchanged/ -- 1.7.5.rc1.3.g4d7b