From 107642fe2661236f48b912480e090799e339c512 Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Sun, 15 Apr 2018 20:16:07 +0200 Subject: convert: add 'working-tree-encoding' attribute Git recognizes files encoded with ASCII or one of its supersets (e.g. UTF-8 or ISO-8859-1) as text files. All other encodings are usually interpreted as binary and consequently built-in Git text processing tools (e.g. 'git diff') as well as most Git web front ends do not visualize the content. Add an attribute to tell Git what encoding the user has defined for a given file. If the content is added to the index, then Git reencodes the content to a canonical UTF-8 representation. On checkout Git will reverse this operation. Signed-off-by: Lars Schneider Signed-off-by: Junio C Hamano --- convert.h | 1 + 1 file changed, 1 insertion(+) (limited to 'convert.h') diff --git a/convert.h b/convert.h index 65ab3e5167..1d9539ed0b 100644 --- a/convert.h +++ b/convert.h @@ -12,6 +12,7 @@ struct index_state; #define CONV_EOL_RNDTRP_WARN (1<<1) /* Warn if CRLF to LF to CRLF is different */ #define CONV_EOL_RENORMALIZE (1<<2) /* Convert CRLF to LF */ #define CONV_EOL_KEEP_CRLF (1<<3) /* Keep CRLF line endings as is */ +#define CONV_WRITE_OBJECT (1<<4) /* Content is written to the index */ extern int global_conv_flags_eol; -- cgit v1.2.3 From e92d6225361eba5ff34696122d1491dc7ace2a5a Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Sun, 15 Apr 2018 20:16:10 +0200 Subject: convert: add round trip check based on 'core.checkRoundtripEncoding' UTF supports lossless conversion round tripping and conversions between UTF and other encodings are mostly round trip safe as Unicode aims to be a superset of all other character encodings. However, certain encodings (e.g. SHIFT-JIS) are known to have round trip issues [1]. Add 'core.checkRoundtripEncoding', which contains a comma separated list of encodings, to define for what encodings Git should check the conversion round trip if they are used in the 'working-tree-encoding' attribute. Set SHIFT-JIS as default value for 'core.checkRoundtripEncoding'. [1] https://support.microsoft.com/en-us/help/170559/prb-conversion-problem-between-shift-jis-and-unicode Signed-off-by: Lars Schneider Signed-off-by: Junio C Hamano --- convert.h | 1 + 1 file changed, 1 insertion(+) (limited to 'convert.h') diff --git a/convert.h b/convert.h index 1d9539ed0b..765abfbd60 100644 --- a/convert.h +++ b/convert.h @@ -56,6 +56,7 @@ struct delayed_checkout { }; extern enum eol core_eol; +extern char *check_roundtrip_encoding; extern const char *get_cached_convert_stats_ascii(const struct index_state *istate, const char *path); extern const char *get_wt_convert_stats_ascii(const char *path); -- cgit v1.2.3