diff options
author | Jeff King <peff@peff.net> | 2017-03-20 21:22:28 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-21 11:12:53 -0700 |
commit | 116fb64e439d3744d0f244a51d7a6d714b7703ae (patch) | |
tree | ec3e23445081ec7fbb0bc5b711b5066ad83b42f5 /builtin/merge-file.c | |
parent | prefix_filename: move docstring to header file (diff) | |
download | tgif-116fb64e439d3744d0f244a51d7a6d714b7703ae.tar.xz |
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.c | 8 |
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) |