mingw: correct exit-code for SIGALRM's SIG_DFL

Make sure SIG_DFL for SIGALRM exits with 128 + SIGALRM so other
processes can diagnose why it exits.

While we're at it, make sure we only write to stderr if it's a
terminal, and  change the output to match that of Linux.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mingw: make fgetc raise SIGINT if apropriate

Set a control-handler to prevent the process from terminating, and
simulate SIGINT so it can be handled by a signal-handler as usual.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/terminal: factor out echo-disabling

By moving the echo-disabling code to a separate function, we can
implement OS-specific versions of it for non-POSIX platforms.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/terminal: separate input and output handles

On Windows, the terminal cannot be opened in read-write mode, so
we need distinct pairs for reading and writing. Since this works
fine on other platforms as well, always open them in pairs.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mingw: reuse tty-version of git_terminal_prompt

The getpass-implementation we use on Windows isn't at all ideal;
it works in raw-mode (as opposed to cooked mode), and as a result
does not deal correcly with deletion, arrow-keys etc.

Instead, use cooked mode to read a line at the time, allowing the
C run-time to process the input properly.

Since we set files to be opened in binary-mode by default on
Windows, introduce a FORCE_TEXT macro that expands to the "t"
modifier that forces the terminal to be opened in text-mode so we
do not have to deal with CRLF issues.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mingw: get rid of getpass implementation

There's no remaining call-sites, and as pointed out in the
previous commit message, it's not quite ideal. So let's just
lose it.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/apply-trailing-blank-removal' into jch

Fix to update_pre_post_images() that did not take into account the
possibility that whitespace fix could shrink the preimage and
change the number of lines in it.

Will cook in 'next'.

* jc/apply-trailing-blank-removal:
  apply.c:update_pre_post_images(): the preimage can be truncated
Merge branch 'mh/ceiling' into jch

Elements of GIT_CEILING_DIRECTORIES list may not match the real
pathname we obtain from getcwd(), leading the GIT_DIR discovery
logic to escape the ceilings the user thought to have specified.

Resurrected from Stalled; the earlier performance fear was
unwarranted.

Will cook in 'next'.

* mh/ceiling:
  string_list_longest_prefix(): remove function
  setup_git_directory_gently_1(): resolve symlinks in ceiling paths
  longest_ancestor_length(): require prefix list entries to be normalized
  longest_ancestor_length(): take a string_list argument for prefixes
  longest_ancestor_length(): use string_list_split()
  Introduce new function real_path_if_valid()
  real_path_internal(): add comment explaining use of cwd
  Introduce new static function real_path_internal()

Conflicts:
	Documentation/technical/api-string-list.txt
	string-list.c
	string-list.h
Merge branch 'nd/wildmatch' into jch

Allows pathname patterns in .gitignore and .gitattributes files
with double-asterisks "foo/**/bar" to match any number of directory
hierarchies.

I suspect that this needs to be plugged to pathspec matching code;
otherwise "git log -- 'Docum*/**/*.txt'" would not show the log for
commits that touch Documentation/git.txt, which would be confusing
to the users.

Will cook in 'next'.

* nd/wildmatch:
  test-wildmatch: avoid Windows path mangling
  Support "**" wildcard in .gitignore and .gitattributes
  wildmatch: make /**/ match zero or more directories
  wildmatch: adjust "**" behavior
  wildmatch: fix case-insensitive matching
  wildmatch: remove static variable force_lower_case
  wildmatch: make wildmatch's return value compatible with fnmatch
  t3070: disable unreliable fnmatch tests
  Integrate wildmatch to git
  wildmatch: follow Git's coding convention
  wildmatch: remove unnecessary functions
  Import wildmatch from rsync
  ctype: support iscntrl, ispunct, isxdigit and isprint
  ctype: make sane_ctype[] const array

Conflicts:
	Makefile
Merge branch 'rc/maint-complete-git-p4' into jch

Comment from Pete will need to be addressed in a follow-up patch.

* rc/maint-complete-git-p4:
  Teach git-completion about git p4
Merge branch 'mh/pthreads-autoconf' into jch

Will cook in 'next'.

* mh/pthreads-autoconf:
  configure.ac: fix pthreads detection on Mac OS X
Merge branch 'jk/fsck-dot-in-trees' into jch

Will cook in 'next'.

* jk/fsck-dot-in-trees:
  fsck: warn about ".git" in trees
  fsck: warn about '.' and '..' in trees
Merge branch 'jn/warn-on-inaccessible-loosen' into jch

An RFC to deal with a situation where .config/git is a file and we
notice .config/git/config is not readable due to ENOTDIR, not
ENOENT.

Will cook in 'next'.

* jn/warn-on-inaccessible-loosen:
  config: exit on error accessing any config file
  doc: advertise GIT_CONFIG_NOSYSTEM
  config: treat user and xdg config permission problems as errors
  config, gitignore: failure to access with ENOTDIR is ok
Merge branch 'nd/pathspec-wildcard' into jch

Will cook in 'next'.

* nd/pathspec-wildcard:
  tree_entry_interesting: do basedir compare on wildcard patterns when possible
  pathspec: apply "*.c" optimization from exclude
  pathspec: do exact comparison on the leading non-wildcard part
  pathspec: save the non-wildcard length part
Merge branch 'mh/unify-xml-in-imap-send-and-http-push' into jch

* mh/unify-xml-in-imap-send-and-http-push:
  wrap_in_html(): process message in bulk rather than line-by-line
  wrap_in_html(): use strbuf_addstr_xml_quoted()
  imap-send: change msg_data from storing (ptr, len) to storing strbuf
  imap-send: correctly report errors reading from stdin
  imap-send: store all_msgs as a strbuf
  lf_to_crlf(): NUL-terminate msg_data::data
  xml_entities(): use function strbuf_addstr_xml_quoted()
  Add new function strbuf_add_xml_quoted()
Merge branch 'fc/fast-export-fixes' into jch

Will cook in 'next'.

* fc/fast-export-fixes:
  fast-export: make sure updated refs get updated
  fast-export: don't handle uninteresting refs
  fast-export: fix comparison in tests
  fast-export: trivial cleanup
  remote-testgit: implement the "done" feature manually
  remote-testgit: report success after an import
  remote-testgit: exercise more features
  remote-testgit: cleanup tests
  remote-testgit: remove irrelevant test
  remote-testgit: remove non-local functionality
  Add new simplified git-remote-testgit
  Rename git-remote-testgit to git-remote-testpy
  remote-helpers: fix failure message
  remote-testgit: fix direction of marks
  fast-export: avoid importing blob marks
submodule: add 'deinit' command

With "git submodule init" the user is able to tell git he cares about one
or more submodules and wants to have it populated on the next call to "git
submodule update". But currently there is no easy way he could tell git he
does not care about a submodule anymore and wants to get rid of his local
work tree (except he knows a lot about submodule internals and removes the
"submodule.$name.url" setting from .git/config himself).

Help those users by providing a 'deinit' command. This removes the whole
submodule.<name> section from .git/config either for the given
submodule(s) or for all those which have been initialized if none were
given. Complain only when for a submodule given on the command line the
url setting can't be found in .git/config.

Add tests and link the man pages of "git submodule deinit" and "git rm"
to assist the user in deciding whether removing or unregistering the
submodule is the right thing to do for him.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'rr/t4041-cleanup' into jch

Will merge to 'next'.

* rr/t4041-cleanup:
  t4041 (diff-submodule-option): modernize style
  t4041 (diff-submodule-option): rewrite add_file() routine
  t4041 (diff-submodule-option): parse digests sensibly
  t4041 (diff-submodule-option): don't hardcode SHA-1 in expected outputs
Merge branch 'cr/push-force-tag-update' into jch

Require "-f" for push to update a tag, even if it is a fast-forward.

Will merge to 'next'.

* cr/push-force-tag-update:
  push: allow already-exists advice to be disabled
  push: rename config variable for more general use
  push: cleanup push rules comment
  push: clarify rejection of update to non-commit-ish
  push: require force for annotated tags
  push: require force for refs under refs/tags/
  push: flag updates that require force
  push: keep track of "update" state separately
  push: add advice for rejected tag reference
  push: return reject reasons as a bitset
Merge branch 'pf/editor-ignore-sigint' into jch

Avoid confusing cases where the user hits Ctrl-C while in the editor
session, not realizing git will receive the signal. Since most editors
will take over the terminal and will block SIGINT, this is not likely
to confuse anyone.

* pf/editor-ignore-sigint:
  launch_editor: propagate signals from editor to git
  run-command: do not warn about child death from terminal
  launch_editor: ignore terminal signals while editor has control
  launch_editor: refactor to use start/finish_command
  run-command: drop silent_exec_failure arg from wait_or_whine