summaryrefslogtreecommitdiff
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-20 21:22:28 -0400
committerJunio C Hamano <gitster@pobox.com>2017-03-21 11:12:53 -0700
commit116fb64e439d3744d0f244a51d7a6d714b7703ae (patch)
treeec3e23445081ec7fbb0bc5b711b5066ad83b42f5 /diff-no-index.c
parent598019769cbaa38495b0c04297efa13d0f4a572e (diff)
downloadgit-116fb64e439d3744d0f244a51d7a6d714b7703ae.tar.gz
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-no-index.c')
-rw-r--r--diff-no-index.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index df762fd0f7..5f7317ced9 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -236,7 +236,7 @@ static void fixup_paths(const char **path, struct strbuf *replacement)
void diff_no_index(struct rev_info *revs,
int argc, const char **argv)
{
- int i, prefixlen;
+ int i;
const char *paths[2];
struct strbuf replacement = STRBUF_INIT;
const char *prefix = revs->prefix;
@@ -257,7 +257,6 @@ void diff_no_index(struct rev_info *revs,
}
}
- prefixlen = prefix ? strlen(prefix) : 0;
for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i];
if (!strcmp(p, "-"))
@@ -266,8 +265,8 @@ void diff_no_index(struct rev_info *revs,
* path that is "-", spell it as "./-".
*/
p = file_from_standard_input;
- else if (prefixlen)
- p = xstrdup(prefix_filename(prefix, prefixlen, p));
+ else if (prefix)
+ p = xstrdup(prefix_filename(prefix, p));
paths[i] = p;
}