Merge branch 'jc/sane-grep'
authorJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2016 20:16:54 +0000 (13:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2016 20:16:54 +0000 (13:16 -0700)
Recent versions of GNU grep is pickier than before to decide if a
file is "binary" and refuse to give line-oriented hits when we
expect it to, unless explicitly told with "-a" option. As our
scripted Porcelains use sane_grep wrapper for line-oriented data,
even when the line may contain non-ASCII payload we took from
end-user data, use "grep -a" to implement sane_grep wrapper when
using an implementation of "grep" that takes the "-a" option.

* jc/sane-grep:
rebase-i: clarify "is this commit relevant?" test
sane_grep: pass "-a" if grep accepts it

1  2 
Makefile
config.mak.uname
configure.ac
git-rebase--interactive.sh
diff --combined Makefile
index 24bef8d4282baa7702d4386193c4291275c708c7,59bbb1e6a9af55aba6d4b2b765c2ea429e0a19ef..2742a6977c6ad871897bc758ea2a7d76359b1eee
+++ b/Makefile
@@@ -77,6 -77,8 +77,6 @@@ all:
  # 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).
  #
  #
  # Define NO_TCLTK if you do not want Tcl/Tk GUI.
  #
+ # Define SANE_TEXT_GREP to "-a" if you use recent versions of GNU grep
+ # and egrep that are pickier when their input contains non-ASCII data.
+ #
  # The TCL_PATH variable governs the location of the Tcl interpreter
  # used to optimize git-gui for your system.  Only used if NO_TCLTK
  # is not set.  Defaults to the bare 'tclsh'.
@@@ -380,18 -385,6 +383,18 @@@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS
  ALL_LDFLAGS = $(LDFLAGS)
  STRIP ?= strip
  
 +ifdef DEVELOPER
 +CFLAGS += -Werror \
 +      -Wdeclaration-after-statement \
 +      -Wno-format-zero-length \
 +      -Wold-style-definition \
 +      -Woverflow \
 +      -Wpointer-arith \
 +      -Wstrict-prototypes \
 +      -Wunused \
 +      -Wvla
 +endif
 +
  # Create as necessary, replace existing, make ranlib unneeded.
  ARFLAGS = rcs
  
@@@ -595,7 -588,6 +598,7 @@@ TEST_PROGRAMS_NEED_X += test-delt
  TEST_PROGRAMS_NEED_X += test-dump-cache-tree
  TEST_PROGRAMS_NEED_X += test-dump-split-index
  TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
 +TEST_PROGRAMS_NEED_X += test-fake-ssh
  TEST_PROGRAMS_NEED_X += test-genrandom
  TEST_PROGRAMS_NEED_X += test-hashmap
  TEST_PROGRAMS_NEED_X += test-index-version
@@@ -748,7 -740,6 +751,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
@@@ -785,7 -776,6 +788,7 @@@ LIB_OBJS += reachable.
  LIB_OBJS += read-cache.o
  LIB_OBJS += reflog-walk.o
  LIB_OBJS += refs.o
 +LIB_OBJS += refs/files-backend.o
  LIB_OBJS += ref-filter.o
  LIB_OBJS += remote.o
  LIB_OBJS += replace_object.o
@@@ -831,7 -821,6 +834,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
@@@ -927,7 -916,6 +930,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
@@@ -1187,6 -1175,9 +1190,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
@@@ -1740,7 -1731,7 +1743,7 @@@ common-cmds.h: $(wildcard Documentation
  
  SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
        $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
-       $(gitwebdir_SQ):$(PERL_PATH_SQ)
+       $(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP)
  define cmd_munge_script
  $(RM) $@ $@+ && \
  sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
      -e $(BROKEN_PATH_FIX) \
      -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
      -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
+     -e 's|@@SANE_TEXT_GREP@@|$(SANE_TEXT_GREP)|g' \
      $@.sh >$@+
  endef
  
@@@ -2038,7 -2030,6 +2042,7 @@@ $(VCSSVN_LIB): $(VCSSVN_OBJS
  
  export DEFAULT_EDITOR DEFAULT_PAGER
  
 +.PHONY: doc man html info pdf
  doc:
        $(MAKE) -C Documentation all
  
@@@ -2082,7 -2073,6 +2086,7 @@@ po/git.pot: $(GENERATED_H) FORC
                $(LOCALIZED_PERL)
        mv $@+ $@
  
 +.PHONY: pot
  pot: po/git.pot
  
  POFILES := $(wildcard po/*.po)
@@@ -2292,7 -2282,6 +2296,7 @@@ mergetools_instdir_SQ = $(subst ','\'',
  
  install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
  
 +.PHONY: profile-install profile-fast-install
  profile-install: profile
        $(MAKE) install
  
@@@ -2359,8 -2348,6 +2363,8 @@@ endi
        done && \
        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
  
 +.PHONY: install-gitweb install-doc install-man install-html install-info install-pdf
 +.PHONY: quick-install-doc quick-install-man quick-install-html
  install-gitweb:
        $(MAKE) -C gitweb install
  
@@@ -2420,7 -2407,6 +2424,7 @@@ rpm: dis
  
  htmldocs = git-htmldocs-$(GIT_VERSION)
  manpages = git-manpages-$(GIT_VERSION)
 +.PHONY: dist-doc distclean
  dist-doc:
        $(RM) -r .doc-tmp-dir
        mkdir .doc-tmp-dir
@@@ -2452,7 -2438,7 +2456,7 @@@ profile-clean
        $(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
  
  clean: profile-clean coverage-clean
 -      $(RM) *.o *.res block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o
 +      $(RM) *.o *.res refs/*.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o
        $(RM) xdiff/*.o vcs-svn/*.o ewah/*.o builtin/*.o
        $(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
        $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@@@ -2489,8 -2475,6 +2493,8 @@@ ALL_COMMANDS += gi
  ALL_COMMANDS += gitk
  ALL_COMMANDS += gitweb
  ALL_COMMANDS += git-gui git-citool
 +
 +.PHONY: check-docs
  check-docs::
        @(for v in $(ALL_COMMANDS); \
        do \
@@@ -2535,7 -2519,6 +2539,7 @@@ check-builtins:
  ### Test suite coverage testing
  #
  .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
 +.PHONY: coverage-untested-functions cover_db cover_db_html
  .PHONY: coverage-clean-results
  
  coverage:
diff --combined config.mak.uname
index 4c68e078e7ac4a9584b2782f278b00fcbe594505,a7064749fc82617199c26ca27a6715fa51552f61..1139b4400743a8a9a687967a9dff5529d876b0c0
@@@ -37,6 -37,7 +37,7 @@@ ifeq ($(uname_S),Linux
        HAVE_CLOCK_GETTIME = YesPlease
        HAVE_CLOCK_MONOTONIC = YesPlease
        HAVE_GETDELIM = YesPlease
+       SANE_TEXT_GREP=-a
  endif
  ifeq ($(uname_S),GNU/kFreeBSD)
        HAVE_ALLOCA_H = YesPlease
@@@ -102,9 -103,6 +103,9 @@@ ifeq ($(uname_S),Darwin
        ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
                NO_STRLCPY = YesPlease
        endif
 +      ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -eq 10 && echo 1),1)
 +              CC = clang
 +      endif
        ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
                HAVE_GETDELIM = YesPlease
        endif
@@@ -169,6 -167,7 +170,6 @@@ endi
  ifeq ($(uname_O),Cygwin)
        ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
                NO_D_TYPE_IN_DIRENT = YesPlease
 -              NO_D_INO_IN_DIRENT = YesPlease
                NO_STRCASESTR = YesPlease
                NO_MEMMEM = YesPlease
                NO_MKSTEMPS = YesPlease
@@@ -372,6 -371,7 +373,6 @@@ ifeq ($(uname_S),Windows
        NO_POSIX_GOODIES = UnfortunatelyYes
        NATIVE_CRLF = YesPlease
        DEFAULT_HELP_FORMAT = html
 -      NO_D_INO_IN_DIRENT = YesPlease
  
        CC = compat/vcbuild/scripts/clink.pl
        AR = compat/vcbuild/scripts/lib.pl
@@@ -521,12 -521,14 +522,12 @@@ ifneq (,$(findstring MINGW,$(uname_S))
        NO_INET_NTOP = YesPlease
        NO_POSIX_GOODIES = UnfortunatelyYes
        DEFAULT_HELP_FORMAT = html
 -      NO_D_INO_IN_DIRENT = YesPlease
 -      COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 +      COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
                compat/win32/dirent.o
        BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
 -      BASIC_LDFLAGS += -Wl,--large-address-aware
        EXTLIBS += -lws2_32
        GITLIBS += git.res
        PTHREAD_LIBS =
@@@ -543,35 -545,8 +544,35 @@@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)
        INTERNAL_QSORT = YesPlease
        HAVE_LIBCHARSET_H = YesPlease
        NO_GETTEXT = YesPlease
 +      COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
  else
 -      NO_CURL = YesPlease
 +      ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
 +              # MSys2
 +              prefix = /usr/
 +              ifeq (MINGW32,$(MSYSTEM))
 +                      prefix = /mingw32
 +              endif
 +              ifeq (MINGW64,$(MSYSTEM))
 +                      prefix = /mingw64
 +              else
 +                      COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
 +                      BASIC_LDFLAGS += -Wl,--large-address-aware
 +              endif
 +              CC = gcc
 +              COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
 +              INSTALL = /bin/install
 +              NO_R_TO_GCC_LINKER = YesPlease
 +              INTERNAL_QSORT = YesPlease
 +              HAVE_LIBCHARSET_H = YesPlease
 +              NO_GETTEXT =
 +              USE_GETTEXT_SCHEME = fallthrough
 +              USE_LIBPCRE= YesPlease
 +              NO_CURL =
 +              USE_NED_ALLOCATOR = YesPlease
 +      else
 +              COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
 +              NO_CURL = YesPlease
 +      endif
  endif
  endif
  ifeq ($(uname_S),QNX)
diff --combined configure.ac
index 89e2590bd6926a52d8f57e0dfc164360809c90d2,6fd7b8edce348ec5cacd2fb8f1d8b1f5c7490ae0..0cd9f4680b84bccd0a98193c401b13749b05b833
@@@ -471,6 -471,13 +471,13 @@@ if test -n "$ASCIIDOC"; the
        esac
  fi
  
+ if grep -a ascii configure.ac >/dev/null; then
+   AC_MSG_RESULT([Using 'grep -a' for sane_grep])
+   SANE_TEXT_GREP=-a
+ else
+   SANE_TEXT_GREP=
+ fi
+ GIT_CONF_SUBST([SANE_TEXT_GREP])
  
  ## Checks for libraries.
  AC_MSG_NOTICE([CHECKS for libraries])
@@@ -790,6 -797,13 +797,6 @@@ elif test x$ac_cv_member_struct_stat_st
        GIT_CONF_SUBST([NO_NSEC])
  fi
  #
 -# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 -AC_CHECK_MEMBER(struct dirent.d_ino,
 -[NO_D_INO_IN_DIRENT=],
 -[NO_D_INO_IN_DIRENT=YesPlease],
 -[#include <dirent.h>])
 -GIT_CONF_SUBST([NO_D_INO_IN_DIRENT])
 -#
  # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
  AC_CHECK_MEMBER(struct dirent.d_type,
index c0cfe88a3d9422e0255c29dc7ccb4566412013cd,773ccd4746e2fcbcfd79d20921916231eba65122..4cde685b43a4463bac5f96bcb4f8ed8b3e9347be
@@@ -81,13 -81,17 +81,13 @@@ rewritten_pending="$state_dir"/rewritte
  # and leaves CR at the end instead.
  cr=$(printf "\015")
  
 -strategy_args=
 -if test -n "$do_merge"
 -then
 -      strategy_args=${strategy:+--strategy=$strategy}
 -      eval '
 -              for strategy_opt in '"$strategy_opts"'
 -              do
 -                      strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
 -              done
 -      '
 -fi
 +strategy_args=${strategy:+--strategy=$strategy}
 +eval '
 +      for strategy_opt in '"$strategy_opts"'
 +      do
 +              strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
 +      done
 +'
  
  GIT_CHERRY_PICK_HELP="$resolvemsg"
  export GIT_CHERRY_PICK_HELP
@@@ -1233,7 -1237,8 +1233,8 @@@ the
        git rev-list $revisions |
        while read rev
        do
-               if test -f "$rewritten"/$rev && test "$(sane_grep "$rev" "$state_dir"/not-cherry-picks)" = ""
+               if test -f "$rewritten"/$rev &&
+                  ! sane_grep "$rev" "$state_dir"/not-cherry-picks >/dev/null
                then
                        # Use -f2 because if rev-list is telling us this commit is
                        # not worthwhile, we don't want to track its multiple heads,