Merge branch 'jc/mailinfo-lib'
authorJunio C Hamano <gitster@pobox.com>
Thu, 29 Oct 2015 20:59:21 +0000 (13:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Oct 2015 20:59:22 +0000 (13:59 -0700)
The implementation of "git mailinfo" was refactored so that a
mailinfo() function can be directly called from inside a process.

* jc/mailinfo-lib: (34 commits)
mailinfo: remove calls to exit() and die() deep in the callchain
mailinfo: handle charset conversion errors in the caller
mailinfo: libify
mailinfo: keep the parsed log message in a strbuf
mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak
mailinfo: move content/content_top to struct mailinfo
mailinfo: move [ps]_hdr_data to struct mailinfo
mailinfo: move cmitmsg and patchfile to struct mailinfo
mailinfo: move charset to struct mailinfo
mailinfo: move transfer_encoding to struct mailinfo
mailinfo: move check for metainfo_charset to convert_to_utf8()
mailinfo: move metainfo_charset to struct mailinfo
mailinfo: move use_scissors and use_inbody_headers to struct mailinfo
mailinfo: move add_message_id and message_id to struct mailinfo
mailinfo: move patch_lines to struct mailinfo
mailinfo: move filter/header stage to struct mailinfo
mailinfo: move global "FILE *fin, *fout" to struct mailinfo
mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo
mailinfo: introduce "struct mailinfo" to hold globals
mailinfo: move global "line" into mailinfo() function
...

1  2 
Makefile
diff --combined Makefile
index e0717b0fa107ea7ead0eb3b5e35545c1263c9f13,7dd3bff12f0f1aca1b78816cf5b94578fb31cb56..43ceeb966c51e4e0b684ac64c2c5cbf0aa943cbf
+++ b/Makefile
@@@ -39,9 -39,6 +39,9 @@@ all:
  # Define CURLDIR=/foo/bar if your curl header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
 +# Define CURL_CONFIG to curl's configuration program that prints information
 +# about the library (e.g., its version number).  The default is 'curl-config'.
 +#
  # Define NO_EXPAT if you do not have expat installed.  git-http-push is
  # not built, and you cannot push using http:// and https:// transports (dumb).
  #
@@@ -77,6 -74,8 +77,6 @@@
  # Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
  # it specifies.
  #
 -# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 -#
  # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  # d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
  #
@@@ -376,9 -375,6 +376,9 @@@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS
  ALL_LDFLAGS = $(LDFLAGS)
  STRIP ?= strip
  
 +# Create as necessary, replace existing, make ranlib unneeded.
 +ARFLAGS = rcs
 +
  # Among the variables below, these:
  #   gitexecdir
  #   template_dir
@@@ -429,7 -425,6 +429,7 @@@ TCL_PATH = tcls
  TCLTK_PATH = wish
  XGETTEXT = xgettext
  MSGFMT = msgfmt
 +CURL_CONFIG = curl-config
  PTHREAD_LIBS = -lpthread
  PTHREAD_CFLAGS =
  GCOV = gcov
@@@ -731,6 -726,7 +731,7 @@@ LIB_OBJS += list-objects.
  LIB_OBJS += ll-merge.o
  LIB_OBJS += lockfile.o
  LIB_OBJS += log-tree.o
+ LIB_OBJS += mailinfo.o
  LIB_OBJS += mailmap.o
  LIB_OBJS += match-trees.o
  LIB_OBJS += merge.o
@@@ -812,7 -808,6 +813,7 @@@ LIB_OBJS += version.
  LIB_OBJS += versioncmp.o
  LIB_OBJS += walker.o
  LIB_OBJS += wildmatch.o
 +LIB_OBJS += worktree.o
  LIB_OBJS += wrapper.o
  LIB_OBJS += write_or_die.o
  LIB_OBJS += ws.o
@@@ -908,7 -903,6 +909,7 @@@ BUILTIN_OBJS += builtin/shortlog.
  BUILTIN_OBJS += builtin/show-branch.o
  BUILTIN_OBJS += builtin/show-ref.o
  BUILTIN_OBJS += builtin/stripspace.o
 +BUILTIN_OBJS += builtin/submodule--helper.o
  BUILTIN_OBJS += builtin/symbolic-ref.o
  BUILTIN_OBJS += builtin/tag.o
  BUILTIN_OBJS += builtin/unpack-file.o
@@@ -1040,7 -1034,7 +1041,7 @@@ ifdef HAVE_ALLOCA_
  endif
  
  IMAP_SEND_BUILDDEPS =
 -IMAP_SEND_LDFLAGS = $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
 +IMAP_SEND_LDFLAGS =
  
  ifdef NO_CURL
        BASIC_CFLAGS += -DNO_CURL
        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
        PROGRAM_OBJS += http-fetch.o
        PROGRAMS += $(REMOTE_CURL_NAMES)
 -      curl_check := $(shell (echo 070908; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
 +      curl_check := $(shell (echo 070908; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "070908"
                ifndef NO_EXPAT
                        PROGRAM_OBJS += http-push.o
                endif
        endif
 -      curl_check := $(shell (echo 072200; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
 +      curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "072200"
                USE_CURL_FOR_IMAP_SEND = YesPlease
        endif
                endif
        endif
  endif
 +IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
  
  ifdef ZLIB_PATH
        BASIC_CFLAGS += -I$(ZLIB_PATH)/include
@@@ -1168,6 -1161,9 +1169,6 @@@ endi
  ifdef NO_D_TYPE_IN_DIRENT
        BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
  endif
 -ifdef NO_D_INO_IN_DIRENT
 -      BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
 -endif
  ifdef NO_GECOS_IN_PWENT
        BASIC_CFLAGS += -DNO_GECOS_IN_PWENT
  endif
@@@ -1470,13 -1466,13 +1471,13 @@@ endi
  QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  QUIET_SUBDIR1  =
  
 -ifneq ($(findstring $(MAKEFLAGS),w),w)
 +ifneq ($(findstring w,$(MAKEFLAGS)),w)
  PRINT_DIR = --no-print-directory
  else # "make -w"
  NO_SUBDIR = :
  endif
  
 -ifneq ($(findstring $(MAKEFLAGS),s),s)
 +ifneq ($(findstring s,$(MAKEFLAGS)),s)
  ifndef V
        QUIET_CC       = @echo '   ' CC $@;
        QUIET_AR       = @echo '   ' AR $@;
@@@ -1980,10 -1976,10 +1981,10 @@@ git-imap-send$X: imap-send.o $(IMAP_SEN
  
  git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 -              $(LIBS) $(CURL_LIBCURL)
 +              $(CURL_LIBCURL) $(LIBS)
  git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 -              $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 +              $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
  
  git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
@@@ -1997,16 -1993,16 +1998,16 @@@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_P
  
  $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 -              $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 +              $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
  
  $(LIB_FILE): $(LIB_OBJS)
 -      $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
 +      $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
  
  $(XDIFF_LIB): $(XDIFF_OBJS)
 -      $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
 +      $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
  
  $(VCSSVN_LIB): $(VCSSVN_OBJS)
 -      $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
 +      $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
  
  export DEFAULT_EDITOR DEFAULT_PAGER