Merge branch 'na/strtoimax' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 28 Dec 2011 19:32:33 +0000 (11:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Dec 2011 19:32:33 +0000 (11:32 -0800)
* na/strtoimax:
Support sizes >=2G in various config options accepting 'g' sizes.
Compatibility: declare strtoimax() under NO_STRTOUMAX
Add strtoimax() compatibility function.

1  2 
Makefile
config.c
git-compat-util.h
diff --combined Makefile
index b1c80a678b5fdb80ec71f0a1ad567a384feba4e8,c5c1fd7ab09dbd43488a576d7aee69fba9688ae7..b21d2f14176d08011cea79790eb2246d50787ec9
+++ b/Makefile
@@@ -30,15 -30,15 +30,15 @@@ all:
  # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
 -# Define NO_CURL if you do not have libcurl installed.  git-http-pull and
 +# Define NO_CURL if you do not have libcurl installed.  git-http-fetch and
  # git-http-push are not built, and you cannot use http:// and https://
 -# transports.
 +# transports (neither smart nor dumb).
  #
  # Define CURLDIR=/foo/bar if your curl header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
  # 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.
 +# not built, and you cannot push using http:// and https:// transports (dumb).
  #
  # Define EXPATDIR=/foo/bar if your expat header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
@@@ -57,8 -57,8 +57,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 NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
  #
 +# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
 +#
 +# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
 +#
  # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  #
  # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  # that tells runtime paths to dynamic libraries;
  # "-Wl,-rpath=/path/lib" is used instead.
  #
 +# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
 +# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
 +#
  # Define USE_NSEC below if you want git to care about sub-second file mtimes
  # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
  #   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
  #
 -# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
 -# and you want to avoid rebuilding objects when an unrelated header file
 -# changes.
 +# Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
 +# header files to be automatically computed, to avoid rebuilding objects when
 +# an unrelated header file changes.  Define it to "no" to use the hard-coded
 +# dependency rules.  The default is "auto", which means to use computed header
 +# dependencies if your compiler is detected to support it.
  #
  # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
  # dependency rules.
@@@ -304,7 -295,6 +304,7 @@@ bindir = $(prefix)/$(bindir_relative
  mandir = share/man
  infodir = share/info
  gitexecdir = libexec/git-core
 +mergetoolsdir = $(gitexecdir)/mergetools
  sharedir = $(prefix)/share
  gitwebdir = $(sharedir)/gitweb
  template_dir = share/git-core/templates
@@@ -507,7 -497,6 +507,7 @@@ VCSSVN_LIB=vcs-svn/lib.
  
  LIB_H += advice.h
  LIB_H += archive.h
 +LIB_H += argv-array.h
  LIB_H += attr.h
  LIB_H += blob.h
  LIB_H += builtin.h
@@@ -518,13 -507,10 +518,13 @@@ LIB_H += commit.
  LIB_H += compat/bswap.h
  LIB_H += compat/cygwin.h
  LIB_H += compat/mingw.h
 +LIB_H += compat/obstack.h
  LIB_H += compat/win32/pthread.h
  LIB_H += compat/win32/syslog.h
 -LIB_H += compat/win32/sys/poll.h
 +LIB_H += compat/win32/poll.h
  LIB_H += compat/win32/dirent.h
 +LIB_H += connected.h
 +LIB_H += convert.h
  LIB_H += csum-file.h
  LIB_H += decorate.h
  LIB_H += delta.h
@@@ -539,7 -525,6 +539,7 @@@ LIB_H += graph.
  LIB_H += grep.h
  LIB_H += hash.h
  LIB_H += help.h
 +LIB_H += kwset.h
  LIB_H += levenshtein.h
  LIB_H += list-objects.h
  LIB_H += ll-merge.h
@@@ -566,13 -551,11 +566,13 @@@ LIB_H += rerere.
  LIB_H += resolve-undo.h
  LIB_H += revision.h
  LIB_H += run-command.h
 +LIB_H += sequencer.h
  LIB_H += sha1-array.h
  LIB_H += sha1-lookup.h
  LIB_H += sideband.h
  LIB_H += sigchain.h
  LIB_H += strbuf.h
 +LIB_H += streaming.h
  LIB_H += string-list.h
  LIB_H += submodule.h
  LIB_H += tag.h
@@@ -592,7 -575,6 +592,7 @@@ LIB_OBJS += alloc.
  LIB_OBJS += archive.o
  LIB_OBJS += archive-tar.o
  LIB_OBJS += archive-zip.o
 +LIB_OBJS += argv-array.o
  LIB_OBJS += attr.o
  LIB_OBJS += base85.o
  LIB_OBJS += bisect.o
@@@ -603,10 -585,8 +603,10 @@@ LIB_OBJS += cache-tree.
  LIB_OBJS += color.o
  LIB_OBJS += combine-diff.o
  LIB_OBJS += commit.o
 +LIB_OBJS += compat/obstack.o
  LIB_OBJS += config.o
  LIB_OBJS += connect.o
 +LIB_OBJS += connected.o
  LIB_OBJS += convert.o
  LIB_OBJS += copy.o
  LIB_OBJS += csum-file.o
@@@ -634,7 -614,6 +634,7 @@@ LIB_OBJS += hash.
  LIB_OBJS += help.o
  LIB_OBJS += hex.o
  LIB_OBJS += ident.o
 +LIB_OBJS += kwset.o
  LIB_OBJS += levenshtein.o
  LIB_OBJS += list-objects.o
  LIB_OBJS += ll-merge.o
@@@ -655,7 -634,6 +655,7 @@@ LIB_OBJS += pack-revindex.
  LIB_OBJS += pack-write.o
  LIB_OBJS += pager.o
  LIB_OBJS += parse-options.o
 +LIB_OBJS += parse-options-cb.o
  LIB_OBJS += patch-delta.o
  LIB_OBJS += patch-ids.o
  LIB_OBJS += path.o
@@@ -676,7 -654,6 +676,7 @@@ LIB_OBJS += revision.
  LIB_OBJS += run-command.o
  LIB_OBJS += server-info.o
  LIB_OBJS += setup.o
 +LIB_OBJS += sequencer.o
  LIB_OBJS += sha1-array.o
  LIB_OBJS += sha1-lookup.o
  LIB_OBJS += sha1_file.o
@@@ -685,7 -662,6 +685,7 @@@ LIB_OBJS += shallow.
  LIB_OBJS += sideband.o
  LIB_OBJS += sigchain.o
  LIB_OBJS += strbuf.o
 +LIB_OBJS += streaming.o
  LIB_OBJS += string-list.o
  LIB_OBJS += submodule.o
  LIB_OBJS += symlinks.o
@@@ -829,7 -805,6 +829,7 @@@ ifeq ($(uname_S),GNU/kFreeBSD
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
        HAVE_PATHS_H = YesPlease
 +      DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
  endif
  ifeq ($(uname_S),UnixWare)
        CC = cc
@@@ -1095,7 -1070,6 +1095,7 @@@ ifeq ($(uname_S),Windows
        NO_PREAD = YesPlease
        NEEDS_CRYPTO_WITH_SSL = YesPlease
        NO_LIBGEN_H = YesPlease
 +      NO_SYS_POLL_H = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NO_IPV6 = YesPlease
        NO_SETENV = YesPlease
        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
        COMPAT_OBJS = compat/msvc.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
 -              compat/win32/sys/poll.o compat/win32/dirent.o
 +              compat/win32/poll.o compat/win32/dirent.o
        COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
        BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
        EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib
@@@ -1150,6 -1124,8 +1150,6 @@@ endi
        X = .exe
  endif
  ifeq ($(uname_S),Interix)
 -      NO_SYS_POLL_H = YesPlease
 -      NO_INTTYPES_H = YesPlease
        NO_INITGROUPS = YesPlease
        NO_IPV6 = YesPlease
        NO_MEMMEM = YesPlease
        ifeq ($(uname_R),3.5)
                NO_INET_NTOP = YesPlease
                NO_INET_PTON = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_FNMATCH_CASEFOLD = YesPlease
        endif
        ifeq ($(uname_R),5.2)
                NO_INET_NTOP = YesPlease
                NO_INET_PTON = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_FNMATCH_CASEFOLD = YesPlease
        endif
  endif
 +ifeq ($(uname_S),Minix)
 +      NO_IPV6 = YesPlease
 +      NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
 +      NO_NSEC = YesPlease
 +      NEEDS_LIBGEN =
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
 +      NEEDS_IDN_WITH_CURL = YesPlease
 +      NEEDS_SSL_WITH_CURL = YesPlease
 +      NEEDS_RESOLV =
 +      NO_HSTRERROR = YesPlease
 +      NO_MMAP = YesPlease
 +      NO_CURL =
 +      NO_EXPAT =
 +endif
  ifneq (,$(findstring MINGW,$(uname_S)))
        pathsep = ;
        NO_PREAD = YesPlease
        NEEDS_CRYPTO_WITH_SSL = YesPlease
        NO_LIBGEN_H = YesPlease
 +      NO_SYS_POLL_H = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NO_SETENV = YesPlease
        NO_UNSETENV = YesPlease
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
 -              compat/win32/sys/poll.o compat/win32/dirent.o
 +              compat/win32/poll.o compat/win32/dirent.o
        EXTLIBS += -lws2_32
        PTHREAD_LIBS =
        X = .exe
@@@ -1252,32 -1209,12 +1252,32 @@@ endi
  endif
  
  ifdef CHECK_HEADER_DEPENDENCIES
 -COMPUTE_HEADER_DEPENDENCIES =
 +COMPUTE_HEADER_DEPENDENCIES = no
  USE_COMPUTED_HEADER_DEPENDENCIES =
  endif
  
 -ifdef COMPUTE_HEADER_DEPENDENCIES
 +ifndef COMPUTE_HEADER_DEPENDENCIES
 +COMPUTE_HEADER_DEPENDENCIES = auto
 +endif
 +
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
 +dep_check = $(shell $(CC) $(ALL_CFLAGS) \
 +      -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
 +      echo $$?)
 +ifeq ($(dep_check),0)
 +override COMPUTE_HEADER_DEPENDENCIES = yes
 +else
 +override COMPUTE_HEADER_DEPENDENCIES = no
 +endif
 +endif
 +
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
  USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
 +else
 +ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
 +$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
 +(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
 +endif
  endif
  
  ifdef SANE_TOOL_PATH
        else
                CURL_LIBCURL = -lcurl
        endif
 +      ifdef NEEDS_SSL_WITH_CURL
 +              CURL_LIBCURL += -lssl
 +              ifdef NEEDS_CRYPTO_WITH_SSL
 +                      CURL_LIBCURL += -lcrypto
 +              endif
 +      endif
 +      ifdef NEEDS_IDN_WITH_CURL
 +              CURL_LIBCURL += -lidn
 +      endif
 +
        REMOTE_CURL_PRIMARY = git-remote-http$X
        REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@@ -1395,7 -1322,7 +1395,7 @@@ ifndef NO_OPENSS
                OPENSSL_LINK =
        endif
        ifdef NEEDS_CRYPTO_WITH_SSL
 -              OPENSSL_LINK += -lcrypto
 +              OPENSSL_LIBSSL += -lcrypto
        endif
  else
        BASIC_CFLAGS += -DNO_OPENSSL
@@@ -1447,9 -1374,6 +1447,9 @@@ endi
  ifdef USE_ST_TIMESPEC
        BASIC_CFLAGS += -DUSE_ST_TIMESPEC
  endif
 +ifdef NO_NORETURN
 +      BASIC_CFLAGS += -DNO_NORETURN
 +endif
  ifdef NO_NSEC
        BASIC_CFLAGS += -DNO_NSEC
  endif
@@@ -1478,7 -1402,7 +1478,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
@@@ -1782,7 -1706,7 +1782,7 @@@ git.sp git.s git.o: EXTRA_CPPFLAGS = -D
        '-DGIT_MAN_PATH="$(mandir_SQ)"' \
        '-DGIT_INFO_PATH="$(infodir_SQ)"'
  
 -git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
 +git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  
@@@ -1914,7 -1838,7 +1914,7 @@@ ifndef NO_CUR
        GIT_OBJS += http.o http-walker.o remote-curl.o
  endif
  XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 -      xdiff/xmerge.o xdiff/xpatience.o
 +      xdiff/xmerge.o xdiff/xpatience.o xdiff/xhistogram.o
  VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
        vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o
  VCSSVN_TEST_OBJS = test-obj-pool.o test-string-pool.o \
@@@ -1924,9 -1848,9 +1924,9 @@@ OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(
  dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
  dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
  
 -ifdef COMPUTE_HEADER_DEPENDENCIES
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
  $(dep_dirs):
 -      mkdir -p $@
 +      @mkdir -p $@
  
  missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
  dep_file = $(dir $@).depend/$(notdir $@).d
@@@ -1937,7 -1861,7 +1937,7 @@@ Please unset CHECK_HEADER_DEPENDENCIES 
  endif
  endif
  
 -ifndef COMPUTE_HEADER_DEPENDENCIES
 +ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
  ifndef CHECK_HEADER_DEPENDENCIES
  dep_dirs =
  missing_dep_dirs =
@@@ -2027,13 -1951,13 +2027,13 @@@ builtin/branch.o builtin/checkout.o bui
  builtin/bundle.o bundle.o transport.o: bundle.h
  builtin/bisect--helper.o builtin/rev-list.o bisect.o: bisect.h
  builtin/clone.o builtin/fetch-pack.o transport.o: fetch-pack.h
 -builtin/grep.o builtin/pack-objects.o transport-helper.o: thread-utils.h
 +builtin/grep.o builtin/pack-objects.o transport-helper.o thread-utils.o: thread-utils.h
  builtin/send-pack.o transport.o: send-pack.h
  builtin/log.o builtin/shortlog.o: shortlog.h
  builtin/prune.o builtin/reflog.o reachable.o: reachable.h
  builtin/commit.o builtin/revert.o wt-status.o: wt-status.h
  builtin/tar-tree.o archive-tar.o: tar.h
 -connect.o transport.o http-backend.o: url.h
 +connect.o transport.o url.o http-backend.o: url.h
  http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
  http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h
  
@@@ -2080,17 -2004,17 +2080,17 @@@ compat/nedmalloc/nedmalloc.sp compat/ne
        -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
  endif
  
 -git-%$X: %.o $(GITLIBS)
 +git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  
 -git-imap-send$X: imap-send.o $(GITLIBS)
 +git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
  
 -git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
 +git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL)
 -git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
 +git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
  
@@@ -2100,7 -2024,7 +2100,7 @@@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_P
        ln -s $< $@ 2>/dev/null || \
        cp $< $@
  
 -$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
 +$(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)
  
@@@ -2147,21 -2071,17 +2147,21 @@@ po/git.pot: $(LOCALIZED_C
  
  pot: po/git.pot
  
 +FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
 +                      $(FIND) . \( -name .git -type d -prune \) \
 +                              -o \( -name '*.[hcS]' -type f -print \) )
 +
  $(ETAGS_TARGET): FORCE
        $(RM) $(ETAGS_TARGET)
 -      $(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
 +      $(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
  
  tags: FORCE
        $(RM) tags
 -      $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
 +      $(FIND_SOURCE_FILES) | xargs ctags -a
  
  cscope:
        $(RM) cscope*
 -      $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 +      $(FIND_SOURCE_FILES) | xargs cscope -b
  
  ### Detect prefix changes
  TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
@@@ -2174,15 -2094,6 +2174,15 @@@ GIT-CFLAGS: FORC
                echo "$$FLAGS" >GIT-CFLAGS; \
              fi
  
 +TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 +
 +GIT-LDFLAGS: FORCE
 +      @FLAGS='$(TRACK_LDFLAGS)'; \
 +          if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
 +              echo 1>&2 "    * new link flags"; \
 +              echo "$$FLAGS" >GIT-LDFLAGS; \
 +            fi
 +
  # We need to apply sq twice, once to protect from the shell
  # that runs GIT-BUILD-OPTIONS, and then again to protect it
  # and the first level quoting from the shell that runs "echo".
@@@ -2246,7 -2157,7 +2246,7 @@@ test-delta$X: diff-delta.o patch-delta.
  
  test-line-buffer$X: vcs-svn/lib.a
  
 -test-parse-options$X: parse-options.o
 +test-parse-options$X: parse-options.o parse-options-cb.o
  
  test-string-pool$X: vcs-svn/lib.a
  
@@@ -2254,7 -2165,7 +2254,7 @@@ test-svn-fe$X: vcs-svn/lib.
  
  .PRECIOUS: $(TEST_OBJS)
  
 -test-%$X: test-%.o $(GITLIBS)
 +test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
  
  check-sha1:: test-sha1$X
@@@ -2299,13 -2210,6 +2299,13 @@@ endi
  gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
  export gitexec_instdir
  
 +ifneq ($(filter /%,$(firstword $(mergetoolsdir))),)
 +mergetools_instdir = $(mergetoolsdir)
 +else
 +mergetools_instdir = $(prefix)/$(mergetoolsdir)
 +endif
 +mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 +
  install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
  
  install: all
        $(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
        $(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_PERL
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
        $(MAKE) -C gitweb install
@@@ -2473,7 -2375,7 +2473,7 @@@ ifndef NO_TCLT
        $(MAKE) -C gitk-git clean
        $(MAKE) -C git-gui clean
  endif
 -      $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
 +      $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
  
  .PHONY: all install clean strip
  .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
@@@ -2584,19 -2486,3 +2584,19 @@@ cover_db: coverage-repor
  
  cover_db_html: cover_db
        cover -report html -outputdir cover_db_html cover_db
 +
 +### profile feedback build
 +#
 +.PHONY: profile-all profile-clean
 +
 +PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1
 +PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1
 +
 +profile-clean:
 +      $(RM) $(addsuffix *.gcda,$(object_dirs))
 +      $(RM) $(addsuffix *.gcno,$(object_dirs))
 +
 +profile-all: profile-clean
 +      $(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" all
 +      $(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" -j1 test
 +      $(MAKE) CFLAGS="$(PROFILE_USE_CFLAGS)" all
diff --combined config.c
index b6d789a189713a0259e3f8eb0e29ef657cde66c7,43aa456be1468b5e8be9e4a18675a5ca4cdf70e7..5ea101fb251d27eadac20c665a7f01fb210c20d1
+++ b/config.c
  
  #define MAXNAME (256)
  
 -static FILE *config_file;
 -static const char *config_file_name;
 -static int config_linenr;
 -static int config_file_eof;
 +typedef struct config_file {
 +      struct config_file *prev;
 +      FILE *f;
 +      const char *name;
 +      int linenr;
 +      int eof;
 +      struct strbuf value;
 +      char var[MAXNAME];
 +} config_file;
 +
 +static config_file *cf;
 +
  static int zlib_compression_seen;
  
  const char *config_exclusive_filename = NULL;
@@@ -47,13 -39,13 +47,13 @@@ void git_config_push_parameter(const ch
        strbuf_release(&env);
  }
  
 -static int git_config_parse_parameter(const char *text,
 -                                    config_fn_t fn, void *data)
 +int git_config_parse_parameter(const char *text,
 +                             config_fn_t fn, void *data)
  {
 -      struct strbuf tmp = STRBUF_INIT;
        struct strbuf **pair;
 -      strbuf_addstr(&tmp, text);
 -      pair = strbuf_split(&tmp, '=');
 +      pair = strbuf_split_str(text, '=', 2);
 +      if (!pair[0])
 +              return error("bogus config parameter: %s", text);
        if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
                strbuf_setlen(pair[0], pair[0]->len - 1);
        strbuf_trim(pair[0]);
@@@ -107,7 -99,7 +107,7 @@@ static int get_next_char(void
        FILE *f;
  
        c = '\n';
 -      if ((f = config_file) != NULL) {
 +      if (cf && ((f = cf->f) != NULL)) {
                c = fgetc(f);
                if (c == '\r') {
                        /* DOS like systems */
                        }
                }
                if (c == '\n')
 -                      config_linenr++;
 +                      cf->linenr++;
                if (c == EOF) {
 -                      config_file_eof = 1;
 +                      cf->eof = 1;
                        c = '\n';
                }
        }
  
  static char *parse_value(void)
  {
 -      static struct strbuf value = STRBUF_INIT;
        int quote = 0, comment = 0, space = 0;
  
 -      strbuf_reset(&value);
 +      strbuf_reset(&cf->value);
        for (;;) {
                int c = get_next_char();
                if (c == '\n') {
                        if (quote)
                                return NULL;
 -                      return value.buf;
 +                      return cf->value.buf;
                }
                if (comment)
                        continue;
                if (isspace(c) && !quote) {
 -                      if (value.len)
 +                      if (cf->value.len)
                                space++;
                        continue;
                }
                        }
                }
                for (; space; space--)
 -                      strbuf_addch(&value, ' ');
 +                      strbuf_addch(&cf->value, ' ');
                if (c == '\\') {
                        c = get_next_char();
                        switch (c) {
                        default:
                                return NULL;
                        }
 -                      strbuf_addch(&value, c);
 +                      strbuf_addch(&cf->value, c);
                        continue;
                }
                if (c == '"') {
                        quote = 1-quote;
                        continue;
                }
 -              strbuf_addch(&value, c);
 +              strbuf_addch(&cf->value, c);
        }
  }
  
@@@ -199,7 -192,7 +199,7 @@@ static int get_value(config_fn_t fn, vo
        /* Get the full name */
        for (;;) {
                c = get_next_char();
 -              if (config_file_eof)
 +              if (cf->eof)
                        break;
                if (!iskeychar(c))
                        break;
@@@ -263,7 -256,7 +263,7 @@@ static int get_base_var(char *name
  
        for (;;) {
                int c = get_next_char();
 -              if (config_file_eof)
 +              if (cf->eof)
                        return -1;
                if (c == ']')
                        return baselen;
@@@ -281,7 -274,7 +281,7 @@@ static int git_parse_file(config_fn_t f
  {
        int comment = 0;
        int baselen = 0;
 -      static char var[MAXNAME];
 +      char *var = cf->var;
  
        /* U+FEFF Byte Order Mark in UTF8 */
        static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
                        }
                }
                if (c == '\n') {
 -                      if (config_file_eof)
 +                      if (cf->eof)
                                return 0;
                        comment = 0;
                        continue;
                if (get_value(fn, data, var, baselen+1) < 0)
                        break;
        }
 -      die("bad config file line %d in %s", config_linenr, config_file_name);
 +      die("bad config file line %d in %s", cf->linenr, cf->name);
  }
  
- static int parse_unit_factor(const char *end, unsigned long *val)
+ static int parse_unit_factor(const char *end, uintmax_t *val)
  {
        if (!*end)
                return 1;
@@@ -356,11 -349,23 +356,23 @@@ static int git_parse_long(const char *v
  {
        if (value && *value) {
                char *end;
-               long val = strtol(value, &end, 0);
-               unsigned long factor = 1;
+               intmax_t val;
+               uintmax_t uval;
+               uintmax_t factor = 1;
+               errno = 0;
+               val = strtoimax(value, &end, 0);
+               if (errno == ERANGE)
+                       return 0;
                if (!parse_unit_factor(end, &factor))
                        return 0;
-               *ret = val * factor;
+               uval = abs(val);
+               uval *= factor;
+               if ((uval > maximum_signed_value_of_type(long)) ||
+                   (abs(val) > uval))
+                       return 0;
+               val *= factor;
+               *ret = val;
                return 1;
        }
        return 0;
@@@ -370,9 -375,19 +382,19 @@@ int git_parse_ulong(const char *value, 
  {
        if (value && *value) {
                char *end;
-               unsigned long val = strtoul(value, &end, 0);
+               uintmax_t val;
+               uintmax_t oldval;
+               errno = 0;
+               val = strtoumax(value, &end, 0);
+               if (errno == ERANGE)
+                       return 0;
+               oldval = val;
                if (!parse_unit_factor(end, &val))
                        return 0;
+               if ((val > maximum_unsigned_value_of_type(long)) ||
+                   (oldval > val))
+                       return 0;
                *ret = val;
                return 1;
        }
  
  static void die_bad_config(const char *name)
  {
 -      if (config_file_name)
 -              die("bad config value for '%s' in %s", name, config_file_name);
 +      if (cf && cf->name)
 +              die("bad config value for '%s' in %s", name, cf->name);
        die("bad config value for '%s'", name);
  }
  
@@@ -491,9 -506,6 +513,9 @@@ static int git_default_core_config(cons
                return 0;
        }
  
 +      if (!strcmp(var, "core.attributesfile"))
 +              return git_config_pathname(&git_attributes_file, var, value);
 +
        if (!strcmp(var, "core.bare")) {
                is_bare_repository_cfg = git_config_bool(var, value);
                return 0;
  
        if (!strcmp(var, "core.packedgitwindowsize")) {
                int pgsz_x2 = getpagesize() * 2;
-               packed_git_window_size = git_config_int(var, value);
+               packed_git_window_size = git_config_ulong(var, value);
  
                /* This value must be multiple of (pagesize * 2) */
                packed_git_window_size /= pgsz_x2;
        }
  
        if (!strcmp(var, "core.bigfilethreshold")) {
-               long n = git_config_int(var, value);
-               big_file_threshold = 0 < n ? n : 0;
+               big_file_threshold = git_config_ulong(var, value);
                return 0;
        }
  
        if (!strcmp(var, "core.packedgitlimit")) {
-               packed_git_limit = git_config_int(var, value);
+               packed_git_limit = git_config_ulong(var, value);
                return 0;
        }
  
        if (!strcmp(var, "core.deltabasecachelimit")) {
-               delta_base_cache_limit = git_config_int(var, value);
+               delta_base_cache_limit = git_config_ulong(var, value);
                return 0;
        }
  
 +      if (!strcmp(var, "core.logpackaccess"))
 +              return git_config_string(&log_pack_access, var, value);
 +
        if (!strcmp(var, "core.autocrlf")) {
                if (value && !strcasecmp(value, "input")) {
                        if (core_eol == EOL_CRLF)
@@@ -808,24 -816,13 +829,24 @@@ int git_config_from_file(config_fn_t fn
  
        ret = -1;
        if (f) {
 -              config_file = f;
 -              config_file_name = filename;
 -              config_linenr = 1;
 -              config_file_eof = 0;
 +              config_file top;
 +
 +              /* push config-file parsing state stack */
 +              top.prev = cf;
 +              top.f = f;
 +              top.name = filename;
 +              top.linenr = 1;
 +              top.eof = 0;
 +              strbuf_init(&top.value, 1024);
 +              cf = &top;
 +
                ret = git_parse_file(fn, data);
 +
 +              /* pop config-file parsing state stack */
 +              strbuf_release(&top.value);
 +              cf = top.prev;
 +
                fclose(f);
 -              config_file_name = NULL;
        }
        return ret;
  }
@@@ -865,12 -862,12 +886,12 @@@ int git_config_early(config_fn_t fn, vo
  
        home = getenv("HOME");
        if (home) {
 -              char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
 +              char buf[PATH_MAX];
 +              char *user_config = mksnpath(buf, sizeof(buf), "%s/.gitconfig", home);
                if (!access(user_config, R_OK)) {
                        ret += git_config_from_file(fn, user_config, data);
                        found += 1;
                }
 -              free(user_config);
        }
  
        if (repo_config && !access(repo_config, R_OK)) {
  
        switch (git_config_from_parameters(fn, data)) {
        case -1: /* error */
 -              ret--;
 +              die("unable to parse command-line config");
                break;
        case 0: /* found nothing */
                break;
@@@ -933,7 -930,6 +954,7 @@@ static int store_aux(const char *key, c
  {
        const char *ep;
        size_t section_len;
 +      FILE *f = cf->f;
  
        switch (store.state) {
        case KEY_SEEN:
                                return 1;
                        }
  
 -                      store.offset[store.seen] = ftell(config_file);
 +                      store.offset[store.seen] = ftell(f);
                        store.seen++;
                }
                break;
                 * Do not increment matches: this is no match, but we
                 * just made sure we are in the desired section.
                 */
 -              store.offset[store.seen] = ftell(config_file);
 +              store.offset[store.seen] = ftell(f);
                /* fallthru */
        case SECTION_END_SEEN:
        case START:
                if (matches(key, value)) {
 -                      store.offset[store.seen] = ftell(config_file);
 +                      store.offset[store.seen] = ftell(f);
                        store.state = KEY_SEEN;
                        store.seen++;
                } else {
                        if (strrchr(key, '.') - key == store.baselen &&
                              !strncmp(key, store.key, store.baselen)) {
                                        store.state = SECTION_SEEN;
 -                                      store.offset[store.seen] = ftell(config_file);
 +                                      store.offset[store.seen] = ftell(f);
                        }
                }
        }
@@@ -1098,12 -1094,6 +1119,12 @@@ contline
        return offset;
  }
  
 +int git_config_set_in_file(const char *config_filename,
 +                      const char *key, const char *value)
 +{
 +      return git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);
 +}
 +
  int git_config_set(const char *key, const char *value)
  {
        return git_config_set_multivar(key, value, NULL, 0);
@@@ -1201,14 -1191,19 +1222,14 @@@ out_free_ret_1
   * - the config file is removed and the lock file rename()d to it.
   *
   */
 -int git_config_set_multivar(const char *key, const char *value,
 -      const char *value_regex, int multi_replace)
 +int git_config_set_multivar_in_file(const char *config_filename,
 +                              const char *key, const char *value,
 +                              const char *value_regex, int multi_replace)
  {
        int fd = -1, in_fd;
        int ret;
 -      char *config_filename;
        struct lock_file *lock = NULL;
  
 -      if (config_exclusive_filename)
 -              config_filename = xstrdup(config_exclusive_filename);
 -      else
 -              config_filename = git_pathdup("config");
 -
        /* parse-key returns negative; flip the sign to feed exit(3) */
        ret = 0 - git_config_parse_key(key, &store.key, &store.baselen);
        if (ret)
  out_free:
        if (lock)
                rollback_lock_file(lock);
 -      free(config_filename);
        return ret;
  
  write_err_out:
  
  }
  
 +int git_config_set_multivar(const char *key, const char *value,
 +                      const char *value_regex, int multi_replace)
 +{
 +      const char *config_filename;
 +      char *buf = NULL;
 +      int ret;
 +
 +      if (config_exclusive_filename)
 +              config_filename = config_exclusive_filename;
 +      else
 +              config_filename = buf = git_pathdup("config");
 +
 +      ret = git_config_set_multivar_in_file(config_filename, key, value,
 +                                      value_regex, multi_replace);
 +      free(buf);
 +      return ret;
 +}
 +
  static int section_name_match (const char *buf, const char *name)
  {
        int i = 0, j = 0, dot = 0;
@@@ -1458,7 -1436,6 +1479,7 @@@ int git_config_rename_section(const cha
        struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
        int out_fd;
        char buf[1024];
 +      FILE *config_file;
  
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
                }
        }
        fclose(config_file);
 - unlock_and_out:
 +unlock_and_out:
        if (commit_lock_file(lock) < 0)
                ret = error("could not commit config file %s", config_filename);
 - out:
 +out:
        free(config_filename);
        return ret;
  }
diff --combined git-compat-util.h
index 8b4dd5c022a160de5c68d83b6237799c23e6ae0a,23f760331f9242e77fda10fce52f4c3b5be60676..230e198fc35390fbccb496d2b74425382439dc4a
@@@ -215,14 -215,10 +215,14 @@@ extern char *gitbasename(char *)
  #define is_dir_sep(c) ((c) == '/')
  #endif
  
 -#if __HP_cc >= 61000
 +#ifndef find_last_dir_sep
 +#define find_last_dir_sep(path) strrchr(path, '/')
 +#endif
 +
 +#if defined(__HP_cc) && (__HP_cc >= 61000)
  #define NORETURN __attribute__((noreturn))
  #define NORETURN_PTR
 -#elif defined(__GNUC__)
 +#elif defined(__GNUC__) && !defined(NO_NORETURN)
  #define NORETURN __attribute__((__noreturn__))
  #define NORETURN_PTR __attribute__((__noreturn__))
  #elif defined(_MSC_VER)
  
  /* General helper functions */
  extern void vreportf(const char *prefix, const char *err, va_list params);
 +extern void vwritef(int fd, const char *prefix, const char *err, va_list params);
  extern NORETURN void usage(const char *err);
  extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
  extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
@@@ -249,7 -244,6 +249,7 @@@ extern int error(const char *err, ...) 
  extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
  
  extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
 +extern void set_error_routine(void (*routine)(const char *err, va_list params));
  
  extern int prefixcmp(const char *str, const char *prefix);
  extern int suffixcmp(const char *str, const char *suffix);
@@@ -351,6 -345,8 +351,8 @@@ extern size_t gitstrlcpy(char *, const 
  #ifdef NO_STRTOUMAX
  #define strtoumax gitstrtoumax
  extern uintmax_t gitstrtoumax(const char *, char **, int);
+ #define strtoimax gitstrtoimax
+ extern intmax_t gitstrtoimax(const char *, char **, int);
  #endif
  
  #ifdef NO_STRTOK_R