vendor/libgit2/src/libgit2/diff_file.c in rugged-1.6.5 vs vendor/libgit2/src/libgit2/diff_file.c in rugged-1.7.1
- old
+ new
@@ -110,11 +110,11 @@
case GIT_DELTA_ADDED:
has_data = !use_old; break;
case GIT_DELTA_DELETED:
has_data = use_old; break;
case GIT_DELTA_UNTRACKED:
- has_data = !use_old &&
+ has_data = (use_old == (diff->opts.flags & GIT_DIFF_REVERSE)) &&
(diff->opts.flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) != 0;
break;
case GIT_DELTA_UNREADABLE:
case GIT_DELTA_MODIFIED:
case GIT_DELTA_COPIED:
@@ -142,32 +142,32 @@
fc->repo = repo;
fc->file = as_file;
if (!src->blob && !src->buf) {
fc->flags |= GIT_DIFF_FLAG__NO_DATA;
- git_oid_clear(&fc->file->id, GIT_OID_SHA1);
+ git_oid_clear(&fc->file->id, opts->oid_type);
} else {
fc->flags |= GIT_DIFF_FLAG__LOADED;
fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
fc->file->mode = GIT_FILEMODE_BLOB;
if (src->blob) {
git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob);
fc->file->size = git_blob_rawsize(src->blob);
git_oid_cpy(&fc->file->id, git_blob_id(src->blob));
- fc->file->id_abbrev = GIT_OID_SHA1_HEXSIZE;
+ fc->file->id_abbrev = (uint16_t)git_oid_hexsize(repo->oid_type);
fc->map.len = (size_t)fc->file->size;
fc->map.data = (char *)git_blob_rawcontent(src->blob);
fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
} else {
int error;
- if ((error = git_odb__hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB, GIT_OID_SHA1)) < 0)
+ if ((error = git_odb__hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB, opts->oid_type)) < 0)
return error;
fc->file->size = src->buflen;
- fc->file->id_abbrev = GIT_OID_SHA1_HEXSIZE;
+ fc->file->id_abbrev = (uint16_t)git_oid_hexsize(opts->oid_type);
fc->map.len = src->buflen;
fc->map.data = (char *)src->buf;
}
}
@@ -176,11 +176,11 @@
}
static int diff_file_content_commit_to_str(
git_diff_file_content *fc, bool check_status)
{
- char oid[GIT_OID_SHA1_HEXSIZE+1];
+ char oid[GIT_OID_MAX_HEXSIZE+1];
git_str content = GIT_STR_INIT;
const char *status = "";
if (check_status) {
int error = 0;
@@ -418,10 +418,10 @@
/* once data is loaded, update OID if we didn't have it previously */
if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) {
error = git_odb__hash(
&fc->file->id, fc->map.data, fc->map.len,
- GIT_OBJECT_BLOB, GIT_OID_SHA1);
+ GIT_OBJECT_BLOB, diff_opts->oid_type);
fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
}
git_str_dispose(&path);
return error;