From: John Keeping Date: Tue, 02 Apr 2013 19:50:31 GMT Subject: [PATCH 1/2] diffcore-break: don't divide by zero Message-ID: In-Reply-To: When the source file is empty, the calculation of the merge score results in a division by zero. Since the merge score is initialized to zero, it makes sense to just leave it as it is if the source size is zero. This means that we still use the extent of damage metric to decide whether to break the filepair. Signed-off-by: John Keeping --- diffcore-break.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diffcore-break.c b/diffcore-break.c index 44f8678..37d8d05 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -90,7 +90,8 @@ static int should_break(struct diff_filespec *src, * merge the surviving pair together if the score is * less than the minimum, after rename/copy runs. */ - *merge_score_p = (int)(src_removed * MAX_SCORE / src->size); + if (src->size) + *merge_score_p = (int)(src_removed * MAX_SCORE / src->size); if (*merge_score_p > break_score) return 1; -- 1.8.2.540.gf023cfe