Merge branch 'mt/patch-id-stable' (early part)

* 'mt/patch-id-stable' (early part):
  patch-id-test: test stable and unstable behaviour
  patch-id: make it stable against hunk reordering
  test doc: test_write_lines does not split its arguments
  test: add test_write_lines helper
Merge branch 'cc/replace-edit'

"git replace" learns a new "--edit" option.

* cc/replace-edit:
  Documentation: replace: describe new --edit option
  replace: add --edit to usage string
  replace: add tests for --edit
  replace: die early if replace ref already exists
  replace: refactor checking ref validity
  replace: make sure --edit results in a different object
  replace: add --edit option
  replace: factor object resolution out of replace_object
  replace: use OPT_CMDMODE to handle modes
  replace: refactor command-mode determination
Merge branch 'jk/do-not-run-httpd-tests-as-root'

* jk/do-not-run-httpd-tests-as-root:
  t/lib-httpd: require SANITY prereq
Merge branch 'sk/wincred'

* sk/wincred:
  wincred: avoid overwriting configured variables
  wincred: add install target
Merge branch 'jk/argv-array-for-child-process'

* jk/argv-array-for-child-process:
  argv-array: drop "detach" code
  get_importer: use run-command's internal argv_array
  get_exporter: use argv_array
  get_helper: use run-command's internal argv_array
  git_connect: use argv_array
  run_column_filter: use argv_array
  run-command: store an optional argv_array
Merge branch 'jk/diff-files-assume-unchanged'

* jk/diff-files-assume-unchanged:
  run_diff_files: do not look at uninitialized stat data
Merge branch 'jk/report-fail-to-read-objects-better'

* jk/report-fail-to-read-objects-better:
  open_sha1_file: report "most interesting" errno
Merge branch 'rr/rebase-autostash-fix'

* rr/rebase-autostash-fix:
  rebase -i: test "Nothing to do" case with autostash
  rebase -i: handle "Nothing to do" case with autostash
Merge branch 'sk/windows-unc-path'

* sk/windows-unc-path:
  Windows: allow using UNC path for git repository
Merge branch 'jk/diff-follow-must-take-one-pathspec'

* jk/diff-follow-must-take-one-pathspec:
  move "--follow needs one pathspec" rule to diff_setup_done
Merge branch 'as/pretty-truncate'

* as/pretty-truncate:
  pretty.c: format string with truncate respects logOutputEncoding
  t4205, t6006: add tests that fail with i18n.logOutputEncoding set
  t4205 (log-pretty-format): use `tformat` rather than `format`
  t4041, t4205, t6006, t7102: don't hardcode tested encoding value
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
Merge branch 'jk/daemon-tolower'

* jk/daemon-tolower:
  daemon/config: factor out duplicate xstrdup_tolower
Merge branch 'jk/strbuf-tolower'

* jk/strbuf-tolower:
  strbuf: add strbuf_tolower function
Merge branch 'cb/byte-order'

Compatibility enhancement for Solaris.

* cb/byte-order:
  compat/bswap.h: fix endianness detection
  compat/bswap.h: restore preference __BIG_ENDIAN over BIG_ENDIAN
  compat/bswap.h: detect endianness on more platforms that don't use BYTE_ORDER
Merge branch 'jl/status-added-submodule-is-never-ignored'

submodule.*.ignore and diff.ignoresubmodules are used to ignore all
submodule changes in "diff" output, but it can be confusing to
apply these configuration values to status and commit.

This is a backward-incompatible change, but should be so in a good
way (aka bugfix).

* jl/status-added-submodule-is-never-ignored:
  commit -m: commit staged submodules regardless of ignore config
  status/commit: show staged submodules regardless of ignore config
Win32: reliably detect console pipe handles

As of "Win32: Thread-safe windows console output", child processes may
print to the console even if stdout has been redirected to a file. E.g.:

 git config tar.cat.command "cat"
 git archive -o test.cat HEAD

Detecting whether stdout / stderr point to our console pipe is currently
based on the assumption that OS HANDLE values are never reused. This is
apparently not true if stdout / stderr is replaced via dup2() (as in
builtin/archive.c:17).

Instead of comparing handle values, check if the file descriptor isatty()
backed by a pipe OS handle. This is only possible by swapping the handles
in MSVCRT's internal data structures, as we do in winansi_init().

Reported-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Win32: let mingw_execve() return an int

This is in the great tradition of POSIX. Original fix by Olivier Refalo.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Win32: simplify internal mingw_spawn* APIs

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>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Win32: fix potential multi-threading issue

...by removing a static buffer in do_stat_internal.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
MinGW: disable CRT command line globbing

MingwRT listens to _CRT_glob to decide if __getmainargs should
perform globbing, with the default being that it should.
Unfortunately, __getmainargs globbing is sub-par; for instance
patterns like "*.c" will only match c-sources in the current
directory.

Disable __getmainargs' command line wildcard expansion, so these
patterns will be left untouched, and handled by Git's superior
built-in globbing instead.

MSVC defaults to no globbing, so we don't need to do anything
in that case.

This fixes t5505 and t7810.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>