Skip to contentSkip to conversation

diff: Fixes shortstat number of files

PATCH New Antoine Pelisse 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diff: Fixes shortstat number of files

There is a discrepancy between the last line of git diff --stat and git diff --shortstat in case of a merge.
The unmerged files are actually counted twice, thus doubling the value of "file changed".

In fact, while stat decrements number of files when seeing an unmerged file, shortstat doesn't.

---
 diff.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff.c +2 -3
index e89a201..5c6bcbd 100644
@@ -1704,9 +1704,8 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option
 		int added = data->files[i]->added;
 		int deleted= data->files[i]->deleted;
 
-		if (data->files[i]->is_unmerged)
-			continue;
-		if (!data->files[i]->is_renamed && (added + deleted == 0)) {
+		if (data->files[i]->is_unmerged ||
+		  (!data->files[i]->is_renamed && (added + deleted == 0))) {
 			total_files--;
 		} else if (!data->files[i]->is_binary) { /* don't count bytes */
 			adds += added;
Signature · 1 line
1.7.9.5