Code

Merge branch 'jk/git-prompt'
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Dec 2011 19:27:23 +0000 (11:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Dec 2011 19:27:23 +0000 (11:27 -0800)
* jk/git-prompt:
  contrib: add credential helper for OS X Keychain
  Makefile: OS X has /dev/tty
  Makefile: linux has /dev/tty
  credential: use git_prompt instead of git_getpass
  prompt: use git_terminal_prompt
  add generic terminal prompt function
  refactor git_getpass into generic prompt function
  move git_getpass to its own source file
  imap-send: don't check return value of git_getpass
  imap-send: avoid buffer overflow

Conflicts:
Makefile

1  2 
Makefile
cache.h
connect.c
imap-send.c

diff --combined Makefile
index 9470a1034396a5f3ee36c5d0e6ffc54e21bb3820,4449cc8f7d9b82e4f83dac2cff8e086c40802391..a782409306df85985e1f465eab4bd3cd7fa2cc83
+++ b/Makefile
@@@ -43,22 -43,6 +43,22 @@@ all:
  # Define EXPATDIR=/foo/bar if your expat header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
 +# Define NO_GETTEXT if you don't want Git output to be translated.
 +# A translated Git requires GNU libintl or another gettext implementation,
 +# plus libintl-perl at runtime.
 +#
 +# Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
 +# trust the langinfo.h's nl_langinfo(CODESET) function to return the
 +# current character set. GNU and Solaris have a nl_langinfo(CODESET),
 +# FreeBSD can use either, but MinGW and some others need to use
 +# libcharset.h's locale_charset() instead.
 +#
 +# Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
 +# need -lintl when linking.
 +#
 +# Define NO_MSGFMT_EXTENDED_OPTIONS if your implementation of msgfmt
 +# doesn't support GNU extensions like --check and --statistics
 +#
  # Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
  # it specifies.
  #
@@@ -73,8 -57,8 +73,8 @@@
  #
  # Define NO_STRLCPY if you don't have strlcpy.
  #
 -# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
 -# If your compiler also does not support long long or does not have
 +# Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
 +# C library. If your compiler also does not support long long or does not have
  # strtoull, define NO_STRTOULL.
  #
  # Define NO_SETENV if you don't have setenv in the C library.
  #
  # Define NO_REGEX if you have no or inferior regex support in your C library.
  #
+ # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
+ # user.
+ #
  # Define GETTEXT_POISON if you are debugging the choice of strings marked
  # for translation.  In a GETTEXT_POISON build, you can turn all strings marked
  # for translation into gibberish by setting the GIT_GETTEXT_POISON variable
@@@ -325,7 -312,6 +328,7 @@@ gitexecdir = libexec/git-cor
  mergetoolsdir = $(gitexecdir)/mergetools
  sharedir = $(prefix)/share
  gitwebdir = $(sharedir)/gitweb
 +localedir = $(sharedir)/locale
  template_dir = share/git-core/templates
  htmldir = share/doc/git-doc
  ETC_GITCONFIG = $(sysconfdir)/gitconfig
@@@ -334,7 -320,7 +337,7 @@@ lib = li
  # DESTDIR=
  pathsep = :
  
 -export prefix bindir sharedir sysconfdir gitwebdir
 +export prefix bindir sharedir sysconfdir gitwebdir localedir
  
  CC = gcc
  AR = ar
@@@ -347,7 -333,6 +350,7 @@@ RPMBUILD = rpmbuil
  TCL_PATH = tclsh
  TCLTK_PATH = wish
  XGETTEXT = xgettext
 +MSGFMT = msgfmt
  PTHREAD_LIBS = -lpthread
  PTHREAD_CFLAGS =
  GCOV = gcov
@@@ -457,7 -442,6 +460,7 @@@ TEST_PROGRAMS_NEED_X += test-ctyp
  TEST_PROGRAMS_NEED_X += test-date
  TEST_PROGRAMS_NEED_X += test-delta
  TEST_PROGRAMS_NEED_X += test-dump-cache-tree
 +TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
  TEST_PROGRAMS_NEED_X += test-genrandom
  TEST_PROGRAMS_NEED_X += test-index-version
  TEST_PROGRAMS_NEED_X += test-line-buffer
@@@ -534,7 -518,6 +537,7 @@@ LIB_H += argv-array.
  LIB_H += attr.h
  LIB_H += blob.h
  LIB_H += builtin.h
 +LIB_H += bulk-checkin.h
  LIB_H += cache.h
  LIB_H += cache-tree.h
  LIB_H += color.h
@@@ -543,6 -526,7 +546,7 @@@ LIB_H += compat/bswap.
  LIB_H += compat/cygwin.h
  LIB_H += compat/mingw.h
  LIB_H += compat/obstack.h
+ LIB_H += compat/terminal.h
  LIB_H += compat/win32/pthread.h
  LIB_H += compat/win32/syslog.h
  LIB_H += compat/win32/poll.h
@@@ -557,11 -541,9 +561,11 @@@ LIB_H += diffcore.
  LIB_H += diff.h
  LIB_H += dir.h
  LIB_H += exec_cmd.h
 +LIB_H += fmt-merge-msg.h
  LIB_H += fsck.h
  LIB_H += gettext.h
  LIB_H += git-compat-util.h
 +LIB_H += gpg-interface.h
  LIB_H += graph.h
  LIB_H += grep.h
  LIB_H += hash.h
@@@ -585,6 -567,7 +589,7 @@@ LIB_H += parse-options.
  LIB_H += patch-ids.h
  LIB_H += pkt-line.h
  LIB_H += progress.h
+ LIB_H += prompt.h
  LIB_H += quote.h
  LIB_H += reflog-walk.h
  LIB_H += refs.h
@@@ -625,13 -608,13 +630,14 @@@ LIB_OBJS += base85.
  LIB_OBJS += bisect.o
  LIB_OBJS += blob.o
  LIB_OBJS += branch.o
 +LIB_OBJS += bulk-checkin.o
  LIB_OBJS += bundle.o
  LIB_OBJS += cache-tree.o
  LIB_OBJS += color.o
  LIB_OBJS += combine-diff.o
  LIB_OBJS += commit.o
  LIB_OBJS += compat/obstack.o
+ LIB_OBJS += compat/terminal.o
  LIB_OBJS += config.o
  LIB_OBJS += connect.o
  LIB_OBJS += connected.o
@@@ -657,8 -640,6 +663,8 @@@ LIB_OBJS += entry.
  LIB_OBJS += environment.o
  LIB_OBJS += exec_cmd.o
  LIB_OBJS += fsck.o
 +LIB_OBJS += gpg-interface.o
 +LIB_OBJS += gettext.o
  LIB_OBJS += graph.o
  LIB_OBJS += grep.o
  LIB_OBJS += hash.o
@@@ -694,6 -675,7 +700,7 @@@ LIB_OBJS += pkt-line.
  LIB_OBJS += preload-index.o
  LIB_OBJS += pretty.o
  LIB_OBJS += progress.o
+ LIB_OBJS += prompt.o
  LIB_OBJS += quote.o
  LIB_OBJS += reachable.o
  LIB_OBJS += read-cache.o
@@@ -855,14 -837,13 +862,15 @@@ ifeq ($(uname_S),Linux
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
        HAVE_PATHS_H = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
+       HAVE_DEV_TTY = YesPlease
  endif
  ifeq ($(uname_S),GNU/kFreeBSD)
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
        HAVE_PATHS_H = YesPlease
        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
  endif
  ifeq ($(uname_S),UnixWare)
        CC = cc
@@@ -917,6 -898,7 +925,7 @@@ ifeq ($(uname_S),Darwin
        endif
        NO_MEMMEM = YesPlease
        USE_ST_TIMESPEC = YesPlease
+       HAVE_DEV_TTY = YesPlease
  endif
  ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
        NO_MKSTEMPS = YesPlease
        NO_REGEX = YesPlease
        NO_FNMATCH_CASEFOLD = YesPlease
 +      NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
        ifeq ($(uname_R),5.6)
                SOCKLEN_T = int
                NO_HSTRERROR = YesPlease
@@@ -1053,7 -1034,6 +1062,7 @@@ ifeq ($(uname_S),GNU
        NO_STRLCPY=YesPlease
        NO_MKSTEMPS = YesPlease
        HAVE_PATHS_H = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
  endif
  ifeq ($(uname_S),IRIX)
        NO_SETENV = YesPlease
@@@ -1272,7 -1252,6 +1281,7 @@@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)
        EXTLIBS += /mingw/lib/libz.a
        NO_R_TO_GCC_LINKER = YesPlease
        INTERNAL_QSORT = YesPlease
 +      HAVE_LIBCHARSET_H = YesPlease
  else
        NO_CURL = YesPlease
  endif
@@@ -1461,11 -1440,6 +1470,11 @@@ endi
  ifdef NEEDS_LIBGEN
        EXTLIBS += -lgen
  endif
 +ifndef NO_GETTEXT
 +ifndef LIBC_CONTAINS_LIBINTL
 +      EXTLIBS += -lintl
 +endif
 +endif
  ifdef NEEDS_SOCKET
        EXTLIBS += -lsocket
  endif
@@@ -1508,11 -1482,9 +1517,11 @@@ ifdef NO_SYMLINK_HEA
        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  endif
  ifdef GETTEXT_POISON
 -      LIB_OBJS += gettext.o
        BASIC_CFLAGS += -DGETTEXT_POISON
  endif
 +ifdef NO_GETTEXT
 +      BASIC_CFLAGS += -DNO_GETTEXT
 +endif
  ifdef NO_STRCASESTR
        COMPAT_CFLAGS += -DNO_STRCASESTR
        COMPAT_OBJS += compat/strcasestr.o
@@@ -1523,7 -1495,7 +1532,7 @@@ ifdef NO_STRLCP
  endif
  ifdef NO_STRTOUMAX
        COMPAT_CFLAGS += -DNO_STRTOUMAX
 -      COMPAT_OBJS += compat/strtoumax.o
 +      COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o
  endif
  ifdef NO_STRTOULL
        COMPAT_CFLAGS += -DNO_STRTOULL
@@@ -1681,10 -1653,10 +1690,14 @@@ ifdef HAVE_PATHS_
        BASIC_CFLAGS += -DHAVE_PATHS_H
  endif
  
 +ifdef HAVE_LIBCHARSET_H
 +      BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
 +endif
 +
+ ifdef HAVE_DEV_TTY
+       BASIC_CFLAGS += -DHAVE_DEV_TTY
+ endif
  ifdef DIR_HAS_BSD_GROUP_SEMANTICS
        COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
  endif
@@@ -1705,10 -1677,6 +1718,10 @@@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEX
        export GIT_TEST_CMP_USE_COPIED_CONTEXT
  endif
  
 +ifndef NO_MSGFMT_EXTENDED_OPTIONS
 +      MSGFMT += --check --statistics
 +endif
 +
  ifeq ($(TCLTK_PATH),)
  NO_TCLTK=NoThanks
  endif
@@@ -1739,7 -1707,6 +1752,7 @@@ ifndef 
        QUIET_GEN      = @echo '   ' GEN $@;
        QUIET_LNCP     = @echo '   ' LN/CP $@;
        QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
 +      QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
        QUIET_GCOV     = @echo '   ' GCOV $@;
        QUIET_SP       = @echo '   ' SP $<;
        QUIET_SUBDIR0  = +@subdir=
@@@ -1766,7 -1733,6 +1779,7 @@@ bindir_SQ = $(subst ','\'',$(bindir)
  bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
  mandir_SQ = $(subst ','\'',$(mandir))
  infodir_SQ = $(subst ','\'',$(infodir))
 +localedir_SQ = $(subst ','\'',$(localedir))
  gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  template_dir_SQ = $(subst ','\'',$(template_dir))
  htmldir_SQ = $(subst ','\'',$(htmldir))
@@@ -1822,7 -1788,7 +1835,7 @@@ ifndef NO_TCLT
        $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
  endif
  ifndef NO_PERL
 -      $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
 +      $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
  endif
  ifndef NO_PYTHON
        $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
@@@ -1872,7 -1838,6 +1885,7 @@@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|
      -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
      -e 's|@@DIFF@@|$(DIFF_SQ)|' \
      -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 +    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
      -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
      -e $(BROKEN_PATH_FIX) \
      $@.sh >$@+
@@@ -2125,9 -2090,6 +2138,9 @@@ config.sp config.s config.o: EXTRA_CPPF
  attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
        -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
  
 +gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
 +      -DGIT_LOCALE_PATH='"$(localedir_SQ)"'
 +
  http.sp http.s http.o: EXTRA_CPPFLAGS = \
        -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"'
  
@@@ -2201,37 -2163,17 +2214,37 @@@ XGETTEXT_FLAGS = 
  XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
        --keyword=_ --keyword=N_ --keyword="Q_:1,2"
  XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
 +XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
  LOCALIZED_C := $(C_OBJ:o=c)
  LOCALIZED_SH := $(SCRIPT_SH)
 +LOCALIZED_PERL := $(SCRIPT_PERL)
 +
 +ifdef XGETTEXT_INCLUDE_TESTS
 +LOCALIZED_C += t/t0200/test.c
 +LOCALIZED_SH += t/t0200/test.sh
 +LOCALIZED_PERL += t/t0200/test.perl
 +endif
  
  po/git.pot: $(LOCALIZED_C)
        $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
        $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \
                $(LOCALIZED_SH)
 +      $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \
 +              $(LOCALIZED_PERL)
        mv $@+ $@
  
  pot: po/git.pot
  
 +POFILES := $(wildcard po/*.po)
 +MOFILES := $(patsubst po/%.po,po/build/locale/%/LC_MESSAGES/git.mo,$(POFILES))
 +
 +ifndef NO_GETTEXT
 +all:: $(MOFILES)
 +endif
 +
 +po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
 +      $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
 +
  FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
                        $(FIND) . \( -name .git -type d -prune \) \
                                -o \( -name '*.[hcS]' -type f -print \) )
@@@ -2250,8 -2192,7 +2263,8 @@@ cscope
  
  ### Detect prefix changes
  TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
 -             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
 +             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 +             $(localedir_SQ)
  
  GIT-CFLAGS: FORCE
        @FLAGS='$(TRACK_CFLAGS)'; \
@@@ -2288,7 -2229,6 +2301,7 @@@ endi
  ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
        @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
  endif
 +      @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
        @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
        @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
  
@@@ -2405,11 -2345,6 +2418,11 @@@ install: al
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
        $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
 +ifndef NO_GETTEXT
 +      $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
 +      (cd po/build/locale && $(TAR) cf - .) | \
 +      (cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
 +endif
  ifndef NO_PERL
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
        $(MAKE) -C gitweb install
@@@ -2546,7 -2481,6 +2559,7 @@@ clean
        $(RM) $(TEST_PROGRAMS)
        $(RM) -r bin-wrappers
        $(RM) -r $(dep_dirs)
 +      $(RM) -r po/build/
        $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
        $(RM) -r autom4te.cache
        $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
diff --combined cache.h
index 270dfdb8aebcade3071156de8b170461d3273b5c,f320c98d881f048fe2641f7dca3e018c6115f596..10afd71d435920a3cc2152208a06058791ea7a04
+++ b/cache.h
@@@ -35,7 -35,6 +35,7 @@@ int git_inflate(git_zstream *, int flus
  void git_deflate_init(git_zstream *, int level);
  void git_deflate_init_gzip(git_zstream *, int level);
  void git_deflate_end(git_zstream *);
 +int git_deflate_abort(git_zstream *);
  int git_deflate_end_gently(git_zstream *);
  int git_deflate(git_zstream *, int flush);
  unsigned long git_deflate_bound(git_zstream *, unsigned long);
@@@ -307,7 -306,7 +307,7 @@@ static inline unsigned int canon_mode(u
  }
  
  #define flexible_size(STRUCT,len) ((offsetof(struct STRUCT,name) + (len) + 8) & ~7)
 -#define cache_entry_size(len) flexible_size(cache_entry,len)
 +#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
  #define ondisk_cache_entry_size(len) flexible_size(ondisk_cache_entry,len)
  #define ondisk_cache_entry_extended_size(len) flexible_size(ondisk_cache_entry_extended,len)
  
@@@ -317,6 -316,7 +317,6 @@@ struct index_state 
        struct string_list *resolve_undo;
        struct cache_tree *cache_tree;
        struct cache_time timestamp;
 -      void *alloc;
        unsigned name_hash_initialized : 1,
                 initialized : 1;
        struct hash_table name_hash;
@@@ -598,7 -598,6 +598,7 @@@ extern size_t packed_git_window_size
  extern size_t packed_git_limit;
  extern size_t delta_base_cache_limit;
  extern unsigned long big_file_threshold;
 +extern unsigned long pack_size_limit_cfg;
  extern int read_replace_refs;
  extern int fsync_object_files;
  extern int core_preload_index;
@@@ -833,9 -832,7 +833,9 @@@ static inline int get_sha1_with_context
  extern int get_sha1_hex(const char *hex, unsigned char *sha1);
  
  extern char *sha1_to_hex(const unsigned char *sha1);  /* static buffer result! */
 -extern int read_ref(const char *filename, unsigned char *sha1);
 +extern int read_ref_full(const char *refname, unsigned char *sha1,
 +                       int reading, int *flags);
 +extern int read_ref(const char *refname, unsigned char *sha1);
  
  /*
   * Resolve a reference, recursively following symbolic refererences.
   *
   * errno is sometimes set on errors, but not always.
   */
 -extern const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag);
 +extern const char *resolve_ref_unsafe(const char *ref, unsigned char *sha1, int reading, int *flag);
 +extern char *resolve_refdup(const char *ref, unsigned char *sha1, int reading, int *flag);
  
  extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
  extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
@@@ -877,7 -873,7 +877,7 @@@ extern int get_sha1_mb(const char *str
  
  extern int refname_match(const char *abbrev_name, const char *full_name, const char **rules);
  extern const char *ref_rev_parse_rules[];
 -extern const char *ref_fetch_rules[];
 +#define ref_fetch_rules ref_rev_parse_rules
  
  extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
  extern int validate_headref(const char *ref);
@@@ -1028,15 -1024,15 +1028,14 @@@ struct ref 
  extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
  
  #define CONNECT_VERBOSE       (1u << 0)
- extern char *git_getpass(const char *prompt);
  extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
  extern int finish_connect(struct child_process *conn);
  extern int git_connection_is_socket(struct child_process *conn);
 -extern int path_match(const char *path, int nr, char **match);
  struct extra_have_objects {
        int nr, alloc;
        unsigned char (*array)[20];
  };
 -extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, unsigned int flags, struct extra_have_objects *);
 +extern struct ref **get_remote_heads(int in, struct ref **list, unsigned int flags, struct extra_have_objects *);
  extern int server_supports(const char *feature);
  
  extern struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);
diff --combined connect.c
index c8d0ea5d75e89a6b15b62e7057e97947036e11ea,519e5276080655d3778e8d3d09432238a78d0801..2ea5c3c0fbedb89e4189d32a455f289398ce106b
+++ b/connect.c
@@@ -53,6 -53,7 +53,6 @@@ static void add_extra_have(struct extra
   * Read all the refs from the other end
   */
  struct ref **get_remote_heads(int in, struct ref **list,
 -                            int nr_match, char **match,
                              unsigned int flags,
                              struct extra_have_objects *extra_have)
  {
@@@ -91,6 -92,8 +91,6 @@@
  
                if (!check_ref(name, name_len, flags))
                        continue;
 -              if (nr_match && !path_match(name, nr_match, match))
 -                      continue;
                ref = alloc_ref(buffer + 41);
                hashcpy(ref->old_sha1, old_sha1);
                *list = ref;
@@@ -105,6 -108,27 +105,6 @@@ int server_supports(const char *feature
                strstr(server_capabilities, feature) != NULL;
  }
  
 -int path_match(const char *path, int nr, char **match)
 -{
 -      int i;
 -      int pathlen = strlen(path);
 -
 -      for (i = 0; i < nr; i++) {
 -              char *s = match[i];
 -              int len = strlen(s);
 -
 -              if (!len || len > pathlen)
 -                      continue;
 -              if (memcmp(path + pathlen - len, s, len))
 -                      continue;
 -              if (pathlen > len && path[pathlen - len - 1] != '/')
 -                      continue;
 -              *s = 0;
 -              return (i + 1);
 -      }
 -      return 0;
 -}
 -
  enum protocol {
        PROTO_LOCAL = 1,
        PROTO_SSH,
@@@ -151,15 -175,6 +151,15 @@@ static void get_host_and_port(char **ho
        }
  }
  
 +static void enable_keepalive(int sockfd)
 +{
 +      int ka = 1;
 +
 +      if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
 +              fprintf(stderr, "unable to set SO_KEEPALIVE on socket: %s\n",
 +                      strerror(errno));
 +}
 +
  #ifndef NO_IPV6
  
  static const char *ai_name(const struct addrinfo *ai)
@@@ -224,8 -239,6 +224,8 @@@ static int git_tcp_connect_sock(char *h
        if (sockfd < 0)
                die("unable to connect to %s:\n%s", host, error_message.buf);
  
 +      enable_keepalive(sockfd);
 +
        if (flags & CONNECT_VERBOSE)
                fprintf(stderr, "done.\n");
  
@@@ -299,8 -312,6 +299,8 @@@ static int git_tcp_connect_sock(char *h
        if (sockfd < 0)
                die("unable to connect to %s:\n%s", host, error_message.buf);
  
 +      enable_keepalive(sockfd);
 +
        if (flags & CONNECT_VERBOSE)
                fprintf(stderr, "done.\n");
  
@@@ -608,47 -619,3 +608,3 @@@ int finish_connect(struct child_proces
        free(conn);
        return code;
  }
- char *git_getpass(const char *prompt)
- {
-       const char *askpass;
-       struct child_process pass;
-       const char *args[3];
-       static struct strbuf buffer = STRBUF_INIT;
-       askpass = getenv("GIT_ASKPASS");
-       if (!askpass)
-               askpass = askpass_program;
-       if (!askpass)
-               askpass = getenv("SSH_ASKPASS");
-       if (!askpass || !(*askpass)) {
-               char *result = getpass(prompt);
-               if (!result)
-                       die_errno("Could not read password");
-               return result;
-       }
-       args[0] = askpass;
-       args[1] = prompt;
-       args[2] = NULL;
-       memset(&pass, 0, sizeof(pass));
-       pass.argv = args;
-       pass.out = -1;
-       if (start_command(&pass))
-               exit(1);
-       strbuf_reset(&buffer);
-       if (strbuf_read(&buffer, pass.out, 20) < 0)
-               die("failed to read password from %s\n", askpass);
-       close(pass.out);
-       if (finish_command(&pass))
-               exit(1);
-       strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
-       return buffer.buf;
- }
diff --combined imap-send.c
index 91763d30181bed9bc6a3bf1cbc8d495d5b88f288,43588e8876756ce911e78362af085c4be4fe4745..e40125a22b72544c107e365d4f09eaa3b1ce53de
@@@ -25,6 -25,7 +25,7 @@@
  #include "cache.h"
  #include "exec_cmd.h"
  #include "run-command.h"
+ #include "prompt.h"
  #ifdef NO_OPENSSL
  typedef void *SSL;
  #else
@@@ -161,6 -162,7 +162,6 @@@ static struct imap_server_conf server 
  struct imap_store_conf {
        struct store_conf gen;
        struct imap_server_conf *server;
 -      unsigned use_namespace:1;
  };
  
  #define NIL   (void *)0x1
@@@ -1208,13 -1210,10 +1209,10 @@@ static struct store *imap_open_store(st
                        goto bail;
                }
                if (!srvc->pass) {
-                       char prompt[80];
-                       sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host);
-                       arg = git_getpass(prompt);
-                       if (!arg) {
-                               perror("getpass");
-                               exit(1);
-                       }
+                       struct strbuf prompt = STRBUF_INIT;
+                       strbuf_addf(&prompt, "Password (%s@%s): ", srvc->user, srvc->host);
+                       arg = git_getpass(prompt.buf);
+                       strbuf_release(&prompt);
                        if (!*arg) {
                                fprintf(stderr, "Skipping account %s@%s, no password\n", srvc->user, srvc->host);
                                goto bail;
@@@ -1538,8 -1537,6 +1536,8 @@@ int main(int argc, char **argv
  
        git_extract_argv0_path(argv[0]);
  
 +      git_setup_gettext();
 +
        if (argc != 1)
                usage(imap_send_usage);