revision: convert remaining parse_object callers to object_id
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 6, 2017 at 22:10 UTC
654b9a905c160aec86be6c0b11bd1c539a62c0b9
1 file changed
+22
-22
revision.c
+22
-22
@@ -177,23 +177,23 @@ void add_pending_object(struct rev_info *revs,
177
178
void add_head_to_pending(struct rev_info *revs)
179
{
180
- unsigned char sha1[20];
180
+ struct object_id oid;
181
struct object *obj;
182
- if (get_sha1("HEAD", sha1))
182
+ if (get_oid("HEAD", &oid))
183
return;
184
- obj = parse_object(sha1);
184
+ obj = parse_object(oid.hash);
185
if (!obj)
186
return;
187
add_pending_object(revs, obj, "HEAD");
188
}
189
190
static struct object *get_reference(struct rev_info *revs, const char *name,
191
- const unsigned char *sha1,
191
+ const struct object_id *oid,
192
unsigned int flags)
193
{
194
struct object *object;
195
196
- object = parse_object(sha1);
196
+ object = parse_object(oid->hash);
197
if (!object) {
198
if (revs->ignore_missing)
199
return object;
@@ -206,7 +206,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
206
void add_pending_oid(struct rev_info *revs, const char *name,
207
const struct object_id *oid, unsigned int flags)
208
{
209
- struct object *object = get_reference(revs, name, oid->hash, flags);
209
+ struct object *object = get_reference(revs, name, oid, flags);
210
add_pending_object(revs, object, name);
211
}
212
@@ -1157,7 +1157,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
1157
if (ref_excluded(cb->all_revs->ref_excludes, path))
1158
return 0;
1159
1160
- object = get_reference(cb->all_revs, path, oid->hash, cb->all_flags);
1160
+ object = get_reference(cb->all_revs, path, oid, cb->all_flags);
1161
add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
1162
add_pending_oid(cb->all_revs, path, oid, cb->all_flags);
1163
return 0;
@@ -1292,7 +1292,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
1292
static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
1293
int exclude_parent)
1294
{
1295
- unsigned char sha1[20];
1295
+ struct object_id oid;
1296
struct object *it;
1297
struct commit *commit;
1298
struct commit_list *parents;
@@ -1303,17 +1303,17 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
1303
flags ^= UNINTERESTING | BOTTOM;
1304
arg++;
1305
}
1306
- if (get_sha1_committish(arg, sha1))
1306
+ if (get_sha1_committish(arg, oid.hash))
1307
return 0;
1308
while (1) {
1309
- it = get_reference(revs, arg, sha1, 0);
1309
+ it = get_reference(revs, arg, &oid, 0);
1310
if (!it && revs->ignore_missing)
1311
return 0;
1312
if (it->type != OBJ_TAG)
1313
break;
1314
if (!((struct tag*)it)->tagged)
1315
return 0;
1316
- hashcpy(sha1, ((struct tag*)it)->tagged->oid.hash);
1316
+ oidcpy(&oid, &((struct tag*)it)->tagged->oid);
1317
}
1318
if (it->type != OBJ_COMMIT)
1319
return 0;
@@ -1434,7 +1434,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1434
struct object_context oc;
1435
char *dotdot;
1436
struct object *object;
1437
- unsigned char sha1[20];
1437
+ struct object_id oid;
1438
int local_flags;
1439
const char *arg = arg_;
1440
int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;
@@ -1444,7 +1444,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1444
1445
dotdot = strstr(arg, "..");
1446
if (dotdot) {
1447
- unsigned char from_sha1[20];
1447
+ struct object_id from_oid;
1448
const char *next = dotdot + 2;
1449
const char *this = arg;
1450
int symmetric = *next == '.';
@@ -1470,8 +1470,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1470
return -1;
1471
}
1472
}
1473
- if (!get_sha1_committish(this, from_sha1) &&
1474
- !get_sha1_committish(next, sha1)) {
1473
+ if (!get_sha1_committish(this, from_oid.hash) &&
1474
+ !get_sha1_committish(next, oid.hash)) {
1475
struct object *a_obj, *b_obj;
1476
1477
if (!cant_be_filename) {
@@ -1479,8 +1479,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1479
verify_non_filename(revs->prefix, arg);
1480
}
1481
1482
- a_obj = parse_object(from_sha1);
1483
- b_obj = parse_object(sha1);
1482
+ a_obj = parse_object(from_oid.hash);
1483
+ b_obj = parse_object(oid.hash);
1484
if (!a_obj || !b_obj) {
1485
missing:
1486
if (revs->ignore_missing)
@@ -1568,11 +1568,11 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1568
if (revarg_opt & REVARG_COMMITTISH)
1569
get_sha1_flags = GET_SHA1_COMMITTISH;
1570
1571
- if (get_sha1_with_context(arg, get_sha1_flags, sha1, &oc))
1571
+ if (get_sha1_with_context(arg, get_sha1_flags, oid.hash, &oc))
1572
return revs->ignore_missing ? 0 : -1;
1573
if (!cant_be_filename)
1574
verify_non_filename(revs->prefix, arg);
1575
- object = get_reference(revs, arg, sha1, flags ^ local_flags);
1575
+ object = get_reference(revs, arg, &oid, flags ^ local_flags);
1576
add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
1577
add_pending_object_with_mode(revs, object, arg, oc.mode);
1578
return 0;
@@ -2287,12 +2287,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2287
if (revs->show_merge)
2288
prepare_show_merge(revs);
2289
if (revs->def && !revs->pending.nr && !got_rev_arg) {
2290
- unsigned char sha1[20];
2290
+ struct object_id oid;
2291
struct object *object;
2292
struct object_context oc;
2293
- if (get_sha1_with_context(revs->def, 0, sha1, &oc))
2293
+ if (get_sha1_with_context(revs->def, 0, oid.hash, &oc))
2294
diagnose_missing_default(revs->def);
2295
- object = get_reference(revs, revs->def, sha1, 0);
2295
+ object = get_reference(revs, revs->def, &oid, 0);
2296
add_pending_object_with_mode(revs, object, revs->def, oc.mode);
2297
}
2298