builtin/merge-base: convert to struct object_id
Convert the remaining uses of unsigned char [20] to struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
76c1d9a096
commit
d0ae910af4
@ -36,12 +36,12 @@ static const char * const merge_base_usage[] = {
|
|||||||
|
|
||||||
static struct commit *get_commit_reference(const char *arg)
|
static struct commit *get_commit_reference(const char *arg)
|
||||||
{
|
{
|
||||||
unsigned char revkey[20];
|
struct object_id revkey;
|
||||||
struct commit *r;
|
struct commit *r;
|
||||||
|
|
||||||
if (get_sha1(arg, revkey))
|
if (get_oid(arg, &revkey))
|
||||||
die("Not a valid object name %s", arg);
|
die("Not a valid object name %s", arg);
|
||||||
r = lookup_commit_reference(revkey);
|
r = lookup_commit_reference(revkey.hash);
|
||||||
if (!r)
|
if (!r)
|
||||||
die("Not a valid commit name %s", arg);
|
die("Not a valid commit name %s", arg);
|
||||||
|
|
||||||
@ -113,14 +113,14 @@ struct rev_collect {
|
|||||||
unsigned int initial : 1;
|
unsigned int initial : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void add_one_commit(unsigned char *sha1, struct rev_collect *revs)
|
static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
|
||||||
{
|
{
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
|
|
||||||
if (is_null_sha1(sha1))
|
if (is_null_oid(oid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
commit = lookup_commit(sha1);
|
commit = lookup_commit(oid->hash);
|
||||||
if (!commit ||
|
if (!commit ||
|
||||||
(commit->object.flags & TMP_MARK) ||
|
(commit->object.flags & TMP_MARK) ||
|
||||||
parse_commit(commit))
|
parse_commit(commit))
|
||||||
@ -139,15 +139,15 @@ static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid
|
|||||||
|
|
||||||
if (revs->initial) {
|
if (revs->initial) {
|
||||||
revs->initial = 0;
|
revs->initial = 0;
|
||||||
add_one_commit(ooid->hash, revs);
|
add_one_commit(ooid, revs);
|
||||||
}
|
}
|
||||||
add_one_commit(noid->hash, revs);
|
add_one_commit(noid, revs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_fork_point(int argc, const char **argv)
|
static int handle_fork_point(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
char *refname;
|
char *refname;
|
||||||
const char *commitname;
|
const char *commitname;
|
||||||
struct rev_collect revs;
|
struct rev_collect revs;
|
||||||
@ -155,7 +155,7 @@ static int handle_fork_point(int argc, const char **argv)
|
|||||||
struct commit_list *bases;
|
struct commit_list *bases;
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
switch (dwim_ref(argv[0], strlen(argv[0]), sha1, &refname)) {
|
switch (dwim_ref(argv[0], strlen(argv[0]), oid.hash, &refname)) {
|
||||||
case 0:
|
case 0:
|
||||||
die("No such ref: '%s'", argv[0]);
|
die("No such ref: '%s'", argv[0]);
|
||||||
case 1:
|
case 1:
|
||||||
@ -165,16 +165,16 @@ static int handle_fork_point(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
commitname = (argc == 2) ? argv[1] : "HEAD";
|
commitname = (argc == 2) ? argv[1] : "HEAD";
|
||||||
if (get_sha1(commitname, sha1))
|
if (get_oid(commitname, &oid))
|
||||||
die("Not a valid object name: '%s'", commitname);
|
die("Not a valid object name: '%s'", commitname);
|
||||||
|
|
||||||
derived = lookup_commit_reference(sha1);
|
derived = lookup_commit_reference(oid.hash);
|
||||||
memset(&revs, 0, sizeof(revs));
|
memset(&revs, 0, sizeof(revs));
|
||||||
revs.initial = 1;
|
revs.initial = 1;
|
||||||
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
|
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
|
||||||
|
|
||||||
if (!revs.nr && !get_sha1(refname, sha1))
|
if (!revs.nr && !get_oid(refname, &oid))
|
||||||
add_one_commit(sha1, &revs);
|
add_one_commit(&oid, &revs);
|
||||||
|
|
||||||
for (i = 0; i < revs.nr; i++)
|
for (i = 0; i < revs.nr; i++)
|
||||||
revs.commit[i]->object.flags &= ~TMP_MARK;
|
revs.commit[i]->object.flags &= ~TMP_MARK;
|
||||||
|
Reference in New Issue
Block a user