]> rtime.felk.cvut.cz Git - git.git/commitdiff
Sync with 1.7.0.4
authorJunio C Hamano <gitster@pobox.com>
Wed, 31 Mar 2010 22:14:27 +0000 (15:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 31 Mar 2010 22:14:27 +0000 (15:14 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1  2 
Makefile
builtin/reset.c
compat/mingw.c
diff.c
gitweb/gitweb.perl

diff --combined Makefile
index 3a6c6ea5259693db4846b91855675218b1e1a920,b07cd8a68146047ed3e7a5a17a420ad0ff5576f8..8a0f5c4d5b9a7c6c3617708014417b918c0ef034
+++ b/Makefile
@@@ -214,13 -214,6 +214,13 @@@ all:
  #   DEFAULT_EDITOR='~/bin/vi',
  #   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 CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 +# dependency rules.
  
  GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@@ -308,7 -301,7 +308,7 @@@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__pow
  # Those must not be GNU-specific; they are shared with perl/ which may
  # be built by a different compiler. (Note that this is an artifact now
  # but it still might be nice to keep that distinction.)
 -BASIC_CFLAGS =
 +BASIC_CFLAGS = -I.
  BASIC_LDFLAGS =
  
  # Guard against environment variables
@@@ -316,16 -309,13 +316,16 @@@ BUILTIN_OBJS 
  BUILT_INS =
  COMPAT_CFLAGS =
  COMPAT_OBJS =
 +EXTRA_CPPFLAGS =
  LIB_H =
  LIB_OBJS =
 +PROGRAM_OBJS =
  PROGRAMS =
  SCRIPT_PERL =
  SCRIPT_PYTHON =
  SCRIPT_SH =
 -TEST_PROGRAMS =
 +SCRIPT_LIB =
 +TEST_PROGRAMS_NEED_X =
  
  # Having this variable in your environment would break pipelines because
  # you cause "cd" to echo its destination to stdout.  It can also take
@@@ -342,20 -332,20 +342,20 @@@ SCRIPT_SH += git-merge-octopus.s
  SCRIPT_SH += git-merge-one-file.sh
  SCRIPT_SH += git-merge-resolve.sh
  SCRIPT_SH += git-mergetool.sh
 -SCRIPT_SH += git-mergetool--lib.sh
 -SCRIPT_SH += git-notes.sh
 -SCRIPT_SH += git-parse-remote.sh
  SCRIPT_SH += git-pull.sh
  SCRIPT_SH += git-quiltimport.sh
  SCRIPT_SH += git-rebase--interactive.sh
  SCRIPT_SH += git-rebase.sh
  SCRIPT_SH += git-repack.sh
  SCRIPT_SH += git-request-pull.sh
 -SCRIPT_SH += git-sh-setup.sh
  SCRIPT_SH += git-stash.sh
  SCRIPT_SH += git-submodule.sh
  SCRIPT_SH += git-web--browse.sh
  
 +SCRIPT_LIB += git-mergetool--lib
 +SCRIPT_LIB += git-parse-remote
 +SCRIPT_LIB += git-sh-setup
 +
  SCRIPT_PERL += git-add--interactive.perl
  SCRIPT_PERL += git-difftool.perl
  SCRIPT_PERL += git-archimport.perl
@@@ -376,35 -366,16 +376,35 @@@ EXTRA_PROGRAMS 
  
  # ... and all the rest that could be moved out of bindir to gitexecdir
  PROGRAMS += $(EXTRA_PROGRAMS)
 -PROGRAMS += git-fast-import$X
 -PROGRAMS += git-imap-send$X
 -PROGRAMS += git-shell$X
 -PROGRAMS += git-show-index$X
 -PROGRAMS += git-upload-pack$X
 -PROGRAMS += git-http-backend$X
 +
 +PROGRAM_OBJS += fast-import.o
 +PROGRAM_OBJS += imap-send.o
 +PROGRAM_OBJS += shell.o
 +PROGRAM_OBJS += show-index.o
 +PROGRAM_OBJS += upload-pack.o
 +PROGRAM_OBJS += http-backend.o
 +
 +PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 +
 +TEST_PROGRAMS_NEED_X += test-chmtime
 +TEST_PROGRAMS_NEED_X += test-ctype
 +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-genrandom
 +TEST_PROGRAMS_NEED_X += test-match-trees
 +TEST_PROGRAMS_NEED_X += test-parse-options
 +TEST_PROGRAMS_NEED_X += test-path-utils
 +TEST_PROGRAMS_NEED_X += test-run-command
 +TEST_PROGRAMS_NEED_X += test-sha1
 +TEST_PROGRAMS_NEED_X += test-sigchain
 +TEST_PROGRAMS_NEED_X += test-index-version
 +
 +TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
  
  # List built-in command $C whose implementation cmd_$C() is not in
 -# builtin-$C.o but is linked in as part of some other command.
 -BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 +# builtin/$C.o but is linked in as part of some other command.
 +BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS))
  
  BUILT_INS += git-cherry$X
  BUILT_INS += git-cherry-pick$X
@@@ -460,7 -431,6 +460,7 @@@ LIB_H += blob.
  LIB_H += builtin.h
  LIB_H += cache.h
  LIB_H += cache-tree.h
 +LIB_H += color.h
  LIB_H += commit.h
  LIB_H += compat/bswap.h
  LIB_H += compat/cygwin.h
@@@ -472,7 -442,6 +472,7 @@@ LIB_H += delta.
  LIB_H += diffcore.h
  LIB_H += diff.h
  LIB_H += dir.h
 +LIB_H += exec_cmd.h
  LIB_H += fsck.h
  LIB_H += git-compat-util.h
  LIB_H += graph.h
@@@ -515,8 -484,7 +515,8 @@@ LIB_H += tree-walk.
  LIB_H += unpack-trees.h
  LIB_H += userdiff.h
  LIB_H += utf8.h
 -LIB_H += wt-status.h
 +LIB_H += xdiff-interface.h
 +LIB_H += xdiff/xdiff.h
  
  LIB_OBJS += abspath.o
  LIB_OBJS += advice.o
@@@ -630,96 -598,95 +630,96 @@@ LIB_OBJS += ws.
  LIB_OBJS += wt-status.o
  LIB_OBJS += xdiff-interface.o
  
 -BUILTIN_OBJS += builtin-add.o
 -BUILTIN_OBJS += builtin-annotate.o
 -BUILTIN_OBJS += builtin-apply.o
 -BUILTIN_OBJS += builtin-archive.o
 -BUILTIN_OBJS += builtin-bisect--helper.o
 -BUILTIN_OBJS += builtin-blame.o
 -BUILTIN_OBJS += builtin-branch.o
 -BUILTIN_OBJS += builtin-bundle.o
 -BUILTIN_OBJS += builtin-cat-file.o
 -BUILTIN_OBJS += builtin-check-attr.o
 -BUILTIN_OBJS += builtin-check-ref-format.o
 -BUILTIN_OBJS += builtin-checkout-index.o
 -BUILTIN_OBJS += builtin-checkout.o
 -BUILTIN_OBJS += builtin-clean.o
 -BUILTIN_OBJS += builtin-clone.o
 -BUILTIN_OBJS += builtin-commit-tree.o
 -BUILTIN_OBJS += builtin-commit.o
 -BUILTIN_OBJS += builtin-config.o
 -BUILTIN_OBJS += builtin-count-objects.o
 -BUILTIN_OBJS += builtin-describe.o
 -BUILTIN_OBJS += builtin-diff-files.o
 -BUILTIN_OBJS += builtin-diff-index.o
 -BUILTIN_OBJS += builtin-diff-tree.o
 -BUILTIN_OBJS += builtin-diff.o
 -BUILTIN_OBJS += builtin-fast-export.o
 -BUILTIN_OBJS += builtin-fetch-pack.o
 -BUILTIN_OBJS += builtin-fetch.o
 -BUILTIN_OBJS += builtin-fmt-merge-msg.o
 -BUILTIN_OBJS += builtin-for-each-ref.o
 -BUILTIN_OBJS += builtin-fsck.o
 -BUILTIN_OBJS += builtin-gc.o
 -BUILTIN_OBJS += builtin-grep.o
 -BUILTIN_OBJS += builtin-hash-object.o
 -BUILTIN_OBJS += builtin-help.o
 -BUILTIN_OBJS += builtin-index-pack.o
 -BUILTIN_OBJS += builtin-init-db.o
 -BUILTIN_OBJS += builtin-log.o
 -BUILTIN_OBJS += builtin-ls-files.o
 -BUILTIN_OBJS += builtin-ls-remote.o
 -BUILTIN_OBJS += builtin-ls-tree.o
 -BUILTIN_OBJS += builtin-mailinfo.o
 -BUILTIN_OBJS += builtin-mailsplit.o
 -BUILTIN_OBJS += builtin-merge.o
 -BUILTIN_OBJS += builtin-merge-base.o
 -BUILTIN_OBJS += builtin-merge-file.o
 -BUILTIN_OBJS += builtin-merge-index.o
 -BUILTIN_OBJS += builtin-merge-ours.o
 -BUILTIN_OBJS += builtin-merge-recursive.o
 -BUILTIN_OBJS += builtin-merge-tree.o
 -BUILTIN_OBJS += builtin-mktag.o
 -BUILTIN_OBJS += builtin-mktree.o
 -BUILTIN_OBJS += builtin-mv.o
 -BUILTIN_OBJS += builtin-name-rev.o
 -BUILTIN_OBJS += builtin-pack-objects.o
 -BUILTIN_OBJS += builtin-pack-redundant.o
 -BUILTIN_OBJS += builtin-pack-refs.o
 -BUILTIN_OBJS += builtin-patch-id.o
 -BUILTIN_OBJS += builtin-prune-packed.o
 -BUILTIN_OBJS += builtin-prune.o
 -BUILTIN_OBJS += builtin-push.o
 -BUILTIN_OBJS += builtin-read-tree.o
 -BUILTIN_OBJS += builtin-receive-pack.o
 -BUILTIN_OBJS += builtin-reflog.o
 -BUILTIN_OBJS += builtin-remote.o
 -BUILTIN_OBJS += builtin-replace.o
 -BUILTIN_OBJS += builtin-rerere.o
 -BUILTIN_OBJS += builtin-reset.o
 -BUILTIN_OBJS += builtin-rev-list.o
 -BUILTIN_OBJS += builtin-rev-parse.o
 -BUILTIN_OBJS += builtin-revert.o
 -BUILTIN_OBJS += builtin-rm.o
 -BUILTIN_OBJS += builtin-send-pack.o
 -BUILTIN_OBJS += builtin-shortlog.o
 -BUILTIN_OBJS += builtin-show-branch.o
 -BUILTIN_OBJS += builtin-show-ref.o
 -BUILTIN_OBJS += builtin-stripspace.o
 -BUILTIN_OBJS += builtin-symbolic-ref.o
 -BUILTIN_OBJS += builtin-tag.o
 -BUILTIN_OBJS += builtin-tar-tree.o
 -BUILTIN_OBJS += builtin-unpack-file.o
 -BUILTIN_OBJS += builtin-unpack-objects.o
 -BUILTIN_OBJS += builtin-update-index.o
 -BUILTIN_OBJS += builtin-update-ref.o
 -BUILTIN_OBJS += builtin-update-server-info.o
 -BUILTIN_OBJS += builtin-upload-archive.o
 -BUILTIN_OBJS += builtin-var.o
 -BUILTIN_OBJS += builtin-verify-pack.o
 -BUILTIN_OBJS += builtin-verify-tag.o
 -BUILTIN_OBJS += builtin-write-tree.o
 +BUILTIN_OBJS += builtin/add.o
 +BUILTIN_OBJS += builtin/annotate.o
 +BUILTIN_OBJS += builtin/apply.o
 +BUILTIN_OBJS += builtin/archive.o
 +BUILTIN_OBJS += builtin/bisect--helper.o
 +BUILTIN_OBJS += builtin/blame.o
 +BUILTIN_OBJS += builtin/branch.o
 +BUILTIN_OBJS += builtin/bundle.o
 +BUILTIN_OBJS += builtin/cat-file.o
 +BUILTIN_OBJS += builtin/check-attr.o
 +BUILTIN_OBJS += builtin/check-ref-format.o
 +BUILTIN_OBJS += builtin/checkout-index.o
 +BUILTIN_OBJS += builtin/checkout.o
 +BUILTIN_OBJS += builtin/clean.o
 +BUILTIN_OBJS += builtin/clone.o
 +BUILTIN_OBJS += builtin/commit-tree.o
 +BUILTIN_OBJS += builtin/commit.o
 +BUILTIN_OBJS += builtin/config.o
 +BUILTIN_OBJS += builtin/count-objects.o
 +BUILTIN_OBJS += builtin/describe.o
 +BUILTIN_OBJS += builtin/diff-files.o
 +BUILTIN_OBJS += builtin/diff-index.o
 +BUILTIN_OBJS += builtin/diff-tree.o
 +BUILTIN_OBJS += builtin/diff.o
 +BUILTIN_OBJS += builtin/fast-export.o
 +BUILTIN_OBJS += builtin/fetch-pack.o
 +BUILTIN_OBJS += builtin/fetch.o
 +BUILTIN_OBJS += builtin/fmt-merge-msg.o
 +BUILTIN_OBJS += builtin/for-each-ref.o
 +BUILTIN_OBJS += builtin/fsck.o
 +BUILTIN_OBJS += builtin/gc.o
 +BUILTIN_OBJS += builtin/grep.o
 +BUILTIN_OBJS += builtin/hash-object.o
 +BUILTIN_OBJS += builtin/help.o
 +BUILTIN_OBJS += builtin/index-pack.o
 +BUILTIN_OBJS += builtin/init-db.o
 +BUILTIN_OBJS += builtin/log.o
 +BUILTIN_OBJS += builtin/ls-files.o
 +BUILTIN_OBJS += builtin/ls-remote.o
 +BUILTIN_OBJS += builtin/ls-tree.o
 +BUILTIN_OBJS += builtin/mailinfo.o
 +BUILTIN_OBJS += builtin/mailsplit.o
 +BUILTIN_OBJS += builtin/merge.o
 +BUILTIN_OBJS += builtin/merge-base.o
 +BUILTIN_OBJS += builtin/merge-file.o
 +BUILTIN_OBJS += builtin/merge-index.o
 +BUILTIN_OBJS += builtin/merge-ours.o
 +BUILTIN_OBJS += builtin/merge-recursive.o
 +BUILTIN_OBJS += builtin/merge-tree.o
 +BUILTIN_OBJS += builtin/mktag.o
 +BUILTIN_OBJS += builtin/mktree.o
 +BUILTIN_OBJS += builtin/mv.o
 +BUILTIN_OBJS += builtin/name-rev.o
 +BUILTIN_OBJS += builtin/notes.o
 +BUILTIN_OBJS += builtin/pack-objects.o
 +BUILTIN_OBJS += builtin/pack-redundant.o
 +BUILTIN_OBJS += builtin/pack-refs.o
 +BUILTIN_OBJS += builtin/patch-id.o
 +BUILTIN_OBJS += builtin/prune-packed.o
 +BUILTIN_OBJS += builtin/prune.o
 +BUILTIN_OBJS += builtin/push.o
 +BUILTIN_OBJS += builtin/read-tree.o
 +BUILTIN_OBJS += builtin/receive-pack.o
 +BUILTIN_OBJS += builtin/reflog.o
 +BUILTIN_OBJS += builtin/remote.o
 +BUILTIN_OBJS += builtin/replace.o
 +BUILTIN_OBJS += builtin/rerere.o
 +BUILTIN_OBJS += builtin/reset.o
 +BUILTIN_OBJS += builtin/rev-list.o
 +BUILTIN_OBJS += builtin/rev-parse.o
 +BUILTIN_OBJS += builtin/revert.o
 +BUILTIN_OBJS += builtin/rm.o
 +BUILTIN_OBJS += builtin/send-pack.o
 +BUILTIN_OBJS += builtin/shortlog.o
 +BUILTIN_OBJS += builtin/show-branch.o
 +BUILTIN_OBJS += builtin/show-ref.o
 +BUILTIN_OBJS += builtin/stripspace.o
 +BUILTIN_OBJS += builtin/symbolic-ref.o
 +BUILTIN_OBJS += builtin/tag.o
 +BUILTIN_OBJS += builtin/tar-tree.o
 +BUILTIN_OBJS += builtin/unpack-file.o
 +BUILTIN_OBJS += builtin/unpack-objects.o
 +BUILTIN_OBJS += builtin/update-index.o
 +BUILTIN_OBJS += builtin/update-ref.o
 +BUILTIN_OBJS += builtin/update-server-info.o
 +BUILTIN_OBJS += builtin/upload-archive.o
 +BUILTIN_OBJS += builtin/var.o
 +BUILTIN_OBJS += builtin/verify-pack.o
 +BUILTIN_OBJS += builtin/verify-tag.o
 +BUILTIN_OBJS += builtin/write-tree.o
  
  GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
  EXTLIBS =
@@@ -919,6 -886,7 +919,7 @@@ ifeq ($(uname_S),IRIX
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH = /usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
+       NEEDS_LIBICONV = YesPlease
  endif
  ifeq ($(uname_S),IRIX64)
        NO_SETENV=YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
+       NEEDS_LIBICONV = YesPlease
  endif
  ifeq ($(uname_S),HP-UX)
        NO_IPV6=YesPlease
@@@ -1059,14 -1028,6 +1061,14 @@@ endi
  -include config.mak.autogen
  -include config.mak
  
 +ifdef CHECK_HEADER_DEPENDENCIES
 +USE_COMPUTED_HEADER_DEPENDENCIES =
 +endif
 +
 +ifdef COMPUTE_HEADER_DEPENDENCIES
 +USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
 +endif
 +
  ifdef SANE_TOOL_PATH
  SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
  BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
        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)
 -      PROGRAMS += $(REMOTE_CURL_NAMES) git-http-fetch$X
 +      PROGRAM_OBJS += http-fetch.o
 +      PROGRAMS += $(REMOTE_CURL_NAMES)
        curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "070908"
                ifndef NO_EXPAT
 -                      PROGRAMS += git-http-push$X
 +                      PROGRAM_OBJS += http-push.o
                endif
        endif
        ifndef NO_EXPAT
@@@ -1147,7 -1107,7 +1149,7 @@@ endi
  EXTLIBS += -lz
  
  ifndef NO_POSIX_ONLY_PROGRAMS
 -      PROGRAMS += git-daemon$X
 +      PROGRAM_OBJS += daemon.o
  endif
  ifndef NO_OPENSSL
        OPENSSL_LIBSSL = -lssl
@@@ -1313,12 -1273,10 +1315,12 @@@ endi
  ifdef BLK_SHA1
        SHA1_HEADER = "block-sha1/sha1.h"
        LIB_OBJS += block-sha1/sha1.o
 +      LIB_H += block-sha1/sha1.h
  else
  ifdef PPC_SHA1
        SHA1_HEADER = "ppc/sha1.h"
        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 +      LIB_H += ppc/sha1.h
  else
        SHA1_HEADER = <openssl/sha.h>
        EXTLIBS += $(LIB_4_CRYPTO)
@@@ -1460,7 -1418,7 +1462,7 @@@ export TAR INSTALL DESTDIR SHELL_PAT
  
  SHELL = $(SHELL_PATH)
  
 -all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
 +all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
  ifneq (,$X)
        $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
  endif
@@@ -1487,15 -1445,15 +1489,15 @@@ strip: $(PROGRAMS) git$
        $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
  
  git.o: common-cmds.h
 -git.s git.o: ALL_CFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"' \
 +git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
        '-DGIT_HTML_PATH="$(htmldir_SQ)"'
  
  git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  
 -builtin-help.o: common-cmds.h
 -builtin-help.s builtin-help.o: ALL_CFLAGS += \
 +builtin/help.o: common-cmds.h
 +builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
        '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
        '-DGIT_MAN_PATH="$(mandir_SQ)"' \
        '-DGIT_INFO_PATH="$(infodir_SQ)"'
@@@ -1511,25 -1469,17 +1513,25 @@@ common-cmds.h: ./generate-cmdlist.sh co
  common-cmds.h: $(wildcard Documentation/git-*.txt)
        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
  
 +define cmd_munge_script
 +$(RM) $@ $@+ && \
 +sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 +    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
 +    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 +    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 +    -e $(BROKEN_PATH_FIX) \
 +    $@.sh >$@+
 +endef
 +
  $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 -      $(QUIET_GEN)$(RM) $@ $@+ && \
 -      sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 -          -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
 -          -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 -          -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 -          -e $(BROKEN_PATH_FIX) \
 -          $@.sh >$@+ && \
 +      $(QUIET_GEN)$(cmd_munge_script) && \
        chmod +x $@+ && \
        mv $@+ $@
  
 +$(SCRIPT_LIB) : % : %.sh
 +      $(QUIET_GEN)$(cmd_munge_script) && \
 +      mv $@+ $@
 +
  ifndef NO_PERL
  $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
  
@@@ -1639,148 -1589,28 +1641,148 @@@ git.o git.spec 
        $(patsubst %.perl,%,$(SCRIPT_PERL)) \
        : GIT-VERSION-FILE
  
 -%.o: %.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 +TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
 +GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
 +      git.o http.o http-walker.o remote-curl.o
 +XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 +      xdiff/xmerge.o xdiff/xpatience.o
 +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
 +$(dep_dirs):
 +      mkdir -p $@
 +
 +missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
 +dep_file = $(dir $@).depend/$(notdir $@).d
 +dep_args = -MF $(dep_file) -MMD -MP
 +ifdef CHECK_HEADER_DEPENDENCIES
 +$(error cannot compute header dependencies outside a normal build. \
 +Please unset CHECK_HEADER_DEPENDENCIES and try again)
 +endif
 +endif
 +
 +ifndef COMPUTE_HEADER_DEPENDENCIES
 +ifndef CHECK_HEADER_DEPENDENCIES
 +dep_dirs =
 +missing_dep_dirs =
 +dep_args =
 +endif
 +endif
 +
 +ifdef CHECK_HEADER_DEPENDENCIES
 +ifndef PRINT_HEADER_DEPENDENCIES
 +missing_deps = $(filter-out $(notdir $^), \
 +      $(notdir $(shell $(MAKE) -s $@ \
 +              CHECK_HEADER_DEPENDENCIES=YesPlease \
 +              USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
 +              PRINT_HEADER_DEPENDENCIES=YesPlease)))
 +endif
 +endif
 +
 +ASM_SRC := $(wildcard $(OBJECTS:o=S))
 +ASM_OBJ := $(ASM_SRC:S=o)
 +C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
 +
 +.SUFFIXES:
 +
 +ifdef PRINT_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c FORCE
 +      echo $^
 +$(ASM_OBJ): %.o: %.S FORCE
 +      echo $^
 +
 +ifndef CHECK_HEADER_DEPENDENCIES
 +$(error cannot print header dependencies during a normal build. \
 +Please set CHECK_HEADER_DEPENDENCIES and try again)
 +endif
 +endif
 +
 +ifndef PRINT_HEADER_DEPENDENCIES
 +ifdef CHECK_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c $(dep_files) FORCE
 +      @set -e; echo CHECK $@; \
 +      missing_deps="$(missing_deps)"; \
 +      if test "$$missing_deps"; \
 +      then \
 +              echo missing dependencies: $$missing_deps; \
 +              false; \
 +      fi
 +$(ASM_OBJ): %.o: %.S $(dep_files) FORCE
 +      @set -e; echo CHECK $@; \
 +      missing_deps="$(missing_deps)"; \
 +      if test "$$missing_deps"; \
 +      then \
 +              echo missing dependencies: $$missing_deps; \
 +              false; \
 +      fi
 +endif
 +endif
 +
 +ifndef CHECK_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
 +      $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 +$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
 +      $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 +endif
 +
  %.s: %.c GIT-CFLAGS FORCE
 -      $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
 -%.o: %.S GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 +      $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
  
 -exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
 +ifdef USE_COMPUTED_HEADER_DEPENDENCIES
 +# Take advantage of gcc's on-the-fly dependency generation
 +# See <http://gcc.gnu.org/gcc-3.0/features.html>.
 +dep_files_present := $(wildcard $(dep_files))
 +ifneq ($(dep_files_present),)
 +include $(dep_files_present)
 +endif
 +else
 +# Dependencies on header files, for platforms that do not support
 +# the gcc -MMD option.
 +#
 +# Dependencies on automatically generated headers such as common-cmds.h
 +# should _not_ be included here, since they are necessary even when
 +# building an object for the first time.
 +#
 +# XXX. Please check occasionally that these include all dependencies
 +# gcc detects!
 +
 +$(GIT_OBJS): $(LIB_H)
 +builtin/branch.o builtin/checkout.o builtin/clone.o builtin/reset.o branch.o transport.o: branch.h
 +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: 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
 +builtin/pack-objects.o: thread-utils.h
 +http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
 +http.o http-walker.o http-push.o remote-curl.o: http.h
 +
 +xdiff-interface.o $(XDIFF_OBJS): \
 +      xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 +      xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 +endif
 +
 +exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
        '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
        '-DBINDIR="$(bindir_relative_SQ)"' \
        '-DPREFIX="$(prefix_SQ)"'
  
 -builtin-init-db.s builtin-init-db.o: ALL_CFLAGS += \
 +builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
        -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
  
 -config.s config.o: ALL_CFLAGS += -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
 +config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
  
 -http.s http.o: ALL_CFLAGS += -DGIT_USER_AGENT='"git/$(GIT_VERSION)"'
 +http.s http.o: EXTRA_CPPFLAGS = -DGIT_USER_AGENT='"git/$(GIT_VERSION)"'
  
  ifdef NO_EXPAT
 -http-walker.o: http.h
 -http-walker.s http-walker.o: ALL_CFLAGS += -DNO_EXPAT
 +http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
  endif
  
  git-%$X: %.o $(GITLIBS)
@@@ -1790,6 -1620,10 +1792,6 @@@ git-imap-send$X: imap-send.o $(GITLIBS
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
  
 -http.o http-walker.o http-push.o: http.h
 -
 -http.o http-walker.o: $(LIB_H)
 -
  git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL)
@@@ -1807,9 -1641,18 +1809,9 @@@ $(REMOTE_CURL_PRIMARY): remote-curl.o h
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
  
 -$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
 -$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
 -builtin-revert.o wt-status.o: wt-status.h
 -
  $(LIB_FILE): $(LIB_OBJS)
        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
  
 -XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 -      xdiff/xmerge.o xdiff/xpatience.o
 -$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 -      xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 -
  $(XDIFF_LIB): $(XDIFF_OBJS)
        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
  
@@@ -1875,6 -1718,24 +1877,6 @@@ GIT-GUI-VARS: FORC
              fi
  endif
  
 -### Testing rules
 -
 -TEST_PROGRAMS_NEED_X += test-chmtime
 -TEST_PROGRAMS_NEED_X += test-ctype
 -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-genrandom
 -TEST_PROGRAMS_NEED_X += test-match-trees
 -TEST_PROGRAMS_NEED_X += test-parse-options
 -TEST_PROGRAMS_NEED_X += test-path-utils
 -TEST_PROGRAMS_NEED_X += test-run-command
 -TEST_PROGRAMS_NEED_X += test-sha1
 -TEST_PROGRAMS_NEED_X += test-sigchain
 -TEST_PROGRAMS_NEED_X += test-index-version
 -
 -TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 -
  test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
  
  all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@@ -1892,8 -1753,6 +1894,8 @@@ bin-wrappers/%: wrap-for-bin.s
  
  export NO_SVN_TESTS
  
 +### Testing rules
 +
  test: all
        $(MAKE) -C t/ all
  
@@@ -1905,7 -1764,9 +1907,7 @@@ test-delta$X: diff-delta.o patch-delta.
  
  test-parse-options$X: parse-options.o
  
 -test-parse-options.o: parse-options.h
 -
 -.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
 +.PRECIOUS: $(TEST_OBJS)
  
  test-%$X: test-%.o $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
@@@ -1951,7 -1812,6 +1953,7 @@@ install: al
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 +      $(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
  ifndef NO_PERL
@@@ -2070,11 -1930,10 +2072,11 @@@ distclean: clea
  
  clean:
        $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
 -              $(LIB_FILE) $(XDIFF_LIB)
 -      $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
 +              builtin/*.o $(LIB_FILE) $(XDIFF_LIB)
 +      $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
        $(RM) $(TEST_PROGRAMS)
        $(RM) -r bin-wrappers
 +      $(RM) -r $(dep_dirs)
        $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
        $(RM) -r autom4te.cache
        $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
@@@ -2104,13 -1963,12 +2106,13 @@@ endi
  ### Check documentation
  #
  check-docs::
 -      @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
 +      @(for v in $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git gitk; \
        do \
                case "$$v" in \
                git-merge-octopus | git-merge-ours | git-merge-recursive | \
                git-merge-resolve | git-merge-subtree | \
                git-fsck-objects | git-init-db | \
 +              git-remote-* | git-stage | \
                git-?*--?* ) continue ;; \
                esac ; \
                test -f "Documentation/$$v.txt" || \
                documented,gitrepository-layout | \
                documented,gittutorial | \
                documented,gittutorial-2 | \
 +              documented,git-bisect-lk2009 | \
 +              documented,git-remote-helpers | \
 +              documented,gitworkflows | \
                sentinel,not,matching,is,ok ) continue ;; \
                esac; \
 -              case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
 +              case " $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git gitk " in \
                *" $$cmd "*)    ;; \
                *) echo "removed but $$how: $$cmd" ;; \
                esac; \
diff --combined builtin/reset.c
index 2c3a69adc674bb3f539d29b2d29116e89f887066,a174a316102c6ed40b4cef24d7812220f6ac5d89..1283068fd24c371e39f0271d01dd6b3aac437d4b
  #include "cache-tree.h"
  
  static const char * const git_reset_usage[] = {
 -      "git reset [--mixed | --soft | --hard | --merge] [-q] [<commit>]",
 +      "git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]",
-       "git reset [--mixed] <commit> [--] <paths>...",
+       "git reset [-q] <commit> [--] <paths>...",
+       "git reset --patch [<commit>] [--] [<paths>...]",
        NULL
  };
  
 -enum reset_type { MIXED, SOFT, HARD, MERGE, NONE };
 -static const char *reset_type_names[] = { "mixed", "soft", "hard", "merge", NULL };
 +enum reset_type { MIXED, SOFT, HARD, MERGE, KEEP, NONE };
 +static const char *reset_type_names[] = {
 +      "mixed", "soft", "hard", "merge", "keep", NULL
 +};
  
  static char *args_to_str(const char **argv)
  {
@@@ -73,7 -72,6 +74,7 @@@ static int reset_index_file(const unsig
        if (!quiet)
                opts.verbose_update = 1;
        switch (reset_type) {
 +      case KEEP:
        case MERGE:
                opts.update = 1;
                break;
  
        read_cache_unmerged();
  
 +      if (reset_type == KEEP) {
 +              unsigned char head_sha1[20];
 +              if (get_sha1("HEAD", head_sha1))
 +                      return error("You do not have a valid HEAD.");
 +              if (!fill_tree_descriptor(desc, head_sha1))
 +                      return error("Failed to find tree of HEAD.");
 +              nr++;
 +              opts.fn = twoway_merge;
 +      }
 +
        if (!fill_tree_descriptor(desc + nr - 1, sha1))
                return error("Failed to find tree of %s.", sha1_to_hex(sha1));
        if (unpack_trees(nr, desc, &opts))
@@@ -224,14 -212,6 +225,14 @@@ static void prepend_reflog_action(cons
                warning("Reflog action message too long: %.*s...", 50, buf);
  }
  
 +static void die_if_unmerged_cache(int reset_type)
 +{
 +      if (is_merge() || read_cache() < 0 || unmerged_cache())
 +              die("Cannot do a %s reset in the middle of a merge.",
 +                  reset_type_names[reset_type]);
 +
 +}
 +
  int cmd_reset(int argc, const char **argv, const char *prefix)
  {
        int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0;
                                "reset HEAD, index and working tree", HARD),
                OPT_SET_INT(0, "merge", &reset_type,
                                "reset HEAD, index and working tree", MERGE),
 +              OPT_SET_INT(0, "keep", &reset_type,
 +                              "reset HEAD but keep local changes", KEEP),
                OPT_BOOLEAN('p', "patch", &patch_mode, "select hunks interactively"),
                OPT_END()
        };
        if (reset_type == NONE)
                reset_type = MIXED; /* by default */
  
 -      if (reset_type == HARD || reset_type == MERGE)
 +      if (reset_type != SOFT && reset_type != MIXED)
                setup_work_tree();
  
        if (reset_type == MIXED && is_bare_repository())
        /* Soft reset does not touch the index file nor the working tree
         * at all, but requires them in a good order.  Other resets reset
         * the index file to the tree object we are switching to. */
 -      if (reset_type == SOFT) {
 -              if (is_merge() || read_cache() < 0 || unmerged_cache())
 -                      die("Cannot do a soft reset in the middle of a merge.");
 +      if (reset_type == SOFT)
 +              die_if_unmerged_cache(reset_type);
 +      else {
 +              int err;
 +              if (reset_type == KEEP)
 +                      die_if_unmerged_cache(reset_type);
 +              err = reset_index_file(sha1, reset_type, quiet);
 +              if (reset_type == KEEP)
 +                      err = err || reset_index_file(sha1, MIXED, quiet);
 +              if (err)
 +                      die("Could not reset index file to revision '%s'.", rev);
        }
 -      else if (reset_index_file(sha1, reset_type, quiet))
 -              die("Could not reset index file to revision '%s'.", rev);
  
        /* Any resets update HEAD to the head being switched to,
         * saving the previous head in ORIG_HEAD before. */
diff --combined compat/mingw.c
index c5bfb39b3949430cd06093afdbc85ecc22f8c9c7,59b18dc7ca51180426a0dbf11e651a93c5eedc81..30716903f5c3072588ddaae71f557f14d7806fde
@@@ -140,22 -140,6 +140,22 @@@ int mingw_open (const char *filename, i
        return fd;
  }
  
 +#undef fopen
 +FILE *mingw_fopen (const char *filename, const char *otype)
 +{
 +      if (!strcmp(filename, "/dev/null"))
 +              filename = "nul";
 +      return fopen(filename, otype);
 +}
 +
 +#undef freopen
 +FILE *mingw_freopen (const char *filename, const char *otype, FILE *stream)
 +{
 +      if (filename && !strcmp(filename, "/dev/null"))
 +              filename = "nul";
 +      return freopen(filename, otype, stream);
 +}
 +
  /*
   * The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
   * Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
@@@ -275,8 -259,17 +275,17 @@@ int mingw_utime (const char *file_name
        int fh, rc;
  
        /* must have write permission */
-       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0)
-               return -1;
+       DWORD attrs = GetFileAttributes(file_name);
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors here; open() will report them */
+               SetFileAttributes(file_name, attrs & ~FILE_ATTRIBUTE_READONLY);
+       }
+       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0) {
+               rc = -1;
+               goto revert_attrs;
+       }
  
        time_t_to_filetime(times->modtime, &mft);
        time_t_to_filetime(times->actime, &aft);
        } else
                rc = 0;
        close(fh);
+ revert_attrs:
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors again */
+               SetFileAttributes(file_name, attrs);
+       }
        return rc;
  }
  
diff --combined diff.c
index f5d93e9694d2f5e78bfa3d8dc886968d7cdd5867,99059231b4e9d7eac9eb2d63ce6baa4d43190b95..2daa732a360b2e846791156be5ceb33b85b4eac9
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -2032,7 -2032,7 +2032,7 @@@ static int diff_populate_gitlink(struc
        char *data = xmalloc(100), *dirty = "";
  
        /* Are we looking at the work tree? */
 -      if (!s->sha1_valid && s->dirty_submodule)
 +      if (s->dirty_submodule)
                dirty = "-dirty";
  
        len = snprintf(data, 100,
@@@ -2628,12 -2628,6 +2628,12 @@@ int diff_setup_done(struct diff_option
         */
        if (options->pickaxe)
                DIFF_OPT_SET(options, RECURSIVE);
 +      /*
 +       * When patches are generated, submodules diffed against the work tree
 +       * must be checked for dirtiness too so it can be shown in the output
 +       */
 +      if (options->output_format & DIFF_FORMAT_PATCH)
 +              DIFF_OPT_SET(options, DIRTY_SUBMODULES);
  
        if (options->detect_rename && options->rename_limit < 0)
                options->rename_limit = diff_rename_limit_default;
@@@ -2832,15 -2826,6 +2832,15 @@@ int diff_opt_parse(struct diff_options 
                DIFF_OPT_SET(options, FOLLOW_RENAMES);
        else if (!strcmp(arg, "--color"))
                DIFF_OPT_SET(options, COLOR_DIFF);
 +      else if (!prefixcmp(arg, "--color=")) {
 +              int value = git_config_colorbool(NULL, arg+8, -1);
 +              if (value == 0)
 +                      DIFF_OPT_CLR(options, COLOR_DIFF);
 +              else if (value > 0)
 +                      DIFF_OPT_SET(options, COLOR_DIFF);
 +              else
 +                      return error("option `color' expects \"always\", \"auto\", or \"never\"");
 +      }
        else if (!strcmp(arg, "--no-color"))
                DIFF_OPT_CLR(options, COLOR_DIFF);
        else if (!strcmp(arg, "--color-words")) {
@@@ -3092,8 -3077,7 +3092,8 @@@ int diff_unmodified_pair(struct diff_fi
         * dealing with a change.
         */
        if (one->sha1_valid && two->sha1_valid &&
 -          !hashcmp(one->sha1, two->sha1))
 +          !hashcmp(one->sha1, two->sha1) &&
 +          !one->dirty_submodule && !two->dirty_submodule)
                return 1; /* no change */
        if (!one->sha1_valid && !two->sha1_valid)
                return 1; /* both look at the same file on the filesystem. */
@@@ -3228,8 -3212,6 +3228,8 @@@ static void diff_resolve_rename_copy(vo
                }
                else if (hashcmp(p->one->sha1, p->two->sha1) ||
                         p->one->mode != p->two->mode ||
 +                       p->one->dirty_submodule ||
 +                       p->two->dirty_submodule ||
                         is_null_sha1(p->one->sha1))
                        p->status = DIFF_STATUS_MODIFIED;
                else {
@@@ -3883,6 -3865,7 +3883,7 @@@ static char *run_textconv(const char *p
        const char **arg = argv;
        struct child_process child;
        struct strbuf buf = STRBUF_INIT;
+       int err = 0;
  
        temp = prepare_temp_file(spec->path, spec);
        *arg++ = pgm;
        child.use_shell = 1;
        child.argv = argv;
        child.out = -1;
-       if (start_command(&child) != 0 ||
-           strbuf_read(&buf, child.out, 0) < 0 ||
-           finish_command(&child) != 0) {
-               close(child.out);
-               strbuf_release(&buf);
+       if (start_command(&child)) {
                remove_tempfile();
-               error("error running textconv command '%s'", pgm);
                return NULL;
        }
+       if (strbuf_read(&buf, child.out, 0) < 0)
+               err = error("error reading from textconv command '%s'", pgm);
        close(child.out);
+       if (finish_command(&child) || err) {
+               strbuf_release(&buf);
+               remove_tempfile();
+               return NULL;
+       }
        remove_tempfile();
  
        return strbuf_detach(&buf, outsize);
diff --combined gitweb/gitweb.perl
index a2d2283ec921acac7b068537eb85f63c16de9556,9d4c58238ea87963221d948020e928d232c0d90d..c356e95f18f0f784584ce644c08e1966ca1be52f
@@@ -1150,7 -1150,6 +1150,7 @@@ sub validate_refname 
  # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
  sub to_utf8 {
        my $str = shift;
 +      return undef unless defined $str;
        if (utf8::valid($str)) {
                utf8::decode($str);
                return $str;
  # correct, but quoted slashes look too horrible in bookmarks
  sub esc_param {
        my $str = shift;
 +      return undef unless defined $str;
        $str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg;
        $str =~ s/ /\+/g;
        return $str;
  # quote unsafe chars in whole URL, so some charactrs cannot be quoted
  sub esc_url {
        my $str = shift;
 +      return undef unless defined $str;
        $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg;
        $str =~ s/\+/%2B/g;
        $str =~ s/ /\+/g;
@@@ -1184,8 -1181,6 +1184,8 @@@ sub esc_html 
        my $str = shift;
        my %opts = @_;
  
 +      return undef unless defined $str;
 +
        $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
@@@ -1200,8 -1195,6 +1200,8 @@@ sub esc_path 
        my $str = shift;
        my %opts = @_;
  
 +      return undef unless defined $str;
 +
        $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
@@@ -2216,8 -2209,7 +2216,7 @@@ sub config_to_multi 
  sub git_get_project_config {
        my ($key, $type) = @_;
  
-       # do we have project
-       return unless (defined $project && defined $git_dir);
+       return unless defined $git_dir;
  
        # key sanity check
        return unless ($key);
@@@ -3389,7 -3381,7 +3388,7 @@@ sub git_footer_html 
              "</html>";
  }
  
 -# die_error(<http_status_code>, <error_message>)
 +# die_error(<http_status_code>, <error_message>[, <detailed_html_description>])
  # Example: die_error(404, 'Hash not found')
  # By convention, use the following status codes (as defined in RFC 2616):
  # 400: Invalid or missing CGI parameters, or
  #      or down for maintenance).  Generally, this is a temporary state.
  sub die_error {
        my $status = shift || 500;
 -      my $error = shift || "Internal server error";
 +      my $error = esc_html(shift) || "Internal Server Error";
        my $extra = shift;
  
        my %http_responses = (