summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-02 18:01:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-07-03 17:22:37 (GMT)
commit8c135ea260a84ef71899c8bd23bb39425288f9fe (patch)
treedbf61be43a0bb027ff1f02a5eea02e6f0bfc67fc /sha1_name.c
parentf01cc14c3c70cfd820114505d2ddc153c28f6f89 (diff)
downloadgit-8c135ea260a84ef71899c8bd23bb39425288f9fe.zip
git-8c135ea260a84ef71899c8bd23bb39425288f9fe.tar.gz
git-8c135ea260a84ef71899c8bd23bb39425288f9fe.tar.bz2
sha1_name.c: get rid of get_sha1_with_mode_1()
The only external caller is setup.c that tries to give a nicer error message when an object name is misspelt (e.g. "HEAD:cashe.h"). Retire it and give the caller a dedicated and more intuitive API function maybe_die_on_misspelt_object_name(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 10932bf..df583c2 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1125,12 +1125,24 @@ static int get_sha1_with_context_1(const char *name, unsigned char *sha1,
return ret;
}
-int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
- int only_to_die, const char *prefix)
+/*
+ * Call this function when you know "name" given by the end user must
+ * name an object but it doesn't; the function _may_ die with a better
+ * diagnostic message than "no such object 'name'", e.g. "Path 'doc' does not
+ * exist in 'HEAD'" when given "HEAD:doc", or it may return in which case
+ * you have a chance to diagnose the error further.
+ */
+void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
{
struct object_context oc;
- int ret;
- ret = get_sha1_with_context_1(name, sha1, &oc, only_to_die, prefix);
+ unsigned char sha1[20];
+ get_sha1_with_context_1(name, sha1, &oc, 1, prefix);
+}
+
+int get_sha1_with_mode(const char *str, unsigned char *sha1, unsigned *mode)
+{
+ struct object_context oc;
+ int ret = get_sha1_with_context_1(str, sha1, &oc, 0, NULL);
*mode = oc.mode;
return ret;
}