sha1_name: convert GET_SHA1* flags to GET_OID*
Convert the flags for get_oid_with_context and friends to use "OID" instead of "SHA1" in their names. This transform was made by running the following one-liner on the affected files: perl -pi -e 's/GET_SHA1/GET_OID/g' Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jul 13, 2017 at 23:49 UTC
321c89bf5fa937b19800fa97cfe93199b817d34f
8 files changed
+56
-56
builtin/cat-file.c
+2
-2
@@ -63,7 +63,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
63
if (unknown_type)
64
flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
65
66
- if (get_oid_with_context(obj_name, GET_SHA1_RECORD_PATH,
66
+ if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
67
&oid, &obj_context))
68
die("Not a valid object name %s", obj_name);
69
@@ -361,7 +361,7 @@ static void batch_one_object(const char *obj_name, struct batch_options *opt,
361
struct expand_data *data)
362
{
363
struct object_context ctx;
364
- int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0;
364
+ int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
365
enum follow_symlinks_result result;
366
367
result = get_oid_with_context(obj_name, flags, &data->oid, &ctx);
builtin/grep.c
+1
-1
@@ -1207,7 +1207,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
1207
break;
1208
}
1209
1210
- if (get_oid_with_context(arg, GET_SHA1_RECORD_PATH,
1210
+ if (get_oid_with_context(arg, GET_OID_RECORD_PATH,
1211
&oid, &oc)) {
1212
if (seen_dashdash)
1213
die(_("unable to resolve revision: %s"), arg);
builtin/log.c
+1
-1
@@ -484,7 +484,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
484
!DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))
485
return stream_blob_to_fd(1, oid, NULL, 0);
486
487
- if (get_oid_with_context(obj_name, GET_SHA1_RECORD_PATH,
487
+ if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
488
&oidc, &obj_context))
489
die(_("Not a valid object name %s"), obj_name);
490
if (!obj_context.path ||
builtin/rev-parse.c
+1
-1
@@ -702,7 +702,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
702
}
703
if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
704
quiet = 1;
705
- flags |= GET_SHA1_QUIETLY;
705
+ flags |= GET_OID_QUIETLY;
706
continue;
707
}
708
if (opt_with_value(arg, "--short", &arg)) {
cache.h
+15
-15
@@ -1283,27 +1283,27 @@ struct object_context {
1283
*/
1284
struct strbuf symlink_path;
1285
/*
1286
- * If GET_SHA1_RECORD_PATH is set, this will record path (if any)
1286
+ * If GET_OID_RECORD_PATH is set, this will record path (if any)
1287
* found when resolving the name. The caller is responsible for
1288
* releasing the memory.
1289
*/
1290
char *path;
1291
};
1292
1293
-#define GET_SHA1_QUIETLY 01
1294
-#define GET_SHA1_COMMIT 02
1295
-#define GET_SHA1_COMMITTISH 04
1296
-#define GET_SHA1_TREE 010
1297
-#define GET_SHA1_TREEISH 020
1298
-#define GET_SHA1_BLOB 040
1299
-#define GET_SHA1_FOLLOW_SYMLINKS 0100
1300
-#define GET_SHA1_RECORD_PATH 0200
1301
-#define GET_SHA1_ONLY_TO_DIE 04000
1302
-
1303
-#define GET_SHA1_DISAMBIGUATORS \
1304
- (GET_SHA1_COMMIT | GET_SHA1_COMMITTISH | \
1305
- GET_SHA1_TREE | GET_SHA1_TREEISH | \
1306
- GET_SHA1_BLOB)
1293
+#define GET_OID_QUIETLY 01
1294
+#define GET_OID_COMMIT 02
1295
+#define GET_OID_COMMITTISH 04
1296
+#define GET_OID_TREE 010
1297
+#define GET_OID_TREEISH 020
1298
+#define GET_OID_BLOB 040
1299
+#define GET_OID_FOLLOW_SYMLINKS 0100
1300
+#define GET_OID_RECORD_PATH 0200
1301
+#define GET_OID_ONLY_TO_DIE 04000
1302
+
1303
+#define GET_OID_DISAMBIGUATORS \
1304
+ (GET_OID_COMMIT | GET_OID_COMMITTISH | \
1305
+ GET_OID_TREE | GET_OID_TREEISH | \
1306
+ GET_OID_BLOB)
1307
1308
extern int get_oid(const char *str, struct object_id *oid);
1309
extern int get_oid_commit(const char *str, struct object_id *oid);
refs.c
+1
-1
@@ -818,7 +818,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in
818
for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);
819
820
if (!cb.reccnt) {
821
- if (flags & GET_SHA1_QUIETLY)
821
+ if (flags & GET_OID_QUIETLY)
822
exit(128);
823
else
824
die("Log for %s is empty.", refname);
revision.c
+3
-3
@@ -1453,7 +1453,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
1453
unsigned int a_flags, b_flags;
1454
int symmetric = 0;
1455
unsigned int flags_exclude = flags ^ (UNINTERESTING | BOTTOM);
1456
- unsigned int oc_flags = GET_SHA1_COMMITTISH | GET_SHA1_RECORD_PATH;
1456
+ unsigned int oc_flags = GET_OID_COMMITTISH | GET_OID_RECORD_PATH;
1457
1458
a_name = arg;
1459
if (!*a_name)
@@ -1549,7 +1549,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1549
int local_flags;
1550
const char *arg = arg_;
1551
int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;
1552
- unsigned get_sha1_flags = GET_SHA1_RECORD_PATH;
1552
+ unsigned get_sha1_flags = GET_OID_RECORD_PATH;
1553
1554
flags = flags & UNINTERESTING ? flags | BOTTOM : flags & ~BOTTOM;
1555
@@ -1600,7 +1600,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1600
}
1601
1602
if (revarg_opt & REVARG_COMMITTISH)
1603
- get_sha1_flags |= GET_SHA1_COMMITTISH;
1603
+ get_sha1_flags |= GET_OID_COMMITTISH;
1604
1605
if (get_oid_with_context(arg, get_sha1_flags, &oid, &oc))
1606
return revs->ignore_missing ? 0 : -1;
sha1_name.c
+32
-32
@@ -390,23 +390,23 @@ static int get_short_oid(const char *name, int len, struct object_id *oid,
390
{
391
int status;
392
struct disambiguate_state ds;
393
- int quietly = !!(flags & GET_SHA1_QUIETLY);
393
+ int quietly = !!(flags & GET_OID_QUIETLY);
394
395
if (init_object_disambiguation(name, len, &ds) < 0)
396
return -1;
397
398
- if (HAS_MULTI_BITS(flags & GET_SHA1_DISAMBIGUATORS))
398
+ if (HAS_MULTI_BITS(flags & GET_OID_DISAMBIGUATORS))
399
die("BUG: multiple get_short_oid disambiguator flags");
400
401
- if (flags & GET_SHA1_COMMIT)
401
+ if (flags & GET_OID_COMMIT)
402
ds.fn = disambiguate_commit_only;
403
- else if (flags & GET_SHA1_COMMITTISH)
403
+ else if (flags & GET_OID_COMMITTISH)
404
ds.fn = disambiguate_committish_only;
405
- else if (flags & GET_SHA1_TREE)
405
+ else if (flags & GET_OID_TREE)
406
ds.fn = disambiguate_tree_only;
407
- else if (flags & GET_SHA1_TREEISH)
407
+ else if (flags & GET_OID_TREEISH)
408
ds.fn = disambiguate_treeish_only;
409
- else if (flags & GET_SHA1_BLOB)
409
+ else if (flags & GET_OID_BLOB)
410
ds.fn = disambiguate_blob_only;
411
else
412
ds.fn = default_disambiguate_hint;
@@ -505,7 +505,7 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)
505
exists = has_sha1_file(sha1);
506
while (len < 40) {
507
struct object_id oid_ret;
508
- status = get_short_oid(hex, len, &oid_ret, GET_SHA1_QUIETLY);
508
+ status = get_short_oid(hex, len, &oid_ret, GET_OID_QUIETLY);
509
if (exists
510
? !status
511
: status == SHORT_NAME_NOT_FOUND) {
@@ -662,9 +662,9 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
662
if (!refs_found)
663
return -1;
664
665
- if (warn_ambiguous_refs && !(flags & GET_SHA1_QUIETLY) &&
665
+ if (warn_ambiguous_refs && !(flags & GET_OID_QUIETLY) &&
666
(refs_found > 1 ||
667
- !get_short_oid(str, len, &tmp_oid, GET_SHA1_QUIETLY)))
667
+ !get_short_oid(str, len, &tmp_oid, GET_OID_QUIETLY)))
668
warning(warn_msg, len, str);
669
670
if (reflog_len) {
@@ -709,13 +709,13 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
709
}
710
}
711
if (at_time) {
712
- if (!(flags & GET_SHA1_QUIETLY)) {
712
+ if (!(flags & GET_OID_QUIETLY)) {
713
warning("Log for '%.*s' only goes "
714
"back to %s.", len, str,
715
show_date(co_time, co_tz, DATE_MODE(RFC2822)));
716
}
717
} else {
718
- if (flags & GET_SHA1_QUIETLY) {
718
+ if (flags & GET_OID_QUIETLY) {
719
exit(128);
720
}
721
die("Log for '%.*s' only has %d entries.",
@@ -732,7 +732,7 @@ static int get_parent(const char *name, int len,
732
struct object_id *result, int idx)
733
{
734
struct object_id oid;
735
- int ret = get_oid_1(name, len, &oid, GET_SHA1_COMMITTISH);
735
+ int ret = get_oid_1(name, len, &oid, GET_OID_COMMITTISH);
736
struct commit *commit;
737
struct commit_list *p;
738
@@ -763,7 +763,7 @@ static int get_nth_ancestor(const char *name, int len,
763
struct commit *commit;
764
int ret;
765
766
- ret = get_oid_1(name, len, &oid, GET_SHA1_COMMITTISH);
766
+ ret = get_oid_1(name, len, &oid, GET_OID_COMMITTISH);
767
if (ret)
768
return ret;
769
commit = lookup_commit_reference(&oid);
@@ -849,11 +849,11 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
849
else
850
return -1;
851
852
- lookup_flags &= ~GET_SHA1_DISAMBIGUATORS;
852
+ lookup_flags &= ~GET_OID_DISAMBIGUATORS;
853
if (expected_type == OBJ_COMMIT)
854
- lookup_flags |= GET_SHA1_COMMITTISH;
854
+ lookup_flags |= GET_OID_COMMITTISH;
855
else if (expected_type == OBJ_TREE)
856
- lookup_flags |= GET_SHA1_TREEISH;
856
+ lookup_flags |= GET_OID_TREEISH;
857
858
if (get_oid_1(name, sp - name - 2, &outer, lookup_flags))
859
return -1;
@@ -904,7 +904,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
904
static int get_describe_name(const char *name, int len, struct object_id *oid)
905
{
906
const char *cp;
907
- unsigned flags = GET_SHA1_QUIETLY | GET_SHA1_COMMIT;
907
+ unsigned flags = GET_OID_QUIETLY | GET_OID_COMMIT;
908
909
for (cp = name + len - 1; name + 2 <= cp; cp--) {
910
char ch = *cp;
@@ -1361,35 +1361,35 @@ int get_oid(const char *name, struct object_id *oid)
1361
int get_oid_committish(const char *name, struct object_id *oid)
1362
{
1363
struct object_context unused;
1364
- return get_oid_with_context(name, GET_SHA1_COMMITTISH,
1364
+ return get_oid_with_context(name, GET_OID_COMMITTISH,
1365
oid, &unused);
1366
}
1367
1368
int get_oid_treeish(const char *name, struct object_id *oid)
1369
{
1370
struct object_context unused;
1371
- return get_oid_with_context(name, GET_SHA1_TREEISH,
1371
+ return get_oid_with_context(name, GET_OID_TREEISH,
1372
oid, &unused);
1373
}
1374
1375
int get_oid_commit(const char *name, struct object_id *oid)
1376
{
1377
struct object_context unused;
1378
- return get_oid_with_context(name, GET_SHA1_COMMIT,
1378
+ return get_oid_with_context(name, GET_OID_COMMIT,
1379
oid, &unused);
1380
}
1381
1382
int get_oid_tree(const char *name, struct object_id *oid)
1383
{
1384
struct object_context unused;
1385
- return get_oid_with_context(name, GET_SHA1_TREE,
1385
+ return get_oid_with_context(name, GET_OID_TREE,
1386
oid, &unused);
1387
}
1388
1389
int get_oid_blob(const char *name, struct object_id *oid)
1390
{
1391
struct object_context unused;
1392
- return get_oid_with_context(name, GET_SHA1_BLOB,
1392
+ return get_oid_with_context(name, GET_OID_BLOB,
1393
oid, &unused);
1394
}
1395
@@ -1505,10 +1505,10 @@ static int get_oid_with_context_1(const char *name,
1505
int ret, bracket_depth;
1506
int namelen = strlen(name);
1507
const char *cp;
1508
- int only_to_die = flags & GET_SHA1_ONLY_TO_DIE;
1508
+ int only_to_die = flags & GET_OID_ONLY_TO_DIE;
1509
1510
if (only_to_die)
1511
- flags |= GET_SHA1_QUIETLY;
1511
+ flags |= GET_OID_QUIETLY;
1512
1513
memset(oc, 0, sizeof(*oc));
1514
oc->mode = S_IFINVALID;
@@ -1551,7 +1551,7 @@ static int get_oid_with_context_1(const char *name,
1551
namelen = strlen(cp);
1552
}
1553
1554
- if (flags & GET_SHA1_RECORD_PATH)
1554
+ if (flags & GET_OID_RECORD_PATH)
1555
oc->path = xstrdup(cp);
1556
1557
if (!active_cache)
@@ -1590,8 +1590,8 @@ static int get_oid_with_context_1(const char *name,
1590
int len = cp - name;
1591
unsigned sub_flags = flags;
1592
1593
- sub_flags &= ~GET_SHA1_DISAMBIGUATORS;
1594
- sub_flags |= GET_SHA1_TREEISH;
1593
+ sub_flags &= ~GET_OID_DISAMBIGUATORS;
1594
+ sub_flags |= GET_OID_TREEISH;
1595
1596
if (!get_oid_1(name, len, &tree_oid, sub_flags)) {
1597
const char *filename = cp+1;
@@ -1600,7 +1600,7 @@ static int get_oid_with_context_1(const char *name,
1600
new_filename = resolve_relative_path(filename);
1601
if (new_filename)
1602
filename = new_filename;
1603
- if (flags & GET_SHA1_FOLLOW_SYMLINKS) {
1603
+ if (flags & GET_OID_FOLLOW_SYMLINKS) {
1604
ret = get_tree_entry_follow_symlinks(tree_oid.hash,
1605
filename, oid->hash, &oc->symlink_path,
1606
&oc->mode);
@@ -1615,7 +1615,7 @@ static int get_oid_with_context_1(const char *name,
1615
}
1616
}
1617
hashcpy(oc->tree, tree_oid.hash);
1618
- if (flags & GET_SHA1_RECORD_PATH)
1618
+ if (flags & GET_OID_RECORD_PATH)
1619
oc->path = xstrdup(filename);
1620
1621
free(new_filename);
@@ -1639,12 +1639,12 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
1639
{
1640
struct object_context oc;
1641
struct object_id oid;
1642
- get_oid_with_context_1(name, GET_SHA1_ONLY_TO_DIE, prefix, &oid, &oc);
1642
+ get_oid_with_context_1(name, GET_OID_ONLY_TO_DIE, prefix, &oid, &oc);
1643
}
1644
1645
int get_oid_with_context(const char *str, unsigned flags, struct object_id *oid, struct object_context *oc)
1646
{
1647
- if (flags & GET_SHA1_FOLLOW_SYMLINKS && flags & GET_SHA1_ONLY_TO_DIE)
1647
+ if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
1648
die("BUG: incompatible flags for get_sha1_with_context");
1649
return get_oid_with_context_1(str, flags, NULL, oid, oc);
1650
}