Skip to content

Commit

Permalink
object: rename function 'typename' to 'type_name'
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
bmwill authored and gitster committed Feb 14, 2018
1 parent 6ca32f4 commit debca9d
Show file tree
Hide file tree
Showing 32 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
if (data->mark_query)
data->info.typep = &data->type;
else
strbuf_addstr(sb, typename(data->type));
strbuf_addstr(sb, type_name(data->type));
} else if (is_atom("objectsize", atom, len)) {
if (data->mark_query)
data->info.sizep = &data->size;
Expand Down
2 changes: 1 addition & 1 deletion builtin/diff-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static int diff_tree_stdin(char *line)
if (obj->type == OBJ_TREE)
return stdin_diff_trees((struct tree *)obj, p);
error("Object %s is a %s, not a commit or tree",
oid_to_hex(&oid), typename(obj->type));
oid_to_hex(&oid), type_name(obj->type));
return -1;
}

Expand Down
8 changes: 4 additions & 4 deletions builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
buf = read_sha1_file(oid->hash, &type, &size);
if (!buf)
die ("Could not read blob %s", oid_to_hex(oid));
if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)
if (check_sha1_signature(oid->hash, buf, size, type_name(type)) < 0)
die("sha1 mismatch in blob %s", oid_to_hex(oid));
object = parse_object_buffer(oid, type, size, buf, &eaten);
}
Expand Down Expand Up @@ -757,7 +757,7 @@ static void handle_tag(const char *name, struct tag *tag)
if (tagged->type != OBJ_COMMIT) {
die ("Tag %s tags unexported %s!",
oid_to_hex(&tag->object.oid),
typename(tagged->type));
type_name(tagged->type));
}
p = (struct commit *)tagged;
for (;;) {
Expand Down Expand Up @@ -839,7 +839,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (!commit) {
warning("%s: Unexpected object of type %s, skipping.",
e->name,
typename(e->item->type));
type_name(e->item->type));
continue;
}

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

Expand Down
4 changes: 2 additions & 2 deletions builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)
object_as_type(obj, type, 0);
}

ret = typename(obj->type);
ret = type_name(obj->type);
if (!ret)
ret = "unknown";

Expand Down Expand Up @@ -137,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
printf("broken link from %7s %s\n",
printable_type(parent), describe_object(parent));
printf("broken link from %7s %s\n",
(type == OBJ_ANY ? "unknown" : typename(type)), "unknown");
(type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
errors_found |= ERROR_REACHABLE;
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
free(data);
return hit;
}
die(_("unable to grep from object of type %s"), typename(obj->type));
die(_("unable to grep from object of type %s"), type_name(obj->type));
}

static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
Expand Down
12 changes: 6 additions & 6 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static unsigned check_object(struct object *obj)
if (type != obj->type)
die(_("object %s: expected type %s, found %s"),
oid_to_hex(&obj->oid),
typename(obj->type), typename(type));
type_name(obj->type), type_name(type));
obj->flags |= FLAG_CHECKED;
return 1;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
int hdrlen;

if (!is_delta_type(type)) {
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), size) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), size) + 1;
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, hdrlen);
} else
Expand Down Expand Up @@ -849,7 +849,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
obj = parse_object_buffer(oid, type, size, buf,
&eaten);
if (!obj)
die(_("invalid %s"), typename(type));
die(_("invalid %s"), type_name(type));
if (do_fsck_object &&
fsck_object(obj, buf, size, &fsck_options))
die(_("Error in object"));
Expand Down Expand Up @@ -959,7 +959,7 @@ static void resolve_delta(struct object_entry *delta_obj,
if (!result->data)
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
hash_sha1_file(result->data, result->size,
typename(delta_obj->real_type),
type_name(delta_obj->real_type),
delta_obj->idx.oid.hash);
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
&delta_obj->idx.oid);
Expand Down Expand Up @@ -1379,7 +1379,7 @@ static void fix_unresolved_deltas(struct sha1file *f)
continue;

if (check_sha1_signature(d->sha1, base_obj->data,
base_obj->size, typename(type)))
base_obj->size, type_name(type)))
die(_("local object %s is corrupt"), sha1_to_hex(d->sha1));
base_obj->obj = append_obj_to_pack(f, d->sha1,
base_obj->data, base_obj->size, type);
Expand Down Expand Up @@ -1588,7 +1588,7 @@ static void show_pack_info(int stat_only)
continue;
printf("%s %-6s %lu %lu %"PRIuMAX,
oid_to_hex(&obj->idx.oid),
typename(obj->real_type), obj->size,
type_name(obj->real_type), obj->size,
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
(uintmax_t)obj->idx.offset);
if (is_delta_type(obj->type)) {
Expand Down
2 changes: 1 addition & 1 deletion builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
strbuf_addf(msg, "%s\t\t%s '%s'\n",
oid_to_hex(&desc->obj->oid),
typename(desc->obj->type),
type_name(desc->obj->type),
remote);
goto cleanup;
}
Expand Down
4 changes: 2 additions & 2 deletions builtin/mktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
mode_type = object_type(mode);
if (mode_type != type_from_string(ptr)) {
die("entry '%s' object type (%s) doesn't match mode type (%s)",
path, ptr, typename(mode_type));
path, ptr, type_name(mode_type));
}

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

Expand Down
2 changes: 1 addition & 1 deletion builtin/prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
if (show_only || verbose) {
enum object_type type = sha1_object_info(oid->hash, NULL);
printf("%s %s\n", oid_to_hex(oid),
(type > 0) ? typename(type) : "unknown");
(type > 0) ? type_name(type) : "unknown");
}
if (!show_only)
unlink_or_warn(fullpath);
Expand Down
12 changes: 6 additions & 6 deletions builtin/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
obj_type = sha1_object_info(object.hash, NULL);
repl_type = sha1_object_info(oid->hash, NULL);

printf("%s (%s) -> %s (%s)\n", refname, typename(obj_type),
oid_to_hex(oid), typename(repl_type));
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
oid_to_hex(oid), type_name(repl_type));
}
}

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

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

Expand Down Expand Up @@ -215,7 +215,7 @@ static void export_object(const struct object_id *oid, enum object_type type,
argv_array_push(&cmd.args, "--no-replace-objects");
argv_array_push(&cmd.args, "cat-file");
if (raw)
argv_array_push(&cmd.args, typename(type));
argv_array_push(&cmd.args, type_name(type));
else
argv_array_push(&cmd.args, "-p");
argv_array_push(&cmd.args, oid_to_hex(oid));
Expand Down Expand Up @@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,
struct tag *tag;
int i;

hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), tag_oid.hash);
hash_sha1_file(extra->value, extra->len, type_name(OBJ_TAG), tag_oid.hash);
tag = lookup_tag(&tag_oid);
if (!tag)
die(_("bad mergetag in commit '%s'"), ref);
Expand Down
2 changes: 1 addition & 1 deletion builtin/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static void create_tag(const struct object_id *object, const char *tag,
"tag %s\n"
"tagger %s\n\n",
oid_to_hex(object),
typename(type),
type_name(type),
tag,
git_committer_info(IDENT_STRICT));

Expand Down
10 changes: 5 additions & 5 deletions builtin/unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
{
struct object_id oid;

if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), oid.hash) < 0)
if (write_sha1_file(obj_buf->buffer, obj_buf->size, type_name(obj->type), oid.hash) < 0)
die("failed to write object %s", oid_to_hex(&obj->oid));
obj->flags |= FLAG_WRITTEN;
}
Expand Down Expand Up @@ -237,14 +237,14 @@ static void write_object(unsigned nr, enum object_type type,
void *buf, unsigned long size)
{
if (!strict) {
if (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)
if (write_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
free(buf);
obj_list[nr].obj = NULL;
} else if (type == OBJ_BLOB) {
struct blob *blob;
if (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)
if (write_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
free(buf);
Expand All @@ -258,12 +258,12 @@ static void write_object(unsigned nr, enum object_type type,
} else {
struct object *obj;
int eaten;
hash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);
hash_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash);
added_object(nr, type, buf, size);
obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
&eaten);
if (!obj)
die("invalid %s", typename(type));
die("invalid %s", type_name(type));
add_object_buffer(obj, buf, size);
obj->flags |= FLAG_OPEN;
obj_list[nr].obj = obj;
Expand Down
2 changes: 1 addition & 1 deletion builtin/verify-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int verify_commit(const char *name, unsigned flags)
return error("%s: unable to read file.", name);
if (type != OBJ_COMMIT)
return error("%s: cannot verify a non-commit object of type %s.",
name, typename(type));
name, type_name(type));

ret = run_gpg_verify(&oid, buf, size, flags);

Expand Down
2 changes: 1 addition & 1 deletion bulk-checkin.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
return error("cannot find the current offset");

header_len = xsnprintf((char *)obuf, sizeof(obuf), "%s %" PRIuMAX,
typename(type), (uintmax_t)size) + 1;
type_name(type), (uintmax_t)size) + 1;
git_SHA1_Init(&ctx);
git_SHA1_Update(&ctx, obuf, header_len);

Expand Down
2 changes: 1 addition & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
oid_to_hex(&commit->object.oid));
if (type != OBJ_COMMIT)
die("expected commit for %s, got %s",
oid_to_hex(&commit->object.oid), typename(type));
oid_to_hex(&commit->object.oid), type_name(type));
if (sizep)
*sizep = size;
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/examples/builtin-fetch--tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static char *get_stdin(void)

static void show_new(enum object_type type, unsigned char *sha1_new)
{
fprintf(stderr, " %s: %s\n", typename(type),
fprintf(stderr, " %s: %s\n", type_name(type),
find_unique_abbrev(sha1_new, DEFAULT_ABBREV));
}

Expand Down
16 changes: 8 additions & 8 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ static int store_object(
git_zstream s;

hdrlen = xsnprintf((char *)hdr, sizeof(hdr), "%s %lu",
typename(type), (unsigned long)dat->len) + 1;
type_name(type), (unsigned long)dat->len) + 1;
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, hdrlen);
git_SHA1_Update(&c, dat->buf, dat->len);
Expand Down Expand Up @@ -2421,7 +2421,7 @@ static void file_change_m(const char *p, struct branch *b)
else if (oe) {
if (oe->type != OBJ_COMMIT)
die("Not a commit (actually a %s): %s",
typename(oe->type), command_buf.buf);
type_name(oe->type), command_buf.buf);
}
/*
* Accept the sha1 without checking; it expected to be in
Expand All @@ -2448,7 +2448,7 @@ static void file_change_m(const char *p, struct branch *b)
command_buf.buf);
if (type != expected)
die("Not a %s (actually a %s): %s",
typename(expected), typename(type),
type_name(expected), type_name(type),
command_buf.buf);
}

Expand Down Expand Up @@ -2599,14 +2599,14 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
} else if (oe) {
if (oe->type != OBJ_BLOB)
die("Not a blob (actually a %s): %s",
typename(oe->type), command_buf.buf);
type_name(oe->type), command_buf.buf);
} else if (!is_null_oid(&oid)) {
enum object_type type = sha1_object_info(oid.hash, NULL);
if (type < 0)
die("Blob not found: %s", command_buf.buf);
if (type != OBJ_BLOB)
die("Not a blob (actually a %s): %s",
typename(type), command_buf.buf);
type_name(type), command_buf.buf);
}

construct_path_with_fanout(oid_to_hex(&commit_oid), *old_fanout, path);
Expand Down Expand Up @@ -2914,7 +2914,7 @@ static void parse_new_tag(const char *arg)
"object %s\n"
"type %s\n"
"tag %s\n",
oid_to_hex(&oid), typename(type), t->name);
oid_to_hex(&oid), type_name(type), t->name);
if (tagger)
strbuf_addf(&new_data,
"tagger %s\n", tagger);
Expand Down Expand Up @@ -2985,10 +2985,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
die("Can't read object %s", oid_to_hex(oid));
if (type != OBJ_BLOB)
die("Object %s is a %s but a blob was expected.",
oid_to_hex(oid), typename(type));
oid_to_hex(oid), type_name(type));
strbuf_reset(&line);
strbuf_addf(&line, "%s %s %lu\n", oid_to_hex(oid),
typename(type), size);
type_name(type), size);
cat_blob_write(line.buf, line.len);
strbuf_release(&line);
cat_blob_write(buf, size);
Expand Down
2 changes: 1 addition & 1 deletion fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
ret = report(options, &tag->object,
FSCK_MSG_TAG_OBJECT_NOT_TAG,
"expected tag got %s",
typename(type));
type_name(type));
goto done;
}
}
Expand Down
2 changes: 1 addition & 1 deletion http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static void start_put(struct transfer_request *request)
git_zstream stream;

unpacked = read_sha1_file(request->obj->oid.hash, &type, &len);
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;

/* Set it up */
git_deflate_init(&stream, zlib_compression_level);
Expand Down
2 changes: 1 addition & 1 deletion log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static void show_one_mergetag(struct commit *commit,
int status, nth;
size_t payload_size, gpg_message_offset;

hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), oid.hash);
hash_sha1_file(extra->value, extra->len, type_name(OBJ_TAG), oid.hash);
tag = lookup_tag(&oid);
if (!tag)
return; /* error message already given */
Expand Down
Loading

0 comments on commit debca9d

Please sign in to comment.