Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: kb/rebasing-me…
Commits on Mar 15, 2012
  1. Rebasing merge to junio/next (38e1251)

    authored
    Previous rebasing merge: 2c05ddb
  2. Win32: fix detection of empty directories in is_dir_empty

    authored
    On Windows XP (not Win7), directories cannot be deleted while a find handle
    is open, causing "Deletion of directory '...' failed. Should I try again?"
    prompts.
    
    Prior to 19d1e75 "Win32: Unicode file name support (except dirent)",
    these failures were silently ignored due to strbuf_free in is_dir_empty
    resetting GetLastError to ERROR_SUCCESS.
    
    Close the find handle in is_dir_empty so that git doesn't block deletion
    of the directory even after all other applications have released it.
    
    Reported-by: John Chen <john0312@gmail.com>
    Signed-off-by: Karsten Blees <blees@dcon.de>
  3. Win32: patch Windows environment on startup

    authored
    Fix Windows specific environment settings on startup rather than checking
    for special values on every getenv call.
    
    As a side effect, this makes the patched environment (i.e. with properly
    initialized TMPDIR and TERM) available to child processes.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  4. Win32: keep the environment sorted

    authored
    The Windows environment is sorted, keep it that way for O(log n)
    environment access.
    
    Change compareenv to compare only the keys, so that it can be used to
    find an entry irrespective of the value.
    
    Change lookupenv to binary seach for an entry. Return one's complement of
    the insert position if not found (libc's bsearch returns NULL).
    
    Replace MSVCRT's getenv with a minimal do_getenv based on the binary search
    function.
    
    Change do_putenv to insert new entries at the correct position. Simplify
    the function by swapping if conditions and using memmove instead of for
    loops.
    
    Move qsort from make_environment_block to mingw_startup. We still need to
    sort on startup to make sure that the environment is sorted according to
    our compareenv function (while Win32 / CreateProcess requires the
    environment block to be sorted case-insensitively, CreateProcess currently
    doesn't enforce this, and some applications such as bash just don't care).
    
    Note that environment functions are _not_ thread-safe and are not required
    to be so by POSIX, the application is responsible for synchronizing access
    to the environment. MSVCRT's getenv and our new getenv implementation are
    better than that in that they are thread-safe with respect to other getenv
    calls as long as the environment is not modified. Git's indiscriminate use
    of getenv in background threads currently requires this property.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  5. Win32: use low-level memory allocation during initialization

    authored
    As of d41489a "Add more large blob test cases", git's high-level memory
    allocation functions (xmalloc, xmemdupz etc.) access the environment to
    simulate limited memory in tests (see 'getenv("GIT_ALLOC_LIMIT")' in
    memory_limit_check()). These functions should not be used before the
    environment is fully initialized (particularly not to initialize the
    environment itself).
    
    The current solution ('environ = NULL; ALLOC_GROW(environ...)') only works
    because MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it
    leaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-
    allocated) environments).
    
    Add our own set of malloc-or-die functions to be used in startup code.
    
    Also check the result of __wgetmainargs, which may fail if there's not
    enough memory for wide-char arguments and environment.
    
    This patch is in preparation of the sorted environment feature, which
    completely replaces MSVCRT's getenv() implementation.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  6. Win32: reduce environment array reallocations

    authored
    Move environment array reallocation from do_putenv to the respective
    callers. Keep track of the environment size in a global variable. Use
    ALLOC_GROW in mingw_putenv to reduce reallocations. Allocate a
    sufficiently sized environment array in make_environment_block to prevent
    reallocations.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  7. Win32: don't copy the environment twice when spawning child processes

    authored
    When spawning child processes via start_command(), the environment and all
    environment entries are copied twice. First by make_augmented_environ /
    copy_environ to merge with child_process.env. Then a second time by
    make_environment_block to create a sorted environment block string as
    required by CreateProcess.
    
    Move the merge logic to make_environment_block so that we only need to copy
    the environment once. This changes semantics of the env parameter: it now
    expects a delta (such as child_process.env) rather than a full environment.
    This is not a problem as the parameter is only used by start_command()
    (all other callers previously passed char **environ, and now pass NULL).
    
    The merge logic no longer xstrdup()s the environment strings, so do_putenv
    must not free them. Add a parameter to distinguish this from normal putenv.
    
    Remove the now unused make_augmented_environ / free_environ API.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  8. Win32: factor out environment block creation

    authored
    Signed-off-by: Karsten Blees <blees@dcon.de>
  9. Win32: unify environment function names

    authored
    Environment helper functions use random naming ('env' prefix or suffix or
    both, with or without '_'). Change to POSIX naming scheme ('env' suffix,
    no '_').
    
    Env_setenv has more in common with putenv than setenv. Change to do_putenv.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  10. Win32: move environment functions

    authored
    Move environment helper functions up so that they can be reused by
    mingw_getenv and mingw_spawnve_fd in subsequent patches.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  11. Win32: simplify internal mingw_spawn* APIs

    authored
    The only public spawn function that needs to tweak the environment is
    mingw_spawnvpe (called from start_command). Nevertheless, all internal
    spawn* functions take an env parameter and needlessly pass the global
    char **environ around. Remove the env parameter where it's not needed.
    
    This removes the internal mingw_execve abstraction, which is no longer
    needed.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  12. Win32: unify environment case-sensitivity

    authored
    The environment on Windows is case-insensitive. Some environment functions
    (such as unsetenv and make_augmented_environ) have always used case-
    sensitive comparisons instead, while others (getenv, putenv, sorting in
    spawn*) were case-insensitive.
    
    Prevent potential inconsistencies by using case-insensitive comparison in
    lookup_env (used by putenv, unsetenv and make_augmented_environ).
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  13. Win32: fix environment memory leaks

    authored
    All functions that modify the environment have memory leaks.
    
    Disable gitunsetenv in the Makefile and use env_setenv (via mingw_putenv)
    instead (this frees removed environment entries).
    
    Move xstrdup from env_setenv to make_augmented_environ, so that
    mingw_putenv no longer copies the environment entries (according to POSIX
    [1], "the string [...] shall become part of the environment"). This also
    fixes the memory leak in gitsetenv, which expects a POSIX compliant putenv.
    
    [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/putenv.html
    
    Note: This patch depends on taking control of char **environ and having
    our own mingw_putenv (both introduced in "Win32: Unicode environment
    (incoming)").
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  14. MinGW: disable legacy encoding tests

    authored
    On Windows, all native APIs are Unicode-based. It is impossible to pass
    legacy encoded byte arrays to a process via command line or environment
    variables. Disable the tests that try to do so.
    
    In t3901, most tests still work if we don't mess up the repository encoding
    in setup, so don't switch to ISO-8859-1 on MinGW.
    
    Note that i18n tests that do their encoding tricks via encoded files (such
    as t3900) are not affected by this.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  15. Win32: Unicode environment (incoming)

    authored
    Convert environment from UTF-16 to UTF-8 on startup.
    
    No changes to getenv() are necessary, as the MSVCRT version is implemented
    on top of char **environ.
    
    However, putenv / _wputenv from MSVCRT no longer work, for two reasons:
    1. they try to keep environ, _wenviron and the Win32 process environment
    in sync, using the default system encoding instead of UTF-8 to convert
    between charsets
    2. msysgit and MSVCRT use different allocators, memory allocated in git
    cannot be freed by the CRT and vice versa
    
    Implement mingw_putenv using the env_setenv helper function from the
    environment merge code.
    
    Note that in case of memory allocation failure, putenv now dies with error
    message (due to xrealloc) instead of failing with ENOMEM. As git assumes
    setenv / putenv to always succeed, this prevents it from continuing with
    incorrect settings.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  16. Win32: Unicode environment (outgoing)

    authored
    Convert environment from UTF-8 to UTF-16 when creating other processes.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  17. Win32: sync Unicode console output and file system

    authored
    Use the same Unicode conversion functions for file names and console
    conversions so that the file system and console output are in sync when
    checking out legacy encoded repositories (i.e. with invalid UTF-8 file
    names).
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  18. Win32: Unicode arguments (incoming)

    authored
    Convert command line arguments from UTF-16 to UTF-8 on startup.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  19. Win32: Unicode arguments (outgoing)

    authored
    Convert command line arguments from UTF-8 to UTF-16 when creating other
    processes.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  20. Unicode file name support (gitk and git-gui)

    authored
    Assumes file names in git tree objects are UTF-8 encoded.
    
    On most unix systems, the system encoding (and thus the TCL system
    encoding) will be UTF-8, so file names will be displayed correctly.
    
    On Windows, it is impossible to set the system encoding to UTF-8. Changing
    the TCL system encoding (via 'encoding system ...', e.g. in the startup
    code) is explicitly discouraged by the TCL docs.
    
    Change gitk and git-gui functions dealing with file names to always convert
    from and to UTF-8.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  21. Win32: Unicode file name support (dirent)

    authored
    Changes opendir/readdir to use Windows Unicode APIs and convert between
    UTF-8/UTF-16.
    
    Removes parameter checks that are already covered by xutftowcs_path. This
    changes detection of ENAMETOOLONG from MAX_PATH - 2 to MAX_PATH (matching
    is_dir_empty in mingw.c). If name + "/*" or the resulting absolute path is
    too long, FindFirstFile fails and errno is set through err_win_to_posix.
    
    Increases the size of dirent.d_name to accommodate the full
    WIN32_FIND_DATA.cFileName converted to UTF-8 (UTF-16 to UTF-8 conversion
    may grow by factor three in the worst case).
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  22. Win32: Unicode file name support (except dirent)

    authored
    Replaces Windows "ANSI" APIs dealing with file- or path names with their
    Unicode equivalent, adding UTF-8/UTF-16LE conversion as necessary.
    
    The dirent API (opendir/readdir/closedir) is updated in a separate commit.
    
    Adds trivial wrappers for access, chmod and chdir.
    
    Adds wrapper for mktemp (needed for both mkstemp and mkdtemp).
    
    The simplest way to convert a repository with legacy-encoded (e.g. Cp1252)
    file names to UTF-8 ist to checkout with an old msysgit version and
    "git add --all & git commit" with the new version.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  23. Win32: add Unicode conversion functions

    authored
    Add Unicode conversion functions to convert between Windows native UTF-16LE
    encoding to UTF-8 and back.
    
    To support repositories with legacy-encoded file names, the UTF-8 to UTF-16
    conversion function tries to create valid, unique file names even for
    invalid UTF-8 byte sequences, so that these repositories can be checked out
    without error.
    
    The current implementation leaves invalid UTF-8 bytes in range 0xa0 - 0xff
    as is (producing printable Unicode chars \u00a0 - \u00ff, equivalent to
    ISO-8859-1), and converts 0x80 - 0x9f to hex-code (\u0080 - \u009f are
    control chars).
    
    The Windows MultiByteToWideChar API was not used as it either drops invalid
    UTF-8 sequences (on Win2k/XP; producing non-unique or even empty file
    names) or converts them to the replacement char \ufffd (Vista/7; causing
    ERROR_INVALID_NAME in subsequent calls to file system APIs).
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  24. Win32: Thread-safe windows console output

    authored
    Winansi.c has many static variables that are accessed and modified from
    the [v][f]printf / fputs functions overridden in the file. This may cause
    multi threaded git commands that print to the console to produce corrupted
    output or even crash.
    
    Additionally, winansi.c doesn't override all functions that can be used to
    print to the console (e.g. fwrite, write, fputc are missing), so that ANSI
    escapes don't work properly for some git commands (e.g. git-grep).
    
    Instead of doing ANSI emulation in just a few wrapped functions on top of
    the IO API, let's plug into the IO system and take advantage of the thread
    safety inherent to the IO system.
    
    Redirect stdout and stderr to a pipe if they point to the console. A
    background thread reads from the pipe, handles ANSI escape sequences and
    UTF-8 to UTF-16 conversion, then writes to the console.
    
    The pipe-based stdout and stderr replacements must be set to unbuffered, as
    MSVCRT doesn't support line buffering and fully buffered streams are
    inappropriate for console output.
    
    Due to the byte-oriented pipe, ANSI escape sequences and multi-byte UTF-8
    sequences can no longer be expected to arrive in one piece. Replace the
    string-based ansi_emulate() with a simple stateful parser (this also fixes
    colored diff hunk headers, which were broken as of commit 2efcc97).
    
    Override isatty to return true for the pipes redirecting to the console.
    
    Exec/spawn obtain the original console handle to pass to the next process
    via winansi_get_osfhandle().
    
    All other overrides are gone, the default stdio implementations work as
    expected with the piped stdout/stderr descriptors.
    
    Global variables are either initialized on startup (single threaded) or
    exclusively modified by the background thread. Threads communicate through
    the pipe, no further synchronization is necessary.
    
    The background thread is terminated by disonnecting the pipe after flushing
    the stdio and pipe buffers. This doesn't work for anonymous pipes (created
    via CreatePipe), as DisconnectNamedPipe only works on the read end, which
    discards remaining data. Thus we have to setup the pipe manually, with the
    write end beeing the server (opened with CreateNamedPipe) and the read end
    the client (opened with CreateFile).
    
    Limitations: doesn't track reopened or duped file descriptors, i.e.:
    - fdopen(1/2) returns fully buffered streams
    - dup(1/2), dup2(1/2) returns normal pipe descriptors (i.e. isatty() =
      false, winansi_get_osfhandle won't return the original console handle)
    
    Currently, only the git-format-patch command uses xfdopen(xdup(1)) (see
    "realstdout" in builtin/log.c), but works well with these limitations.
    
    Many thanks to Atsushi Nakagawa <atnak@chejz.com> for suggesting and
    reviewing the thread-exit-mechanism.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  25. Revert "mingw.c: move definition of mingw_getenv down"

    authored
    This reverts commit 06bc4b7.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  26. Revert "Windows: teach getenv to do a case-sensitive search"

    authored
    This reverts commit df599e9.
    
    As of 5e9637c "i18n: add infrastructure for translating Git with gettext",
    eval_gettext uses MinGW envsubst.exe instead of git-sh-i18n--envsubst.exe
    for variable substitution. This breaks git-submodule.sh messages and tests,
    as envsubst.exe doesn't support case-sensitive environment lookup (the same
    is true for almost everything on Windows, including MSys and Cygwin tools).
    
    30a615a "Windows/i18n: rename $path to prevent clashes with $PATH" renames
    the conflicting variable in git-submodule.sh, so that it works on Windows
    (i.e. with case-insensitive environment, regardless of the toolset).
    
    Revert to the documented behaviour of case-insensitive environment on
    Windows.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  27. gitk: fix file name encoding in diff hunk headers

    authored
    Decode file names from system encoding in all diff hunk header lines, not
    just the first (i.e. print nice file names in 'rename from' / 'rename to' /
    'Binary files' lines, too).
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  28. git-gui: fix encoding in git-gui file browser

    authored
    Assume git tree objects (i.e. output of git-ls-tree) are encoded in system
    encoding, for display in the git-gui file browser.
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
  29. @dscho

    Teach 'git remote' that the config var branch.*.rebase can be 'intera…

    dscho authored committed
    …ctive'
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  30. @patthoyts

    gitk: fix setting font display with new tabbed dialog layout.

    patthoyts authored committed
    The changes to the dialog window tree broke the preview of the selected
    font on the button. This corrects that issue.
    
    Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  31. @patthoyts

    gitk: use a tabbed dialog to edit preferences

    patthoyts authored committed
    This commit converts the user preferences dialog into a tabbed property
    sheet grouping general properties, colours and font selections onto
    separate pages. The previous implementation was exceeding the screen
    height on some systems and this avoids such problems and permits extension
    using new pages in the future.
    
    If themed Tk is unavailable or undesired a reasonable facsimile of the
    tabbed notebook widget is used instead.
    
    Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  32. Windows/i18n: rename $path to prevent clashes with $PATH

    authored
    Environment variables on Windows are case-insensitive. Rename '$path' in
    all calls to eval_gettext to $modulepath so that it is not mistakenly
    expanded to the value of the $PATH variable.
    
    [jes: this happens to fix t7406/t7407 on Windows]
    [pt: squashed in fix for substitution order error that broke t7400]
    
    Signed-off-by: Karsten Blees <blees@dcon.de>
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
    Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  33. @dscho

    Install Git/I18N.pm even in the absence of Perl's MakeMaker

    dscho authored committed
    The telltale was that t0202 could not find I18N.pm on msysGit.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  34. @dscho

    t030[02]: work around CR/LF issue

    dscho authored committed
    It is the old shell-script issue we had in a few other tests already.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  35. @dscho

    Define NO_GETTEXT for Git for Windows

    dscho authored committed
    The dreaded "your vnsprintf is broken (returned -1)" error is back. At
    least with the libintl version we have. So for the moment, just work
    around the issue by _not_ using gettext.
    
    Ah, I wish that my attempt at implementing a custom strbuf_vaddf() would
    not have been brushed aside so rashly. Oh well. Time saved on maintaining
    that thing, I guess (although more time went into working around coping
    with existing implementations).
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Something went wrong with that request. Please try again.