summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-19 19:38:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-19 19:38:44 (GMT)
commita6f38c109b6e70a1c788581194fc9b8669eea231 (patch)
treeb99d5c9b930d4c386789a5083fa2da804075d51c /diff.c
parentd04787e645abab1c50651fd41a748b43ac68c819 (diff)
parent94e327e973d320abf91c22307b87292911643c3b (diff)
downloadgit-a6f38c109b6e70a1c788581194fc9b8669eea231.zip
git-a6f38c109b6e70a1c788581194fc9b8669eea231.tar.gz
git-a6f38c109b6e70a1c788581194fc9b8669eea231.tar.bz2
Merge branch 'bw/object-id'
Conversion from uchar[20] to struct object_id continues. * bw/object-id: (33 commits) diff: rename diff_fill_sha1_info to diff_fill_oid_info diffcore-rename: use is_empty_blob_oid tree-diff: convert path_appendnew to object_id tree-diff: convert diff_tree_paths to struct object_id tree-diff: convert try_to_follow_renames to struct object_id builtin/diff-tree: cleanup references to sha1 diff-tree: convert diff_tree_sha1 to struct object_id notes-merge: convert write_note_to_worktree to struct object_id notes-merge: convert verify_notes_filepair to struct object_id notes-merge: convert find_notes_merge_pair_ps to struct object_id notes-merge: convert merge_from_diffs to struct object_id notes-merge: convert notes_merge* to struct object_id tree-diff: convert diff_root_tree_sha1 to struct object_id combine-diff: convert find_paths_* to struct object_id combine-diff: convert diff_tree_combined to struct object_id diff: convert diff_flush_patch_id to struct object_id patch-ids: convert to struct object_id diff: finish conversion for prepare_temp_file to struct object_id diff: convert reuse_worktree_file to struct object_id diff: convert fill_filespec to struct object_id ...
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/diff.c b/diff.c
index e35cf6c..acedf86 100644
--- a/diff.c
+++ b/diff.c
@@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)
}
}
-void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
- int sha1_valid, unsigned short mode)
+void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
+ int oid_valid, unsigned short mode)
{
if (mode) {
spec->mode = canon_mode(mode);
- hashcpy(spec->oid.hash, sha1);
- spec->oid_valid = sha1_valid;
+ oidcpy(&spec->oid, oid);
+ spec->oid_valid = oid_valid;
}
}
@@ -2717,7 +2717,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
* the work tree has that object contents, return true, so that
* prepare_temp_file() does not have to inflate and extract.
*/
-static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)
+static int reuse_worktree_file(const char *name, const struct object_id *oid, int want_file)
{
const struct cache_entry *ce;
struct stat st;
@@ -2748,7 +2748,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* objects however would tend to be slower as they need
* to be individually opened and inflated.
*/
- if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1))
+ if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(oid->hash))
return 0;
/*
@@ -2768,7 +2768,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* This is not the sha1 we are looking for, or
* unreusable because it is not a regular file.
*/
- if (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))
+ if (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
return 0;
/*
@@ -2842,7 +2842,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
return diff_populate_gitlink(s, size_only);
if (!s->oid_valid ||
- reuse_worktree_file(s->path, s->oid.hash, 0)) {
+ reuse_worktree_file(s->path, &s->oid, 0)) {
struct strbuf buf = STRBUF_INIT;
struct stat st;
int fd;
@@ -3008,7 +3008,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
if (!S_ISGITLINK(one->mode) &&
(!one->oid_valid ||
- reuse_worktree_file(name, one->oid.hash, 1))) {
+ reuse_worktree_file(name, &one->oid, 1))) {
struct stat st;
if (lstat(name, &st) < 0) {
if (errno == ENOENT)
@@ -3030,13 +3030,13 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
/* we can borrow from the file in the work tree */
temp->name = name;
if (!one->oid_valid)
- sha1_to_hex_r(temp->hex, null_sha1);
+ oid_to_hex_r(temp->hex, &null_oid);
else
oid_to_hex_r(temp->hex, &one->oid);
/* Even though we may sometimes borrow the
* contents from the work tree, we always want
* one->mode. mode is trustworthy even when
- * !(one->sha1_valid), as long as
+ * !(one->oid_valid), as long as
* DIFF_FILE_VALID(one).
*/
xsnprintf(temp->mode, sizeof(temp->mode), "%06o", one->mode);
@@ -3239,7 +3239,7 @@ static void run_diff_cmd(const char *pgm,
fprintf(o->file, "* Unmerged path %s\n", name);
}
-static void diff_fill_sha1_info(struct diff_filespec *one)
+static void diff_fill_oid_info(struct diff_filespec *one)
{
if (DIFF_FILE_VALID(one)) {
if (!one->oid_valid) {
@@ -3298,8 +3298,8 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
return;
}
- diff_fill_sha1_info(one);
- diff_fill_sha1_info(two);
+ diff_fill_oid_info(one);
+ diff_fill_oid_info(two);
if (!pgm &&
DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
@@ -3344,8 +3344,8 @@ static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
if (o->prefix_length)
strip_prefix(o->prefix_length, &name, &other);
- diff_fill_sha1_info(p->one);
- diff_fill_sha1_info(p->two);
+ diff_fill_oid_info(p->one);
+ diff_fill_oid_info(p->two);
builtin_diffstat(name, other, p->one, p->two, diffstat, o, p);
}
@@ -3368,8 +3368,8 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
if (o->prefix_length)
strip_prefix(o->prefix_length, &name, &other);
- diff_fill_sha1_info(p->one);
- diff_fill_sha1_info(p->two);
+ diff_fill_oid_info(p->one);
+ diff_fill_oid_info(p->two);
builtin_checkdiff(name, other, attr_path, p->one, p->two, o);
}
@@ -4582,7 +4582,7 @@ static void patch_id_add_mode(git_SHA_CTX *ctx, unsigned mode)
}
/* returns 0 upon success, and writes result into sha1 */
-static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
+static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
{
struct diff_queue_struct *q = &diff_queued_diff;
int i;
@@ -4614,8 +4614,8 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,
if (DIFF_PAIR_UNMERGED(p))
continue;
- diff_fill_sha1_info(p->one);
- diff_fill_sha1_info(p->two);
+ diff_fill_oid_info(p->one);
+ diff_fill_oid_info(p->two);
len1 = remove_space(p->one->path, strlen(p->one->path));
len2 = remove_space(p->two->path, strlen(p->two->path));
@@ -4654,9 +4654,9 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,
if (diff_filespec_is_binary(p->one) ||
diff_filespec_is_binary(p->two)) {
git_SHA1_Update(&ctx, oid_to_hex(&p->one->oid),
- 40);
+ GIT_SHA1_HEXSZ);
git_SHA1_Update(&ctx, oid_to_hex(&p->two->oid),
- 40);
+ GIT_SHA1_HEXSZ);
continue;
}
@@ -4669,15 +4669,15 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,
p->one->path);
}
- git_SHA1_Final(sha1, &ctx);
+ git_SHA1_Final(oid->hash, &ctx);
return 0;
}
-int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
+int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
{
struct diff_queue_struct *q = &diff_queued_diff;
int i;
- int result = diff_get_patch_id(options, sha1, diff_header_only);
+ int result = diff_get_patch_id(options, oid, diff_header_only);
for (i = 0; i < q->nr; i++)
diff_free_filepair(q->queue[i]);
@@ -5077,8 +5077,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
void diff_addremove(struct diff_options *options,
int addremove, unsigned mode,
- const unsigned char *sha1,
- int sha1_valid,
+ const struct object_id *oid,
+ int oid_valid,
const char *concatpath, unsigned dirty_submodule)
{
struct diff_filespec *one, *two;
@@ -5110,9 +5110,9 @@ void diff_addremove(struct diff_options *options,
two = alloc_filespec(concatpath);
if (addremove != '+')
- fill_filespec(one, sha1, sha1_valid, mode);
+ fill_filespec(one, oid, oid_valid, mode);
if (addremove != '-') {
- fill_filespec(two, sha1, sha1_valid, mode);
+ fill_filespec(two, oid, oid_valid, mode);
two->dirty_submodule = dirty_submodule;
}
@@ -5123,9 +5123,9 @@ void diff_addremove(struct diff_options *options,
void diff_change(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
- const unsigned char *old_sha1,
- const unsigned char *new_sha1,
- int old_sha1_valid, int new_sha1_valid,
+ const struct object_id *old_oid,
+ const struct object_id *new_oid,
+ int old_oid_valid, int new_oid_valid,
const char *concatpath,
unsigned old_dirty_submodule, unsigned new_dirty_submodule)
{
@@ -5138,8 +5138,8 @@ void diff_change(struct diff_options *options,
if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
SWAP(old_mode, new_mode);
- SWAP(old_sha1, new_sha1);
- SWAP(old_sha1_valid, new_sha1_valid);
+ SWAP(old_oid, new_oid);
+ SWAP(old_oid_valid, new_oid_valid);
SWAP(old_dirty_submodule, new_dirty_submodule);
}
@@ -5149,8 +5149,8 @@ void diff_change(struct diff_options *options,
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
- fill_filespec(one, old_sha1, old_sha1_valid, old_mode);
- fill_filespec(two, new_sha1, new_sha1_valid, new_mode);
+ fill_filespec(one, old_oid, old_oid_valid, old_mode);
+ fill_filespec(two, new_oid, new_oid_valid, new_mode);
one->dirty_submodule = old_dirty_submodule;
two->dirty_submodule = new_dirty_submodule;
p = diff_queue(&diff_queued_diff, one, two);
@@ -5277,7 +5277,7 @@ int textconv_object(const char *path,
struct userdiff_driver *textconv;
df = alloc_filespec(path);
- fill_filespec(df, oid->hash, oid_valid, mode);
+ fill_filespec(df, oid, oid_valid, mode);
textconv = get_textconv(df);
if (!textconv) {
free_filespec(df);