aboutsummaryrefslogtreecommitdiffstats
path: root/convert.c
diff options
context:
space:
mode:
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/convert.c b/convert.c
index a8870baff3..c9a31eb4f0 100644
--- a/convert.c
+++ b/convert.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
@@ -322,6 +324,9 @@ static void trace_encoding(const char *context, const char *path,
struct strbuf trace = STRBUF_INIT;
int i;
+ if (!trace_want(&coe))
+ return;
+
strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding);
for (i = 0; i < len && buf; ++i) {
strbuf_addf(
@@ -345,30 +350,32 @@ static int check_roundtrip(const char *enc_name)
* space separated encodings (eg. "UTF-16, ASCII, CP1125").
* Search for the given encoding in that string.
*/
- const char *found = strcasestr(check_roundtrip_encoding, enc_name);
+ const char *encoding = check_roundtrip_encoding ?
+ check_roundtrip_encoding : "SHIFT-JIS";
+ const char *found = strcasestr(encoding, enc_name);
const char *next;
int len;
if (!found)
return 0;
next = found + strlen(enc_name);
- len = strlen(check_roundtrip_encoding);
+ len = strlen(encoding);
return (found && (
/*
- * check that the found encoding is at the
- * beginning of check_roundtrip_encoding or
- * that it is prefixed with a space or comma
+ * Check that the found encoding is at the beginning of
+ * encoding or that it is prefixed with a space or
+ * comma.
*/
- found == check_roundtrip_encoding || (
+ found == encoding || (
(isspace(found[-1]) || found[-1] == ',')
)
) && (
/*
- * check that the found encoding is at the
- * end of check_roundtrip_encoding or
- * that it is suffixed with a space or comma
+ * Check that the found encoding is at the end of
+ * encoding or that it is suffixed with a space
+ * or comma.
*/
- next == check_roundtrip_encoding + len || (
- next < check_roundtrip_encoding + len &&
+ next == encoding + len || (
+ next < encoding + len &&
(isspace(next[0]) || next[0] == ',')
)
));
@@ -956,7 +963,7 @@ int async_query_available_blobs(const char *cmd, struct string_list *available_p
while ((line = packet_read_line(process->out, NULL))) {
const char *path;
if (skip_prefix(line, "pathname=", &path))
- string_list_insert(available_paths, xstrdup(path));
+ string_list_insert(available_paths, path);
else
; /* ignore unknown keys */
}
@@ -979,9 +986,9 @@ done:
static struct convert_driver {
const char *name;
struct convert_driver *next;
- const char *smudge;
- const char *clean;
- const char *process;
+ char *smudge;
+ char *clean;
+ char *process;
int required;
} *user_convert, **user_convert_tail;
@@ -1028,7 +1035,7 @@ static int read_convert_config(const char *var, const char *value,
if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name)
return 0;
for (drv = user_convert; drv; drv = drv->next)
- if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
+ if (!xstrncmpz(drv->name, name, namelen))
break;
if (!drv) {
CALLOC_ARRAY(drv, 1);
@@ -1046,14 +1053,20 @@ static int read_convert_config(const char *var, const char *value,
* The command-line will not be interpolated in any way.
*/
- if (!strcmp("smudge", key))
+ if (!strcmp("smudge", key)) {
+ FREE_AND_NULL(drv->smudge);
return git_config_string(&drv->smudge, var, value);
+ }
- if (!strcmp("clean", key))
+ if (!strcmp("clean", key)) {
+ FREE_AND_NULL(drv->clean);
return git_config_string(&drv->clean, var, value);
+ }
- if (!strcmp("process", key))
+ if (!strcmp("process", key)) {
+ FREE_AND_NULL(drv->process);
return git_config_string(&drv->process, var, value);
+ }
if (!strcmp("required", key)) {
drv->required = git_config_bool(var, value);
@@ -1358,6 +1371,9 @@ void reset_parsed_attributes(void)
for (drv = user_convert; drv; drv = next) {
next = drv->next;
free((void *)drv->name);
+ free((void *)drv->smudge);
+ free((void *)drv->clean);
+ free((void *)drv->process);
free(drv);
}
user_convert = NULL;