[PATCH v2 10/10] object.c: move type_from_string() code to its last user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In commits leading up to this one various errors have been improved
and bugs fixed by moving various callers to
type_from_string_gently(). Now that there's no caller left of
type_from_string() except cat-file.c, let's move this function over to
it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 builtin/cat-file.c | 4 +++-
 object.c           | 9 ---------
 object.h           | 1 -
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 46fc7a32ba..20c60045f6 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -154,7 +154,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
 		break;
 
 	case 0:
-		exp_type_id = type_from_string(exp_type);
+		exp_type_id = type_from_string_gently(exp_type, strlen(exp_type));
+		if (exp_type_id < 0)
+			die(_("invalid object type \"%s\""), exp_type);
 		if (exp_type_id == OBJ_BLOB) {
 			struct object_id blob_oid;
 			if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
diff --git a/object.c b/object.c
index 8f3ddfc8f4..3c962da6c9 100644
--- a/object.c
+++ b/object.c
@@ -49,15 +49,6 @@ enum object_type type_from_string_gently(const char *str, size_t len)
 	return -1;
 }
 
-enum object_type type_from_string(const char *str)
-{
-	size_t len = strlen(str);
-	enum object_type ret = type_from_string_gently(str, len);
-	if (ret < 0)
-		die(_("invalid object type \"%s\""), str);
-	return ret;
-}
-
 /*
  * Return a numerical hash value between 0 and n-1 for the object with
  * the specified sha1.  n must be a power of 2.  Please note that the
diff --git a/object.h b/object.h
index a4eca10d72..85e7491815 100644
--- a/object.h
+++ b/object.h
@@ -94,7 +94,6 @@ struct object {
 
 const char *type_name(unsigned int type);
 enum object_type type_from_string_gently(const char *str, size_t len);
-enum object_type type_from_string(const char *str);
 
 /*
  * Return the current number of buckets in the object hashmap.
-- 
2.31.1.723.ga5d7868e4a





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux