git-commit-vandalism/builtin
Torsten Bögershausen 76759c7dff git on Mac OS and precomposed unicode
Mac OS X mangles file names containing unicode on file systems HFS+,
VFAT or SAMBA.  When a file using unicode code points outside ASCII
is created on a HFS+ drive, the file name is converted into
decomposed unicode and written to disk. No conversion is done if
the file name is already decomposed unicode.

Calling open("\xc3\x84", ...) with a precomposed "Ä" yields the same
result as open("\x41\xcc\x88",...) with a decomposed "Ä".

As a consequence, readdir() returns the file names in decomposed
unicode, even if the user expects precomposed unicode.  Unlike on
HFS+, Mac OS X stores files on a VFAT drive (e.g. an USB drive) in
precomposed unicode, but readdir() still returns file names in
decomposed unicode.  When a git repository is stored on a network
share using SAMBA, file names are send over the wire and written to
disk on the remote system in precomposed unicode, but Mac OS X
readdir() returns decomposed unicode to be compatible with its
behaviour on HFS+ and VFAT.

The unicode decomposition causes many problems:

- The names "git add" and other commands get from the end user may
  often be precomposed form (the decomposed form is not easily input
  from the keyboard), but when the commands read from the filesystem
  to see what it is going to update the index with already is on the
  filesystem, readdir() will give decomposed form, which is different.

- Similarly "git log", "git mv" and all other commands that need to
  compare pathnames found on the command line (often but not always
  precomposed form; a command line input resulting from globbing may
  be in decomposed) with pathnames found in the tree objects (should
  be precomposed form to be compatible with other systems and for
  consistency in general).

- The same for names stored in the index, which should be
  precomposed, that may need to be compared with the names read from
  readdir().

NFS mounted from Linux is fully transparent and does not suffer from
the above.

As Mac OS X treats precomposed and decomposed file names as equal,
we can

 - wrap readdir() on Mac OS X to return the precomposed form, and

 - normalize decomposed form given from the command line also to the
   precomposed form,

to ensure that all pathnames used in Git are always in the
precomposed form.  This behaviour can be requested by setting
"core.precomposedunicode" configuration variable to true.

The code in compat/precomposed_utf8.c implements basically 4 new
functions: precomposed_utf8_opendir(), precomposed_utf8_readdir(),
precomposed_utf8_closedir() and precompose_argv().  The first three
are to wrap opendir(3), readdir(3), and closedir(3) functions.

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.

When creating a new git repository with "git init" or "git clone",
"core.precomposedunicode" will be set "false".

The user needs to activate this feature manually.  She typically
sets core.precomposedunicode to "true" on HFS and VFAT, or file
systems mounted via SAMBA.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-08 22:03:46 -07:00
..
add.c Merge branch 'js/add-e-submodule-fix' 2012-02-10 14:08:27 -08:00
annotate.c
apply.c i18n: apply: split to fix a partial i18n message 2012-06-01 07:43:10 -07:00
archive.c Revert "upload-archive: use start_command instead of fork" 2011-11-15 15:39:33 -08:00
bisect--helper.c bisect: introduce support for --no-checkout option. 2011-08-04 15:34:32 -07:00
blame.c builtin/blame.c: Fix a "Using plain integer as NULL pointer" warning 2012-05-14 10:19:42 -07:00
branch.c branch: remove lego in i18n tracking info strings 2012-05-04 09:12:24 -07:00
bundle.c Teach progress eye-candy to fetch_refs_from_bundle() 2011-09-19 11:07:21 -07:00
cat-file.c cat-file: use streaming API to print blobs 2012-03-07 09:07:38 -08:00
check-attr.c
check-ref-format.c Change check_refname_format() to reject unnormalized refnames 2011-10-05 13:45:30 -07:00
checkout-index.c
checkout.c Merge branch 'ap/checkout-no-progress-for-non-tty' 2012-05-25 12:06:34 -07:00
clean.c Documentation: clarify "git clean -e <pattern>" 2011-08-28 23:47:55 -07:00
clone.c Merge branch 'ef/maint-1.7.6-clone-progress-fix' into ef/maint-clone-progress-fix 2012-05-07 12:35:36 -07:00
column.c Add column layout skeleton and git-column 2012-04-27 09:26:37 -07:00
commit-tree.c Merge branch 'jc/show-sig' 2012-01-06 12:44:07 -08:00
commit.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
config.c config: remove useless assignment 2012-03-28 15:19:17 -07:00
count-objects.c add description parameter to OPT__VERBOSE 2010-11-15 09:56:51 -08:00
describe.c describe: Refresh the index when run with --dirty 2011-08-11 13:03:35 -07:00
diff-files.c Convert struct diff_options to use struct pathspec 2011-02-03 12:28:15 -08:00
diff-index.c Submodules: Use "ignore" settings from .gitmodules too for diff and status 2010-08-09 09:11:44 -07:00
diff-tree.c
diff.c drop casts from users EMPTY_TREE_SHA1_BIN 2012-03-23 13:52:05 -07:00
fast-export.c Merge branch 'js/maint-fast-export-mark-error' 2012-06-12 07:27:50 -07:00
fetch-pack.c Merge branch 'jk/fetch-pack-remove-dups-optim' 2012-05-29 13:09:08 -07:00
fetch.c Merge branch 'nd/i18n' 2012-05-02 13:51:35 -07:00
fmt-merge-msg.c Merge branch 'jc/fmt-merge-msg-people' 2012-06-12 08:33:30 -07:00
for-each-ref.c
fsck.c fsck: use streaming API for writing lost-found blobs 2012-03-07 09:07:39 -08:00
gc.c gc: use argv-array for sub-commands 2012-04-18 16:17:42 -07:00
grep.c Merge branch 'rs/maint-grep-F' 2012-05-25 12:04:19 -07:00
hash-object.c index_fd(): turn write_object and format_check arguments into one flag 2011-05-09 11:58:19 -07:00
help.c Merge branch 'nd/columns' 2012-05-03 15:13:31 -07:00
index-pack.c Merge branch 'nd/threaded-index-pack' 2012-05-14 11:50:40 -07:00
init-db.c git on Mac OS and precomposed unicode 2012-07-08 22:03:46 -07:00
log.c format-patch: do not use bogus email addresses in message ids 2012-05-24 20:50:19 -07:00
ls-files.c Merge branch 'cb/common-prefix-unification' 2011-10-10 15:56:17 -07:00
ls-remote.c Merge branch 'jc/ls-remote-short-help' 2011-10-05 12:36:26 -07:00
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c Documentation: update to git-merge-base --octopus 2011-04-15 10:13:52 -07:00
merge-file.c remove superfluous newlines in error messages 2012-04-30 15:45:51 -07:00
merge-index.c
merge-ours.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
merge-recursive.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
merge-tree.c sparse: Fix an "symbol 'merge_file' not decared" warning 2011-04-11 10:35:25 -07:00
merge.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
mktag.c read_sha1_file(): get rid of read_sha1_file_repl() madness 2011-05-15 15:23:33 -07:00
mktree.c Merge "Move 'builtin-*' into a 'builtin/' subdirectory" 2011-11-10 09:10:51 -08:00
mv.c Merge branch 'jk/maint-mv' 2011-12-19 16:05:34 -08:00
name-rev.c Sync with 1.7.7.4 2011-11-18 11:30:02 -08:00
notes.c Merge branch 'nd/war-on-nul-in-commit' 2011-12-22 11:27:26 -08:00
pack-objects.c pack-objects: refactor write_object() into helper functions 2012-05-18 14:22:15 -07:00
pack-redundant.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
pack-refs.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
patch-id.c
prune-packed.c fix deletion of .git/objects sub-directories in git-prune/repack 2012-03-07 10:24:33 -08:00
prune.c fix deletion of .git/objects sub-directories in git-prune/repack 2012-03-07 10:24:33 -08:00
push.c Merge branch 'mm/simple-push' 2012-05-02 13:51:24 -07:00
read-tree.c Teach read-tree the -n|--dry-run option 2011-05-25 15:04:25 -07:00
receive-pack.c Merge branch 'cb/receive-pack-keep-errors' 2012-02-20 00:14:50 -08:00
reflog.c
remote-ext.c Remove unused variables 2011-03-22 11:43:27 -07:00
remote-fd.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
remote.c remote: fix typo 2012-05-20 18:48:10 -07:00
replace.c Convert many resolve_ref() calls to read_ref*() and ref_exists() 2011-11-13 12:21:06 -08:00
rerere.c rerere: libify rerere_clear() and rerere_gc() 2011-05-08 12:55:34 -07:00
reset.c reset: update cache-tree data when appropriate 2011-12-06 15:13:39 -08:00
rev-list.c Merge branch 'jk/maint-reflog-walk-count-vs-time' 2012-05-11 11:30:08 -07:00
rev-parse.c rev-parse --show-prefix: add in trailing newline 2012-04-10 09:25:35 -07:00
revert.c Merge branch 'cc/fix-missing-va-end-in-revert' into maint 2012-05-10 10:32:43 -07:00
rm.c i18n: git-rm basic messages 2011-03-09 23:52:56 -08:00
send-pack.c teach send-pack about --[no-]progress 2012-05-01 09:40:30 -07:00
shortlog.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
show-branch.c
show-ref.c
stripspace.c
symbolic-ref.c symbolic-ref --short: abbreviate the output unambiguously 2012-02-27 15:58:36 -08:00
tag.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
tar-tree.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
unpack-file.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
unpack-objects.c remove superfluous newlines in error messages 2012-04-30 15:45:51 -07:00
update-index.c update-index: upgrade/downgrade on-disk index version 2012-04-04 09:57:50 -07:00
update-ref.c
update-server-info.c update-server-info: respect core.bigfilethreshold 2012-03-07 09:07:39 -08:00
upload-archive.c upload-archive: use start_command instead of fork 2011-11-21 14:32:40 -08:00
var.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
verify-pack.c verify-pack: use index-pack --verify 2011-06-05 22:45:38 -07:00
verify-tag.c verify-tag: Parse GPG configuration options. 2012-03-08 14:03:07 -08:00
write-tree.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00