vendor/libgit2/src/diff_generate.c in rugged-1.3.2.3 vs vendor/libgit2/src/diff_generate.c in rugged-1.4.2
- old
+ new
@@ -115,10 +115,30 @@
&diff->pathspec, entry->path, disable_pathspec_match,
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE),
matched_pathspec, NULL);
}
+static void diff_delta__flag_known_size(git_diff_file *file)
+{
+ /*
+ * If we don't know the ID, that can only come from the workdir
+ * iterator, which means we *do* know the file size. This is a
+ * leaky abstraction, but alas. Otherwise, we test against the
+ * empty blob id.
+ */
+ if (file->size ||
+ !(file->flags & GIT_DIFF_FLAG_VALID_ID) ||
+ git_oid_equal(&file->id, &git_oid__empty_blob_sha1))
+ file->flags |= GIT_DIFF_FLAG_VALID_SIZE;
+}
+
+static void diff_delta__flag_known_sizes(git_diff_delta *delta)
+{
+ diff_delta__flag_known_size(&delta->old_file);
+ diff_delta__flag_known_size(&delta->new_file);
+}
+
static int diff_delta__from_one(
git_diff_generated *diff,
git_delta_t status,
const git_index_entry *oitem,
const git_index_entry *nitem)
@@ -180,10 +200,12 @@
delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
if (has_old || !git_oid_is_zero(&delta->new_file.id))
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
+ diff_delta__flag_known_sizes(delta);
+
return diff_insert_delta(diff, delta, matched_pathspec);
}
static int diff_delta__from_two(
git_diff_generated *diff,
@@ -242,10 +264,12 @@
if (!git_oid_is_zero(&new_entry->id))
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
}
+ diff_delta__flag_known_sizes(delta);
+
return diff_insert_delta(diff, delta, matched_pathspec);
}
static git_diff_delta *diff_delta__last_for_item(
git_diff_generated *diff,
@@ -584,11 +608,11 @@
const git_index_entry *src,
uint16_t mode,
const git_oid *update_match)
{
git_diff_generated *diff;
- git_buf full_path = GIT_BUF_INIT;
+ git_str full_path = GIT_STR_INIT;
git_index_entry entry = *src;
git_filter_list *fl = NULL;
int error = 0;
GIT_ASSERT(d->type == GIT_DIFF_TYPE_GENERATED);
@@ -603,12 +627,12 @@
struct stat st;
diff->base.perf.stat_calls++;
if (p_stat(full_path.ptr, &st) < 0) {
- error = git_path_set_error(errno, entry.path, "stat");
- git_buf_dispose(&full_path);
+ error = git_fs_path_set_error(errno, entry.path, "stat");
+ git_str_dispose(&full_path);
return error;
}
git_index_entry__init_from_stat(&entry,
&st, (diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) != 0);
@@ -667,11 +691,11 @@
error = git_index_add(idx, &updated_entry);
diff->index_updated = true;
}
}
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
return error;
}
typedef struct {
git_repository *repo;
@@ -1021,13 +1045,13 @@
(delta_type == GIT_DELTA_IGNORED &&
DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS));
/* do not advance into directories that contain a .git file */
if (recurse_into_dir && !contains_oitem) {
- git_buf *full = NULL;
+ git_str *full = NULL;
if (git_iterator_current_workdir_path(&full, info->new_iter) < 0)
return -1;
- if (full && git_path_contains(full, DOT_GIT)) {
+ if (full && git_fs_path_contains(full, DOT_GIT)) {
/* TODO: warning if not a valid git repository */
recurse_into_dir = false;
}
}