path: root/abspath.c
diff options
authorJeff King <>2017-03-21 01:22:28 (GMT)
committerJunio C Hamano <>2017-03-21 18:12:53 (GMT)
commit116fb64e439d3744d0f244a51d7a6d714b7703ae (patch)
treeec3e23445081ec7fbb0bc5b711b5066ad83b42f5 /abspath.c
parent598019769cbaa38495b0c04297efa13d0f4a572e (diff)
prefix_filename: drop length parameter
This function takes the prefix as a ptr/len pair, but in every caller the length is exactly strlen(ptr). Let's simplify the interface and just take the string. This saves callers specifying it (and in some cases handling a NULL prefix). In a handful of cases we had the length already without calling strlen, so this is technically slower. But it's not likely to matter (after all, if the prefix is non-empty we'll allocate and copy it into a buffer anyway). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'abspath.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/abspath.c b/abspath.c
index fd30aff..c6f4809 100644
--- a/abspath.c
+++ b/abspath.c
@@ -246,9 +246,11 @@ char *absolute_pathdup(const char *path)
return strbuf_detach(&sb, NULL);
-const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
+const char *prefix_filename(const char *pfx, const char *arg)
static struct strbuf path = STRBUF_INIT;
+ size_t pfx_len = pfx ? strlen(pfx) : 0;
if (!pfx_len || is_absolute_path(arg))
return arg;