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>2020-04-10 22:44:45 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-11 00:47:36 +0300
commit6c7e6963c1b6d9a5344345d55dd537e4ab45158f (patch)
treeb66a00a9f0ef5a1ef76ad5bd5947cb6dcbfde85f
parentf5914f4b6bcdb517733c761fe5ba9d94471eb01d (diff)
config: drop useless length variable in write_pair()
We compute the length of a subset of a string, but then use that length only to feed a "%.*s" printf placeholder for the same string. We can just use "%s" to achieve the same thing. The variable became useless in cb891a5989 (Use a strbuf for building up section header and key/value pair strings., 2007-12-14), which swapped out a write() which _did_ use the length for a strbuf_addf() call. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--config.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/config.c b/config.c
index ff7998df46..7ea588a7e0 100644
--- a/config.c
+++ b/config.c
@@ -2545,7 +2545,6 @@ static ssize_t write_pair(int fd, const char *key, const char *value,
{
int i;
ssize_t ret;
- int length = strlen(key + store->baselen + 1);
const char *quote = "";
struct strbuf sb = STRBUF_INIT;
@@ -2564,8 +2563,7 @@ static ssize_t write_pair(int fd, const char *key, const char *value,
if (i && value[i - 1] == ' ')
quote = "\"";
- strbuf_addf(&sb, "\t%.*s = %s",
- length, key + store->baselen + 1, quote);
+ strbuf_addf(&sb, "\t%s = %s", key + store->baselen + 1, quote);
for (i = 0; value[i]; i++)
switch (value[i]) {