return count;
}
-int git_diff_file_stats__full_to_buf(
+static int diff_file_stats_full_to_buf(
git_buf *out,
const git_diff_delta *delta,
const diff_file_stats *filestat,
const git_diff_stats *stats,
size_t width)
{
- const char *old_path = NULL, *new_path = NULL;
+ const char *old_path = NULL, *new_path = NULL, *adddel_path = NULL;
size_t padding;
- git_off_t old_size, new_size;
+ git_object_size_t old_size, new_size;
old_path = delta->old_file.path;
new_path = delta->new_file.path;
old_size = delta->old_file.size;
new_size = delta->new_file.size;
- if (strcmp(old_path, new_path) != 0) {
+ if (old_path && new_path && strcmp(old_path, new_path) != 0) {
size_t common_dirlen;
int error;
if (error < 0)
goto on_error;
} else {
- if (git_buf_printf(out, " %s", old_path) < 0)
+ adddel_path = new_path ? new_path : old_path;
+ if (git_buf_printf(out, " %s", adddel_path) < 0)
goto on_error;
- padding = stats->max_name - strlen(old_path);
+ padding = stats->max_name - strlen(adddel_path);
if (stats->renames > 0)
padding += strlen(DIFF_RENAME_FILE_SEPARATOR);
return (git_buf_oom(out) ? -1 : 0);
}
-int git_diff_file_stats__number_to_buf(
+static int diff_file_stats_number_to_buf(
git_buf *out,
const git_diff_delta *delta,
const diff_file_stats *filestats)
return error;
}
-int git_diff_file_stats__summary_to_buf(
+static int diff_file_stats_summary_to_buf(
git_buf *out,
const git_diff_delta *delta)
{
/* TODO ugh */
namelen = strlen(delta->new_file.path);
- if (strcmp(delta->old_file.path, delta->new_file.path) != 0) {
+ if (delta->old_file.path && strcmp(delta->old_file.path, delta->new_file.path) != 0) {
namelen += strlen(delta->old_file.path);
stats->renames++;
}
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__number_to_buf(
+ error = diff_file_stats_number_to_buf(
out, delta, &stats->filestats[i]);
if (error < 0)
return error;
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__full_to_buf(
+ error = diff_file_stats_full_to_buf(
out, delta, &stats->filestats[i], stats, width);
if (error < 0)
return error;
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__summary_to_buf(out, delta);
+ error = diff_file_stats_summary_to_buf(out, delta);
if (error < 0)
return error;
}