Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/blame: convert struct origin to use struct object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Mon, 5 Sep 2016 20:07:54 +0000
(20:07 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 7 Sep 2016 19:59:42 +0000
(12:59 -0700)
Convert struct origin to use struct object_id by applying the
following semantic patch and the object_id transforms from contrib,
plus the actual change to the struct:
@@
struct origin E1;
@@
- E1.blob_sha1
+ E1.blob_oid.hash
@@
struct origin *E1;
@@
- E1->blob_sha1
+ E1->blob_oid.hash
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
eb1c9c7
)
diff --git
a/builtin/blame.c
b/builtin/blame.c
index 5eb3725de261581fa667b32716965ea7951c2df3..9c09d464bf4b92ce063d2a5697bd52f4def47f54 100644
(file)
--- a/
builtin/blame.c
+++ b/
builtin/blame.c
@@
-120,7
+120,7
@@
struct origin {
*/
struct blame_entry *suspects;
mmfile_t file;
*/
struct blame_entry *suspects;
mmfile_t file;
-
unsigned char blob_sha1[20]
;
+
struct object_id blob_oid
;
unsigned mode;
/* guilty gets set when shipping any suspects to the final
* blame list instead of other commits
unsigned mode;
/* guilty gets set when shipping any suspects to the final
* blame list instead of other commits
@@
-188,15
+188,16
@@
static void fill_origin_blob(struct diff_options *opt,
num_read_blob++;
if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
num_read_blob++;
if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
- textconv_object(o->path, o->mode, o->blob_
sha1
, 1, &file->ptr, &file_size))
+ textconv_object(o->path, o->mode, o->blob_
oid.hash
, 1, &file->ptr, &file_size))
;
else
;
else
- file->ptr = read_sha1_file(o->blob_sha1, &type, &file_size);
+ file->ptr = read_sha1_file(o->blob_oid.hash, &type,
+ &file_size);
file->size = file_size;
if (!file->ptr)
die("Cannot read blob %s for path %s",
file->size = file_size;
if (!file->ptr)
die("Cannot read blob %s for path %s",
-
sha1_to_hex(o->blob_sha1
),
+
oid_to_hex(&o->blob_oid
),
o->path);
o->file = *file;
}
o->path);
o->file = *file;
}
@@
-508,17
+509,17
@@
static struct origin *get_origin(struct scoreboard *sb,
*/
static int fill_blob_sha1_and_mode(struct origin *origin)
{
*/
static int fill_blob_sha1_and_mode(struct origin *origin)
{
- if (!is_null_
sha1(origin->blob_sha1
))
+ if (!is_null_
oid(&origin->blob_oid
))
return 0;
if (get_tree_entry(origin->commit->object.oid.hash,
origin->path,
return 0;
if (get_tree_entry(origin->commit->object.oid.hash,
origin->path,
- origin->blob_
sha1
, &origin->mode))
+ origin->blob_
oid.hash
, &origin->mode))
goto error_out;
goto error_out;
- if (sha1_object_info(origin->blob_
sha1
, NULL) != OBJ_BLOB)
+ if (sha1_object_info(origin->blob_
oid.hash
, NULL) != OBJ_BLOB)
goto error_out;
return 0;
error_out:
goto error_out;
return 0;
error_out:
-
hashclr(origin->blob_sha1
);
+
oidclr(&origin->blob_oid
);
origin->mode = S_IFINVALID;
return -1;
}
origin->mode = S_IFINVALID;
return -1;
}
@@
-572,7
+573,7
@@
static struct origin *find_origin(struct scoreboard *sb,
if (!diff_queued_diff.nr) {
/* The path is the same as parent */
porigin = get_origin(sb, parent, origin->path);
if (!diff_queued_diff.nr) {
/* The path is the same as parent */
porigin = get_origin(sb, parent, origin->path);
-
hashcpy(porigin->blob_sha1, origin->blob_sha1
);
+
oidcpy(&porigin->blob_oid, &origin->blob_oid
);
porigin->mode = origin->mode;
} else {
/*
porigin->mode = origin->mode;
} else {
/*
@@
-598,7
+599,7
@@
static struct origin *find_origin(struct scoreboard *sb,
p->status);
case 'M':
porigin = get_origin(sb, parent, origin->path);
p->status);
case 'M':
porigin = get_origin(sb, parent, origin->path);
-
hashcpy(porigin->blob_sha1, p->one->oid.hash
);
+
oidcpy(&porigin->blob_oid, &p->one->oid
);
porigin->mode = p->one->mode;
break;
case 'A':
porigin->mode = p->one->mode;
break;
case 'A':
@@
-644,7
+645,7
@@
static struct origin *find_rename(struct scoreboard *sb,
if ((p->status == 'R' || p->status == 'C') &&
!strcmp(p->two->path, origin->path)) {
porigin = get_origin(sb, parent, p->one->path);
if ((p->status == 'R' || p->status == 'C') &&
!strcmp(p->two->path, origin->path)) {
porigin = get_origin(sb, parent, p->one->path);
-
hashcpy(porigin->blob_sha1, p->one->oid.hash
);
+
oidcpy(&porigin->blob_oid, &p->one->oid
);
porigin->mode = p->one->mode;
break;
}
porigin->mode = p->one->mode;
break;
}
@@
-1308,7
+1309,7
@@
static void find_copy_in_parent(struct scoreboard *sb,
continue;
norigin = get_origin(sb, parent, p->one->path);
continue;
norigin = get_origin(sb, parent, p->one->path);
-
hashcpy(norigin->blob_sha1, p->one->oid.hash
);
+
oidcpy(&norigin->blob_oid, &p->one->oid
);
norigin->mode = p->one->mode;
fill_origin_blob(&sb->revs->diffopt, norigin, &file_p);
if (!file_p.ptr)
norigin->mode = p->one->mode;
fill_origin_blob(&sb->revs->diffopt, norigin, &file_p);
if (!file_p.ptr)
@@
-1458,15
+1459,14
@@
static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
porigin = find(sb, p, origin);
if (!porigin)
continue;
porigin = find(sb, p, origin);
if (!porigin)
continue;
- if (!
hashcmp(porigin->blob_sha1, origin->blob_sha1
)) {
+ if (!
oidcmp(&porigin->blob_oid, &origin->blob_oid
)) {
pass_whole_blame(sb, origin, porigin);
origin_decref(porigin);
goto finish;
}
for (j = same = 0; j < i; j++)
if (sg_origin[j] &&
pass_whole_blame(sb, origin, porigin);
origin_decref(porigin);
goto finish;
}
for (j = same = 0; j < i; j++)
if (sg_origin[j] &&
- !hashcmp(sg_origin[j]->blob_sha1,
- porigin->blob_sha1)) {
+ !oidcmp(&sg_origin[j]->blob_oid, &porigin->blob_oid)) {
same = 1;
break;
}
same = 1;
break;
}
@@
-2388,7
+2388,7
@@
static struct commit *fake_working_tree_commit(struct diff_options *opt,
convert_to_git(path, buf.buf, buf.len, &buf, 0);
origin->file.ptr = buf.buf;
origin->file.size = buf.len;
convert_to_git(path, buf.buf, buf.len, &buf, 0);
origin->file.ptr = buf.buf;
origin->file.size = buf.len;
- pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_
sha1
);
+ pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_
oid.hash
);
/*
* Read the current index, replace the path entry with
/*
* Read the current index, replace the path entry with
@@
-2410,7
+2410,7
@@
static struct commit *fake_working_tree_commit(struct diff_options *opt,
}
size = cache_entry_size(len);
ce = xcalloc(1, size);
}
size = cache_entry_size(len);
ce = xcalloc(1, size);
-
hashcpy(ce->oid.hash, origin->blob_sha1
);
+
oidcpy(&ce->oid, &origin->blob_oid
);
memcpy(ce->name, path, len);
ce->ce_flags = create_ce_flags(0);
ce->ce_namelen = len;
memcpy(ce->name, path, len);
ce->ce_flags = create_ce_flags(0);
ce->ce_namelen = len;
@@
-2793,16
+2793,16
@@
int cmd_blame(int argc, const char **argv, const char *prefix)
die("no such path %s in %s", path, final_commit_name);
if (DIFF_OPT_TST(&sb.revs->diffopt, ALLOW_TEXTCONV) &&
die("no such path %s in %s", path, final_commit_name);
if (DIFF_OPT_TST(&sb.revs->diffopt, ALLOW_TEXTCONV) &&
- textconv_object(path, o->mode, o->blob_
sha1
, 1, (char **) &sb.final_buf,
+ textconv_object(path, o->mode, o->blob_
oid.hash
, 1, (char **) &sb.final_buf,
&sb.final_buf_size))
;
else
&sb.final_buf_size))
;
else
- sb.final_buf = read_sha1_file(o->blob_
sha1
, &type,
+ sb.final_buf = read_sha1_file(o->blob_
oid.hash
, &type,
&sb.final_buf_size);
if (!sb.final_buf)
die("Cannot read blob %s for path %s",
&sb.final_buf_size);
if (!sb.final_buf)
die("Cannot read blob %s for path %s",
-
sha1_to_hex(o->blob_sha1
),
+
oid_to_hex(&o->blob_oid
),
path);
}
num_read_blob++;
path);
}
num_read_blob++;