Skip to content

Commit debca9d

Browse files
bmwillgitster
authored andcommitted
object: rename function 'typename' to 'type_name'
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6ca32f4 commit debca9d

32 files changed

+73
-73
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
229229
if (data->mark_query)
230230
data->info.typep = &data->type;
231231
else
232-
strbuf_addstr(sb, typename(data->type));
232+
strbuf_addstr(sb, type_name(data->type));
233233
} else if (is_atom("objectsize", atom, len)) {
234234
if (data->mark_query)
235235
data->info.sizep = &data->size;

builtin/diff-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int diff_tree_stdin(char *line)
7676
if (obj->type == OBJ_TREE)
7777
return stdin_diff_trees((struct tree *)obj, p);
7878
error("Object %s is a %s, not a commit or tree",
79-
oid_to_hex(&oid), typename(obj->type));
79+
oid_to_hex(&oid), type_name(obj->type));
8080
return -1;
8181
}
8282

builtin/fast-export.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
240240
buf = read_sha1_file(oid->hash, &type, &size);
241241
if (!buf)
242242
die ("Could not read blob %s", oid_to_hex(oid));
243-
if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)
243+
if (check_sha1_signature(oid->hash, buf, size, type_name(type)) < 0)
244244
die("sha1 mismatch in blob %s", oid_to_hex(oid));
245245
object = parse_object_buffer(oid, type, size, buf, &eaten);
246246
}
@@ -757,7 +757,7 @@ static void handle_tag(const char *name, struct tag *tag)
757757
if (tagged->type != OBJ_COMMIT) {
758758
die ("Tag %s tags unexported %s!",
759759
oid_to_hex(&tag->object.oid),
760-
typename(tagged->type));
760+
type_name(tagged->type));
761761
}
762762
p = (struct commit *)tagged;
763763
for (;;) {
@@ -839,7 +839,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
839839
if (!commit) {
840840
warning("%s: Unexpected object of type %s, skipping.",
841841
e->name,
842-
typename(e->item->type));
842+
type_name(e->item->type));
843843
continue;
844844
}
845845

@@ -851,7 +851,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
851851
continue;
852852
default: /* OBJ_TAG (nested tags) is already handled */
853853
warning("Tag points to object of unexpected type %s, skipping.",
854-
typename(commit->object.type));
854+
type_name(commit->object.type));
855855
continue;
856856
}
857857

builtin/fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)
7070
object_as_type(obj, type, 0);
7171
}
7272

73-
ret = typename(obj->type);
73+
ret = type_name(obj->type);
7474
if (!ret)
7575
ret = "unknown";
7676

@@ -137,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
137137
printf("broken link from %7s %s\n",
138138
printable_type(parent), describe_object(parent));
139139
printf("broken link from %7s %s\n",
140-
(type == OBJ_ANY ? "unknown" : typename(type)), "unknown");
140+
(type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
141141
errors_found |= ERROR_REACHABLE;
142142
return 1;
143143
}

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
627627
free(data);
628628
return hit;
629629
}
630-
die(_("unable to grep from object of type %s"), typename(obj->type));
630+
die(_("unable to grep from object of type %s"), type_name(obj->type));
631631
}
632632

633633
static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,

builtin/index-pack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static unsigned check_object(struct object *obj)
228228
if (type != obj->type)
229229
die(_("object %s: expected type %s, found %s"),
230230
oid_to_hex(&obj->oid),
231-
typename(obj->type), typename(type));
231+
type_name(obj->type), type_name(type));
232232
obj->flags |= FLAG_CHECKED;
233233
return 1;
234234
}
@@ -448,7 +448,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
448448
int hdrlen;
449449

450450
if (!is_delta_type(type)) {
451-
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), size) + 1;
451+
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), size) + 1;
452452
git_SHA1_Init(&c);
453453
git_SHA1_Update(&c, hdr, hdrlen);
454454
} else
@@ -849,7 +849,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
849849
obj = parse_object_buffer(oid, type, size, buf,
850850
&eaten);
851851
if (!obj)
852-
die(_("invalid %s"), typename(type));
852+
die(_("invalid %s"), type_name(type));
853853
if (do_fsck_object &&
854854
fsck_object(obj, buf, size, &fsck_options))
855855
die(_("Error in object"));
@@ -959,7 +959,7 @@ static void resolve_delta(struct object_entry *delta_obj,
959959
if (!result->data)
960960
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
961961
hash_sha1_file(result->data, result->size,
962-
typename(delta_obj->real_type),
962+
type_name(delta_obj->real_type),
963963
delta_obj->idx.oid.hash);
964964
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
965965
&delta_obj->idx.oid);
@@ -1379,7 +1379,7 @@ static void fix_unresolved_deltas(struct sha1file *f)
13791379
continue;
13801380

13811381
if (check_sha1_signature(d->sha1, base_obj->data,
1382-
base_obj->size, typename(type)))
1382+
base_obj->size, type_name(type)))
13831383
die(_("local object %s is corrupt"), sha1_to_hex(d->sha1));
13841384
base_obj->obj = append_obj_to_pack(f, d->sha1,
13851385
base_obj->data, base_obj->size, type);
@@ -1588,7 +1588,7 @@ static void show_pack_info(int stat_only)
15881588
continue;
15891589
printf("%s %-6s %lu %lu %"PRIuMAX,
15901590
oid_to_hex(&obj->idx.oid),
1591-
typename(obj->real_type), obj->size,
1591+
type_name(obj->real_type), obj->size,
15921592
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
15931593
(uintmax_t)obj->idx.offset);
15941594
if (is_delta_type(obj->type)) {

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
520520
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
521521
strbuf_addf(msg, "%s\t\t%s '%s'\n",
522522
oid_to_hex(&desc->obj->oid),
523-
typename(desc->obj->type),
523+
type_name(desc->obj->type),
524524
remote);
525525
goto cleanup;
526526
}

builtin/mktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
112112
mode_type = object_type(mode);
113113
if (mode_type != type_from_string(ptr)) {
114114
die("entry '%s' object type (%s) doesn't match mode type (%s)",
115-
path, ptr, typename(mode_type));
115+
path, ptr, type_name(mode_type));
116116
}
117117

118118
/* Check the type of object identified by sha1 */
@@ -131,7 +131,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
131131
* because the new tree entry will never be correct.
132132
*/
133133
die("entry '%s' object %s is a %s but specified type was (%s)",
134-
path, sha1_to_hex(sha1), typename(obj_type), typename(mode_type));
134+
path, sha1_to_hex(sha1), type_name(obj_type), type_name(mode_type));
135135
}
136136
}
137137

builtin/prune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
5252
if (show_only || verbose) {
5353
enum object_type type = sha1_object_info(oid->hash, NULL);
5454
printf("%s %s\n", oid_to_hex(oid),
55-
(type > 0) ? typename(type) : "unknown");
55+
(type > 0) ? type_name(type) : "unknown");
5656
}
5757
if (!show_only)
5858
unlink_or_warn(fullpath);

builtin/replace.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
5656
obj_type = sha1_object_info(object.hash, NULL);
5757
repl_type = sha1_object_info(oid->hash, NULL);
5858

59-
printf("%s (%s) -> %s (%s)\n", refname, typename(obj_type),
60-
oid_to_hex(oid), typename(repl_type));
59+
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
60+
oid_to_hex(oid), type_name(repl_type));
6161
}
6262
}
6363

@@ -168,8 +168,8 @@ static int replace_object_oid(const char *object_ref,
168168
die("Objects must be of the same type.\n"
169169
"'%s' points to a replaced object of type '%s'\n"
170170
"while '%s' points to a replacement object of type '%s'.",
171-
object_ref, typename(obj_type),
172-
replace_ref, typename(repl_type));
171+
object_ref, type_name(obj_type),
172+
replace_ref, type_name(repl_type));
173173

174174
check_ref_valid(object, &prev, &ref, force);
175175

@@ -215,7 +215,7 @@ static void export_object(const struct object_id *oid, enum object_type type,
215215
argv_array_push(&cmd.args, "--no-replace-objects");
216216
argv_array_push(&cmd.args, "cat-file");
217217
if (raw)
218-
argv_array_push(&cmd.args, typename(type));
218+
argv_array_push(&cmd.args, type_name(type));
219219
else
220220
argv_array_push(&cmd.args, "-p");
221221
argv_array_push(&cmd.args, oid_to_hex(oid));
@@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,
355355
struct tag *tag;
356356
int i;
357357

358-
hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), tag_oid.hash);
358+
hash_sha1_file(extra->value, extra->len, type_name(OBJ_TAG), tag_oid.hash);
359359
tag = lookup_tag(&tag_oid);
360360
if (!tag)
361361
die(_("bad mergetag in commit '%s'"), ref);

0 commit comments

Comments
 (0)