Skip to content

Commit be6bc04

Browse files
peffgitster
authored andcommitted
config: use git_config_string() for core.checkRoundTripEncoding
Since this code path was recently converted to check for a NULL value, it now behaves exactly like git_config_string(). We can shorten the code a bit by using that helper. Note that git_config_string() takes a const pointer, but our storage variable is non-const. We're better off making this "const", though, since the default value points to a string literal (and thus it would be an error if anybody tried to write to it). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0824879 commit be6bc04

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

config.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,12 +1551,8 @@ static int git_default_core_config(const char *var, const char *value,
15511551
return 0;
15521552
}
15531553

1554-
if (!strcmp(var, "core.checkroundtripencoding")) {
1555-
if (!value)
1556-
return config_error_nonbool(var);
1557-
check_roundtrip_encoding = xstrdup(value);
1558-
return 0;
1559-
}
1554+
if (!strcmp(var, "core.checkroundtripencoding"))
1555+
return git_config_string(&check_roundtrip_encoding, var, value);
15601556

15611557
if (!strcmp(var, "core.notesref")) {
15621558
if (!value)

convert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void convert_attrs(struct index_state *istate,
9292
struct conv_attrs *ca, const char *path);
9393

9494
extern enum eol core_eol;
95-
extern char *check_roundtrip_encoding;
95+
extern const char *check_roundtrip_encoding;
9696
const char *get_cached_convert_stats_ascii(struct index_state *istate,
9797
const char *path);
9898
const char *get_wt_convert_stats_ascii(const char *path);

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const char *excludes_file;
6464
enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
6565
enum eol core_eol = EOL_UNSET;
6666
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
67-
char *check_roundtrip_encoding = "SHIFT-JIS";
67+
const char *check_roundtrip_encoding = "SHIFT-JIS";
6868
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
6969
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
7070
enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;

0 commit comments

Comments
 (0)