i18n.pathencoding
Subsystems (2)
RFC 1/1 i18n.pathencoding
Allow path names to be encoded in UTF-8 in the repository and checkout out as e.g. ISO-8859-1 in the working tree.
Introduce a config variable i18n.pathEncoding.
If empty, no re-encoding of path names is done.
Add t3911 to test encoding back and forth
The re-encoding is done in compat/reencode_pathname.c, where all file system functions like open(), stat(), readdir() are re-defined.
reencode_pathname.c includes all functionality from precompose_utf8.c, which should be removed
---
Please read this as an RFC, so there several limitations:
compat/reencode_pathname.h defines struct dirent_psx with d_name[2].
This is done to test renc_pn_readdir() in compat/reencode_pathname.c
test case t1450 failes even on one of my linux machines. At first glance
it looks as the same failure which has been sometimes observed on Mac OS X.
compat/precompose_utf8.[ch] had been integrated into reencode_pathname.[ch],
and should be removed.
The patch should work on v7.1.12, it's not tested against latest master
Comments are welcome.
Documentation/config.txt | 10 + Makefile | 11 +- builtin/init-db.c | 3 + cache.h | 1 + compat/reencode_pathname.c | 441 ++++++++++++++++++++++++++++++++++++++++++ compat/reencode_pathname.h | 72 +++++++ config.c | 3 + environment.c | 1 + git-compat-util.h | 20 +- parse-options.c | 2 +- t/t3911-i18n-filename-8859.sh | 251 ++++++++++++++++++++++++ wt-status.c | 21 +- 12 files changed, 827 insertions(+), 9 deletions(-) create mode 100644 compat/reencode_pathname.c create mode 100644 compat/reencode_pathname.h create mode 100755 t/t3911-i18n-filename-8859.sh
Documentation/config.txt +10 -0
@@ -1442,6 +1442,16 @@ i18n.logOutputEncoding:: Character encoding the commit messages are converted to when running 'git log' and friends. +i18n.pathEncoding:: + This option is only used by some implementations of git. + When "git init" sets core.supportspathencoding to true, + i18n.pathEncoding can be set to re-encode path names when + a working tree is checked out. + Path names may be e.g. encoded in ISO-8859-1 and are stored as + UTF-8 encoded in the repository. + When not set, the encoding of path names is the same in working tree + and the repository. + imap:: The configuration variables in the 'imap' section are described in linkgit:git-imap-send[1].
Makefile +10 -1
@@ -143,6 +143,9 @@ all:: # # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin). # +# Define PATH_ENCODING if the encoding of file names +# differs from the encoding in the git repo +# # Define NEEDS_SOCKET if linking with libc is not enough (SunOS, # Patrick Mauritz). #
@@ -595,6 +598,7 @@ LIB_H += compat/bswap.h LIB_H += compat/cygwin.h LIB_H += compat/mingw.h LIB_H += compat/obstack.h +LIB_H += compat/reencode_pathname.h LIB_H += compat/precompose_utf8.h LIB_H += compat/terminal.h LIB_H += compat/win32/dirent.h
@@ -932,6 +936,7 @@ ifeq ($(uname_S),OSF1) NO_NSEC = YesPlease endif ifeq ($(uname_S),Linux) + PATH_ENCODING = YesPlease NO_STRLCPY = YesPlease NO_MKSTEMPS = YesPlease HAVE_PATHS_H = YesPlease
@@ -999,7 +1004,7 @@ ifeq ($(uname_S),Darwin) NO_MEMMEM = YesPlease USE_ST_TIMESPEC = YesPlease HAVE_DEV_TTY = YesPlease - COMPAT_OBJS += compat/precompose_utf8.o + COMPAT_OBJS += compat/reencode_pathname.o BASIC_CFLAGS += -DPRECOMPOSE_UNICODE endif ifeq ($(uname_S),SunOS)
@@ -1591,6 +1596,10 @@ ifdef FREAD_READS_DIRECTORIES COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES COMPAT_OBJS += compat/fopen.o endif +ifdef PATH_ENCODING + COMPAT_CFLAGS += -DPATH_ENCODING + COMPAT_OBJS += compat/reencode_pathname.o +endif ifdef NO_SYMLINK_HEAD BASIC_CFLAGS += -DNO_SYMLINK_HEAD endif
builtin/init-db.c +3 -0
@@ -291,6 +291,9 @@ static int create_default_files(const char *template_path)if (!access (path,F_OK ))git_config_set ("core.ignorecase" ,"true" );probe_utf8_pathname_composition (path, len); +#ifdef PATH_ENCODING +git_config_set ("core.supportspathencoding" ,"true" ); +#endif }return reinit;
cache.h +1 -0
@@ -1160,6 +1160,7 @@ extern int user_ident_sufficiently_given(void);extern const char *git_commit_encoding;extern const char *git_log_output_encoding;extern const char *git_mailmap_file; +extern const char *wt_path_encoding;/* IO helper functions */ extern void maybe_flush_or_die (FILE *,const char *);
compat/reencode_pathname.c new file +441 -0
441 lines not on this page · raw message
compat/reencode_pathname.h new file +70 -0
70 lines not on this page · raw message
config.c +3 -0
@@ -775,6 +775,9 @@ static int git_default_i18n_config(const char *var, const char *value)if (!strcmp (var,"i18n.logoutputencoding" ))return git_config_string (&git_log_output_encoding, var, value); +if (!strcmp (var,"i18n.pathencoding" )) +return git_config_string (&wt_path_encoding, var, value); +/* Add other config variables here and to Documentation/config.txt. */ return 0 ; }
environment.c +1 -0
@@ -59,6 +59,7 @@ int grafts_replace_parents = 1;int core_apply_sparse_checkout;int merge_log_config =-1 ;int precomposed_unicode =-1 ;/* see probe_utf8_pathname_composition() */ +const char *wt_path_encoding =NULL ;struct startup_info *startup_info;unsigned long pack_size_limit_cfg;
git-compat-util.h +14 -6
@@ -153,13 +153,21 @@#endif #endif -/* used on Mac OS X */ -#ifdef PRECOMPOSE_UNICODE -#include "compat/precompose_utf8.h" +#if defined(PATH_ENCODING ) || defined(PRECOMPOSE_UNICODE ) +#include "compat/reencode_pathname.h" #else -#define precompose_str (in,i_nfd2nfc) -#define precompose_argv (c,v) -#define probe_utf8_pathname_composition (a,b) +#define reencode_argv (c,v) +#endif + +/* needed for Mac OS X */ +#ifndef PRECOMPOSE_UNICODE +#define probe_utf8_pathname_composition (a,b); +#endif + +#ifndef PATH_ENCODING +#define str_worktree2repolen (in, insz) (NULL) +#define str_repo2worktree (in) (NULL) +#define str_worktree2repo (in) (NULL)#endif #ifndef NO_LIBGEN_H
parse-options.c +1 -1
@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); } -precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }
t/t3911-i18n-filename-8859.sh new file +251 -0
251 lines not on this page · raw message
wt-status.c +20 -1
@@ -233,7 +233,26 @@ static void wt_status_print_trailer(struct wt_status *s)status_printf_ln (s,color (WT_STATUS_HEADER , s),"" ); } -#define quote_path quote_path_relative +#ifdef PATH_ENCODING +char *quote_path_repo2worktree (const char *in,int len, +struct strbuf *out,const char *prefix) +{ +const char *in_encoded = in; +char *in_worktree_encoded =str_repo2worktree (in); +char *ret; + (void )len; + +if (in_worktree_encoded) + in_encoded = in_worktree_encoded; + ret =quote_path_relative (in_encoded ,-1 , out, prefix); +free (in_worktree_encoded); +return ret; + +} +#define quote_path quote_path_repo2worktree +#else +#define quote_path quote_path_relative +#endif static void wt_status_print_unmerged_data (struct wt_status *s,struct string_list_item *it)
Signature · 1 line
1.7.12
Torsten Bögershausen skrev 2012-09-01 08.11:> Allow path names to be encoded in UTF-8 in the repository
Quoted 1 line
and checkout out as e.g. ISO-8859-1 in the working tree.
Ack for attempting this.
Did it myself if 2007, but times weren't ripe then, I guess.
Documentation/config.txt i18n.logOutputEncoding:: · line 1453
Quoted 9 lines
Documentation/config.txt +9
-0+i18n.pathEncoding:: + This option is only used by some implementations of git. + When "git init" sets core.supportspathencoding to true, + i18n.pathEncoding can be set to re-encode path names when + a working tree is checked out. + Path names may be e.g. encoded in ISO-8859-1 and are stored as + UTF-8 encoded in the repository. + When not set, the encoding of path names is the same in working tree + and the repository.
"If set, then core.precomposeunicode is ignored on Mac OS X."
compat/reencode_pathname.c line 6
Quoted 12 lines
compat/reencode_pathname.c new file +6
-0@@ -0,0 +1,441 @@ +/* +* Converts pathnames from one encoding into another. +* The pathnames are stored as UTF-8 in the repository, +* and might be checkout out as e.g. ISO-8859-1 in the working tree +* +* On MacOS X decomposed unicode is converted into precomposed unicode.
, ignoring the setting of core.precomposeunicode.
[...]
Quoted 9 lines
compat/reencode_pathname.c new file +9
-0+*/ + +#define REENCODE_PATHNAME_C +#include "cache.h" +#include "utf8.h" +#include "reencode_pathname.h" + +#if defined(OLD_ICONV ) || (defined(__sun__) && !defined(_XPG6)) +typedef const char *iconv_ibp ;
compat/reencode_pathname.c line 25
Quoted 10 lines
compat/reencode_pathname.c new file +10
-0+#else +typedef char *iconv_ibp ; +#endif + +const static char *repo_path_encoding ="UTF-8" ; + +static iconv_t iconv_open_or_die (const char *tocode,const char *fromcode) +{ +iconv_t my_iconv; + my_iconv =iconv_open (tocode, fromcode);
join these two lines
Quoted 25 lines
compat/reencode_pathname.c new file +25
-0+if (my_iconv == (iconv_t) -1 ) +die_errno (_ ("iconv_open(%s,%s) failed" ), tocode, fromcode); +return my_iconv; +} + +static size_t has_non_ascii (const char *s,size_t maxlen,size_t *strlen_c) +{ +const uint8_t *ptr = (const uint8_t *)s; +size_t strlen_chars =0 ; +size_t ret =0 ; + +if (!ptr || !*ptr) +return 0 ; + +while (*ptr && maxlen) { +if (*ptr &0x80 ) + ret++; + strlen_chars++; + ptr++; + maxlen--; + } +if (strlen_c) + *strlen_c = strlen_chars; + +return ret;
compat/reencode_pathname.c line 60
Quoted 10 lines
compat/reencode_pathname.c new file +10
-0+} + +#ifdef PRECOMPOSE_UNICODE +void probe_utf8_pathname_composition (char *path,int len) +{ +static const char *auml_nfc ="\xc3\xa4" ; +static const char *auml_nfd ="\x61\xcc\x88" ; +int output_fd; +if (precomposed_unicode !=-1 ) +return ;/* We found it defined in the global config, respect it */
a bland line here would be nice
Quoted 16 lines
compat/reencode_pathname.c new file +16
-0+strcpy (path + len, auml_nfc); + output_fd =open (path,O_CREAT |O_EXCL |O_RDWR ,0600 ); +if (output_fd >=0 ) { +close (output_fd); +strcpy (path + len, auml_nfd); +/* Indicate to the user, that we can configure it to true */ +if (!access (path,R_OK )) +git_config_set ("core.precomposeunicode" ,"false" ); +/* To be backward compatible, set precomposed_unicode to 0 */ + precomposed_unicode =0 ; +strcpy (path + len, auml_nfc); +if (unlink (path)) +die_errno (_ ("failed to unlink '%s'" ), path); + } +} +#endif
[...]
compat/reencode_pathname.c line 235
Quoted 13 lines
compat/reencode_pathname.c new file +13
-0+struct dirent_psx *renc_pn_readdir (RENC_FN_DIR *renc_pn_dir) +{ +struct dirent *res; + res =readdir (renc_pn_dir->dirp); +if (res) { +size_t namelenz =strlen (res->d_name) +1 ;/* \0 */ +size_t new_len_needed =0 ; +int ret_errno = errno; + + renc_pn_dir->dirent_utf8->d_ino = res->d_ino; + renc_pn_dir->dirent_utf8->d_type = res->d_type; + do { + if (new_len_needed > renc_pn_dir->dirent_utf8->max_name_len) {
indent
[...]
environment.c int grafts_replace_parents = 1; · line 62
Quoted 9 lines
environment.c +1
-0@@ -59,6 +59,7 @@ int grafts_replace_parents = 1;int core_apply_sparse_checkout;int merge_log_config =-1 ;int precomposed_unicode =-1 ;/* see probe_utf8_pathname_composition() */ +const char *wt_path_encoding =NULL ;
indent
Quoted 194 lines
environment.c +0
-0struct startup_info *startup_info;unsigned long pack_size_limit_cfg;git-compat-util.h +14
-6@@ -153,13 +153,21 @@#endif #endif -/* used on Mac OS X */ -#ifdef PRECOMPOSE_UNICODE -#include "compat/precompose_utf8.h" +#if defined(PATH_ENCODING ) || defined(PRECOMPOSE_UNICODE ) +#include "compat/reencode_pathname.h" #else -#define precompose_str (in,i_nfd2nfc) -#define precompose_argv (c,v) -#define probe_utf8_pathname_composition (a,b) +#define reencode_argv (c,v) +#endif + +/* needed for Mac OS X */ +#ifndef PRECOMPOSE_UNICODE +#define probe_utf8_pathname_composition (a,b); +#endif + +#ifndef PATH_ENCODING +#define str_worktree2repolen (in, insz) (NULL) +#define str_repo2worktree (in) (NULL) +#define str_worktree2repo (in) (NULL)#endif #ifndef NO_LIBGEN_H parse-options.c +1
-1@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); } -precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }t/t3911-i18n-filename-8859.sh new file +140
-0@@ -0,0 +1,251 @@ +#!/bin/sh +# +# Copyright (c) 2010 Torsten Bögershausen +# + +test_description='file system encodings UTF-8 ISO8859-1' + +. ./test-lib.sh + +fname_UTF_8=`printf '\303\206\302\242'` +fname_ISO8859_1=`printf '\306\242'` +Euro_utf8=`printf '\342\202\254'` +supportspathencoding=`git config core.supportspathencoding` || : + + +add_file_dir_link() { + local bname=$1 + local fname=$2 + test_expect_success "add file $fname.f $bname" ' + git checkout master && + git checkout -b add_f_$bname && + >$fname.f && + git add $fname.f && + git commit -m "add fname" + ' + + test_expect_success "add dir $fname.d $bname" ' + git checkout master && + git checkout -b add_d_$bname && + mkdir $fname.d && + touch $fname.d/$fname.f && + git add $fname.d/$fname.f && + git commit -m "add fname.d/fname" + ' + + i=0 + for src in x $fname; do + for dst in x $fname; do + test_expect_success "add link $dst.l->$src.f on branch add_l_${i}_$bname" ' + git checkout master && + git checkout -b add_l_${i}_$bname && + ln -s $src.f $dst.l && + git add $dst.l && + git commit -m "add fname.l $i" + ' + i=$(($i+1)) + done + done +} + +test_expect_success "setup add rm x" ' + >x && + git add x && + git commit -m "1st commit" && + git rm x && + git commit -m "rm x" +' + +#combinations to be tested: +# UTF-8 -> ISO8859-1 +# ISO8859-1 -> UTF-8 + +if test "$supportspathencoding" +then + srcencodings="ISO8859-1 UTF-8" + for srcenc in $srcencodings + do + case $srcenc in + ISO8859-1) + dstenc=UTF-8 + ;; + UTF-8) + dstenc=ISO8859-1 + ;; + UTF-8-MAC) + dstenc=UTF-8 + ;; + *) + echo >&2 "Wrong encoding $srcenc" + exit 1 + ;; + esac + eval fname_src=\$fname_$(echo $srcenc | sed -e 's/-/_/g' -e 's/_MAC//') + eval fname_dst=\$fname_$(echo $dstenc | sed -e 's/-/_/g') + test_expect_success "setup $srcenc" ' + git checkout master && + git config i18n.pathencoding $srcenc + ' + add_file_dir_link $srcenc $fname_src + + test_expect_success "setup $dstenc" ' + git checkout master && + echo "git checkout Master" >&2 + ls -l >&2 + git config i18n.pathencoding $dstenc + ' + + test_expect_success "checkout file $dstenc (was $srcenc)" ' + git checkout add_f_$srcenc + ' + + test_expect_success "exists file $dstenc (was $srcenc)" ' + test -f $fname_dst.f + ' + + test_expect_success "log file $dstenc (was $srcenc)" ' + git log $fname_dst.f + ' + + test_expect_success "git mv" ' + git checkout -b mv_file_$srcenc && + git mv $fname_dst.f XX.f && + git commit -m "git mv fname_dst.f XX.f" + ' + + test_expect_success "checkout dir $dstenc (was $srcenc)" ' + git checkout add_d_$srcenc + ' + + test_expect_success "exist dir $dstenc (was $srcenc)" ' + test -d $fname_dst.d + ' + + test_expect_success "log dir $dstenc (was $srcenc)" ' + git log $fname_dst.d + ' + + i=0 + for src in x $fname_dst; do + for dst in x $fname_dst; do + test_expect_success "checkout link $dst.l->$src.f branch add_l_${i}_$srcenc" ' + git checkout add_l_${i}_$srcenc + ' + test_expect_success "exist link $dst.l->$src.f branch add_l_${i}_$srcenc" ' + test -L $dst.l + ' + test_expect_success "log link $dst.l->$src.f branch add_l_${i}_$srcenc" ' + git log $dst.l + ' + test_expect_success "readlink $dst.l->$src.f branch add_l_${i}_$srcenc" '
t/t3911-i18n-filename-8859.sh line 150
Quoted 10 lines
t/t3911-i18n-filename-8859.sh new file +10
-0+ echo "$src.f" >expect && + readlink "$dst.l" > actual && + test_cmp expect actual && + rm expect actual + ' + i=$(($i+1)) + done + done + done + # Make sure that Euro sign can NOT be checked out in 8859
"8859-1", The euro sign exists in 8859-15.
Quoted 4 lines
t/t3911-i18n-filename-8859.sh new file +4
-0+ #fname_src=Euro + test_expect_success "setup UTF-8" ' + git checkout master && + git config i18n.pathencoding UTF-8
t/t3911-i18n-filename-8859.sh line 164
Quoted 10 lines
t/t3911-i18n-filename-8859.sh new file +10
-0+ ' + add_file_dir_link Euro $Euro_utf8 + + test_expect_success "setup ISO8859-1" ' + git checkout master && + rm -rf * && + git config i18n.pathencoding ISO8859-1 + ' + test_expect_success "checkout file Euro branch add_f_Euro" ' + git checkout add_f_Euro
Missing && ?
Quoted 29 lines
t/t3911-i18n-filename-8859.sh new file +29
-0+ echo * >actual && + echo "*" >expect && + test_cmp expect actual && + rm expect actual + ' + + test_expect_success "checkout dir Euro branch add_d_Euro" ' + rm -rf * && + test_must_fail git checkout add_d_Euro + ' + + test_expect_success "Cleanup" ' + git config i18n.pathencoding UTF-8 && + git checkout master && + rm -rf * && + git reset --hard && + git config i18n.pathencoding ISO8859-1 + ' + + test_expect_success "checkout link Euro.l->x.f branch add_l_1_Euro" ' + ! git checkout add_l_1_Euro + ' + + test_expect_success "No link Euro.l->x.f" ' + echo * >actual && + echo "*" >expect && + test_cmp expect actual && + rm expect actual + '
t/t3911-i18n-filename-8859.sh line 203
Quoted 10 lines
t/t3911-i18n-filename-8859.sh new file +10
-0+ + test_expect_success "Cleanup after Euro.l->x.f" ' + git config i18n.pathencoding UTF-8 && + git checkout master && + rm -rf * && + git reset --hard && + git config i18n.pathencoding ISO8859-1 + ' + + # Checkoing out a soft link pointing to a filename outside
"checking"
Quoted 23 lines
t/t3911-i18n-filename-8859.sh new file +23
-0+ # 8859-1 should fail + test_expect_failure "checkout link x.l->Euro.f branch add_l_2_Euro" ' + ! git checkout add_l_2_Euro + ' + + test_expect_success "No link x.f->Euro.l" ' + echo * >actual && + echo "*" >expect && + test_cmp expect actual && + rm expect actual + ' + + test_expect_success "Cleanup after link x.l->Euro.f branch" ' + git config i18n.pathencoding UTF-8 && + git checkout master && + rm -rf * && + git reset --hard && + git config i18n.pathencoding ISO8859-1 + ' + + test_expect_success "checkout link Euro.l->Euro.f branch add_l_3_Euro" ' + ! git checkout add_l_3_Euro + '
t/t3911-i18n-filename-8859.sh line 236
Quoted 10 lines
t/t3911-i18n-filename-8859.sh new file +10
-0+ + test_expect_success "No link Euro.l->Euro.f" ' + echo * >actual && + echo "*" >expect && + test_cmp expect actual && + rm expect actual + ' + +else + test_expect_success "setup 8859" '
"8859-1"
Quoted 5 lines
t/t3911-i18n-filename-8859.sh new file +5
-0+ git config i18n.pathencoding ISO8859-1 && + git checkout -b add_file_8859 && + > $fname_src.f && + git add $fname_src.f && + git commit -m "add fname_src" &&
t/t3911-i18n-filename-8859.sh line 251
Quoted 10 lines
t/t3911-i18n-filename-8859.sh new file +10
-0+ git config i18n.pathencoding UTF-8 && + rm -rf * && + git reset --hard + ' + test_expect_success "Silent support of pathencoding" ' + test_must_fail test -f $fname_UTF_8.f + ' +fi + +test_done
-- robin
Quoted 17 lines · Robin Rosenberg
Torsten Bögershausen skrev 2012-09-01 08.11:> Allow path names to be encoded in UTF-8 in the repository
Quoted 1 line
and checkout out as e.g. ISO-8859-1 in the working tree.
Ack for attempting this.
Did it myself if 2007, but times weren't ripe then, I guess.
Documentation/config.txt i18n.logOutputEncoding:: · line 1453
Quoted 9 lines
Documentation/config.txt +9
-0+i18n.pathEncoding:: + This option is only used by some implementations of git. + When "git init" sets core.supportspathencoding to true, + i18n.pathEncoding can be set to re-encode path names when + a working tree is checked out. + Path names may be e.g. encoded in ISO-8859-1 and are stored as + UTF-8 encoded in the repository. + When not set, the encoding of path names is the same in working tree + and the repository.
Quoted 1 line
"If set, then core.precomposeunicode is ignored on Mac OS X."
Thanks for comments,
I will integrate them (but don't expect that too soon ;-).
Before that I want to find & fix the performance issues, and the t1450 breakage asks for my attention again.
However, the combination of i18n.pathEncoding and core.precomposeunicode under Mac OS X needs to be clarified.
Mac OS X only allows unicode (an "Ä" encoded in ISO-8859-1 gives a single byte), and the HFS+ filesystem will list it as %C4.
So the i18.pathencoding does not make sence under Mac OS X, and should be ignored. It is not ignored today, since the characters use in t3911 are choosen to be both valid UTF-8 and ISO-8859-1 code points/characters, so that the feature can be tested on Mac OS X.
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 12 lines · Torsten Bögershausen
parse-options.c +1
-1@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); } -precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }
If you have to re-encode command line arguments, what about paths coming --stdin or a file? I guess that paths that are argument to an option are not re-encoded too, which may put git in an inconsistent state where it cannot compare paths to paths because some may be re-encoded above, some not.
Signature · 1 line
Duy
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 8 lines · Torsten Bögershausen
parse-options.c +0
-0@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); }
Quoted 7 lines
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 4 lines
parse-options.c +1
-1-precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }If you have to re-encode command line arguments, what about paths coming --stdin or a file?
That problem is inherited from the MacOS precompose topic this one builds on. Not that it is unimportant to fix, though.
Quoted 19 lines · Junio C Hamano
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 8 lines · Torsten Bögershausen
parse-options.c +0
-0@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); }Quoted 7 lines
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 4 lines
parse-options.c +1
-1-precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }If you have to re-encode command line arguments, what about paths coming --stdin or a file?
Quoted 2 lines
That problem is inherited from the MacOS precompose topic this one builds on. Not that it is unimportant to fix, though.
Thanks for the comments,
(actually the precompose feature started as "fully" reencode, and was downsized to only do the readdir() and argv[] conversion)
This leads to 2 questions:
a) Do we want the reencode feature in git, so that I continue to work on it? From a performance point of view that would probably OK:
The "git status" on a linux tree was slightly slower on my PC when measured with time. From the user experience there was not a difference.
b) If yes,
I have to admit that I don't use paths from --stdin or file so much, except "git am" or "git format-patch"
Which commands are affected?
Quoted 5 lines · Torsten Bögershausen
This leads to 2 questions:
a) Do we want the reencode feature in git, so that I continue to work on it? From a performance point of view that would probably OK:
The "git status" on a linux tree was slightly slower on my PC when measured with time. From the user experience there was not a difference.
I am not fundamentally opposed to such a change, as long as the change does not affect performance at all when the feature is not used, and the resulting code does not become too ugly.
Use of the "reencode" feature may have to make things slow, but you have to spend some cycle to do what the feature has to do anyway, so...
Quoted 4 lines
b) If yes,
I have to admit that I don't use paths from --stdin or file so much, except "git am" or "git format-patch"
Which commands are affected?
$ git grep -l -e '--stdin' Documentation/git*
may be a good starting point.
Quoted 16 lines · Junio C Hamano
Quoted 5 lines · Torsten Bögershausen
This leads to 2 questions:
a) Do we want the reencode feature in git, so that I continue to work on it? From a performance point of view that would probably OK:
The "git status" on a linux tree was slightly slower on my PC when measured with time. From the user experience there was not a difference.I am not fundamentally opposed to such a change, as long as the change does not affect performance at all when the feature is not used, and the resulting code does not become too ugly.
Use of the "reencode" feature may have to make things slow, but you have to spend some cycle to do what the feature has to do anyway, so...
Quoted 8 lines
Quoted 4 lines
b) If yes,
I have to admit that I don't use paths from --stdin or file so much, except "git am" or "git format-patch"
Which commands are affected?$ git grep -l -e '--stdin' Documentation/git*may be a good starting point.
------------------------------
I'll have a look into the --stdin stuff later, thanks Junio
-------------------------------
And here some benchmarks on my PC,
first run is using git v1.7.12,
second run with i18n.pathencoding applied
===================
for f in 1 2 3 4 5; do time git status ; done 2>&1 | egrep "^user|^real|^sys"
real 0m0.492s user 0m0.300s sys 0m0.200s real 0m0.448s user 0m0.260s sys 0m0.190s real 0m0.443s user 0m0.250s sys 0m0.200s real 0m0.451s user 0m0.260s sys 0m0.190s real 0m0.429s user 0m0.230s sys 0m0.200s ========================= for f in 1 2 3 4 5; do time ~/projects/git/tb.localfname/git status ; done 2>&1 | egrep "^user|^real|^sys" real 0m0.580s user 0m0.320s sys 0m0.230s real 0m0.461s user 0m0.260s sys 0m0.200s real 0m0.463s user 0m0.250s sys 0m0.220s real 0m0.445s user 0m0.290s sys 0m0.160s real 0m0.443s user 0m0.240s sys 0m0.210s
=======================
It seems that we have a little penalty on performance. I'll have a look at the readdir() function.
Quoted 14 lines · Junio C Hamano
Quoted 5 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Torsten Bögershausen
parse-options.c +0
-0@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); }Quoted 7 lines
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 4 lines
parse-options.c +1
-1-precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }If you have to re-encode command line arguments, what about paths coming --stdin or a file?
Quoted 2 lines
That problem is inherited from the MacOS precompose topic this one builds on. Not that it is unimportant to fix, though.
On fixing that. 76759c7 describes the change as:
The argv[] conversion allows to use the TAB filename completion done by the shell on command line. It tolerates other tools which use readdir() to feed decomposed file names into git.
How come git's internal conversion helps TAB filename completion, which is done before git is executed? If it's the pathname output from git that helps tab completion, then perhaps we should convert at output time rather than input, by piping all the output through a converter when we know the output is textual. That keeps all paths in the same encoding internally (I hope).
Just two cents. And I'm not against i18n.pathencoding or anything.
Signature · 1 line
Duy
Quoted 18 lines · Nguyen Thai Ngoc Duy
Quoted 14 lines · Junio C Hamano
Quoted 5 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Torsten Bögershausen
parse-options.c +0
-0@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); }Quoted 7 lines
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 4 lines
parse-options.c +1
-1-precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }If you have to re-encode command line arguments, what about paths coming --stdin or a file?
Quoted 2 lines
That problem is inherited from the MacOS precompose topic this one builds on. Not that it is unimportant to fix, though.
Quoted 8 lines
On fixing that. 76759c7 describes the change as:
The argv[] conversion allows to use the TAB filename completion done by the shell on command line. It tolerates other tools which use
readdir()to feed decomposed file names into git.How come git's internal conversion helps TAB filename completion, which is done before git is executed?
Because the shell use readdir() itself when <TAB> is pressed
$echo Bö > Bö
$echo Ba > Ba
$ls
Bo ̈
Ba
# The terminal program of Mac OS shows the decomposed "ö" correctly, "Bö" is shown as "Bö", while xterm shows "Bö" as "Bo ̈", that is "o" followod by a "combining diaresis".
The shell seems to do the same:
to add Bö to git,
$git add Bo<TAB>
needs to be used.
And as a result, the sheel will pass the "o" in decomposed unicode to git, which is corrected in precompose_argv().
Quoted 40 lines · Torsten Bögershausen
Quoted 18 lines · Nguyen Thai Ngoc Duy
Quoted 14 lines · Junio C Hamano
Quoted 5 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Torsten Bögershausen
parse-options.c +0
-0@@ -476,7 +476,7 @@ int parse_options(int argc, const char **argv, const char *prefix,usage_with_options (usagestr, options); }Quoted 7 lines
parse-options.c int parse_options(int argc, const char **argv, const char *prefix, · line 481
Quoted 4 lines
parse-options.c +1
-1-precompose_argv (argc, argv); +reencode_argv (argc, argv);return parse_options_end (&ctx); }If you have to re-encode command line arguments, what about paths coming --stdin or a file?
Quoted 2 lines
That problem is inherited from the MacOS precompose topic this one builds on. Not that it is unimportant to fix, though.
Quoted 8 lines
On fixing that. 76759c7 describes the change as:
The argv[] conversion allows to use the TAB filename completion done by the shell on command line. It tolerates other tools which use
readdir()to feed decomposed file names into git.How come git's internal conversion helps TAB filename completion, which is done before git is executed?
Because the shell use
readdir()itself when <TAB> is pressed$echo Bö > Bö
$echo Ba > Ba
$ls
Bo ̈
Ba# The terminal program of Mac OS shows the decomposed "ö" correctly, "Bö" is shown as "Bö", while xterm shows "Bö" as "Bo ̈", that is "o" followod by a "combining diaresis".
Quoted 8 lines
The shell seems to do the same:
to add Bö to git,$git add Bo<TAB>
needs to be used.
And as a result, the sheel will pass the "o" in decomposed unicode to git, which is corrected inprecompose_argv().
Well explained; this does not have anything to do with what Git outputs.