Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-21 04:22:28 +0300
committerJunio C Hamano <gitster@pobox.com>2017-03-21 21:12:53 +0300
commit116fb64e439d3744d0f244a51d7a6d714b7703ae (patch)
treeec3e23445081ec7fbb0bc5b711b5066ad83b42f5 /builtin/merge-file.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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-file.c')
-rw-r--r--builtin/merge-file.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 13e22a2f0b..63cd943587 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -28,7 +28,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
xmparam_t xmp = {{0}};
int ret = 0, i = 0, to_stdout = 0;
int quiet = 0;
- int prefixlen = 0;
struct option options[] = {
OPT_BOOL('p', "stdout", &to_stdout, N_("send results to standard output")),
OPT_SET_INT(0, "diff3", &xmp.style, N_("use a diff3 based merge"), XDL_MERGE_DIFF3),
@@ -65,11 +64,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
return error_errno("failed to redirect stderr to /dev/null");
}
- if (prefix)
- prefixlen = strlen(prefix);
-
for (i = 0; i < 3; i++) {
- const char *fname = prefix_filename(prefix, prefixlen, argv[i]);
+ const char *fname = prefix_filename(prefix, argv[i]);
if (!names[i])
names[i] = argv[i];
if (read_mmfile(mmfs + i, fname))
@@ -90,7 +86,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
if (ret >= 0) {
const char *filename = argv[0];
- const char *fpath = prefix_filename(prefix, prefixlen, argv[0]);
+ const char *fpath = prefix_filename(prefix, argv[0]);
FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
if (!f)