git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 6/6] git-sh-setup: remove "sane_grep", it's not needed anymore
Date: Thu, 21 Oct 2021 21:58:00 +0200	[thread overview]
Message-ID: <patch-6.6-556fa96dde7-20211021T195538Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.6-00000000000-20211021T195538Z-avarab@gmail.com>

Remove the sane_grep() shell function in git-sh-setup. The two reasons
for why it existed don't apply anymore:

1. It was added due to GNU grep supporting GREP_OPTIONS. See
   e1622bfcbad (Protect scripted Porcelains from GREP_OPTIONS insanity,
   2009-11-23).

   Newer versions of GNU grep ignore that, but even on older versions
   its existence won't matter, none of these sane_grep() uses care
   about grep's output, they're merely using it to check if a string
   exists in a file or stream. We also don't care about the "LC_ALL=C"
   that "sane_grep" was using, these greps for fixed or ASCII strings
   will behave the same under any locale.

2. The SANE_TEXT_GREP added in 71b401032b9 (sane_grep: pass "-a" if
   grep accepts it, 2016-03-08) isn't needed either, none of these grep
   uses deal with binary data.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Makefile                            | 6 +-----
 config.mak.uname                    | 1 -
 configure.ac                        | 8 --------
 contrib/buildsystems/CMakeLists.txt | 1 -
 git-filter-branch.sh                | 2 +-
 git-instaweb.sh                     | 4 ++--
 git-sh-setup.sh                     | 4 ----
 7 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index 50eba522f4e..01585bfebdc 100644
--- a/Makefile
+++ b/Makefile
@@ -305,9 +305,6 @@ all::
 #
 # 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'.
@@ -2254,7 +2251,7 @@ hook-list.h: generate-hooklist.sh Documentation/githooks.txt
 
 SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):\
 	$(localedir_SQ):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
-	$(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP):$(PAGER_ENV):\
+	$(gitwebdir_SQ):$(PERL_PATH_SQ):$(PAGER_ENV):\
 	$(perllibdir_SQ)
 GIT-SCRIPT-DEFINES: FORCE
 	@FLAGS='$(SCRIPT_DEFINES)'; \
@@ -2272,7 +2269,6 @@ 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' \
     -e 's|@@PAGER_ENV@@|$(PAGER_ENV_SQ)|g' \
     $@.sh >$@+
 endef
diff --git a/config.mak.uname b/config.mak.uname
index 3236a4918a3..d0701f9beb0 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -58,7 +58,6 @@ ifeq ($(uname_S),Linux)
 	# -lrt is needed for clock_gettime on glibc <= 2.16
 	NEEDS_LIBRT = YesPlease
 	HAVE_GETDELIM = YesPlease
-	SANE_TEXT_GREP=-a
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
 	BASIC_CFLAGS += -DHAVE_SYSINFO
 	PROCFS_EXECUTABLE_PATH = /proc/self/exe
diff --git a/configure.ac b/configure.ac
index 031e8d3fee8..5ee25ec95c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -507,14 +507,6 @@ if test -n "$ASCIIDOC"; then
 	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])
 #
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index fd1399c440f..86b46114464 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -781,7 +781,6 @@ foreach(script ${git_shell_scripts})
 	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
 	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
 	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
 	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index cb893728136..3a51d4507c7 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -579,7 +579,7 @@ if [ "$filter_tag_name" ]; then
 				git hash-object -t tag -w --stdin) ||
 				die "Could not create new tag object for $ref"
 			if git cat-file tag "$ref" | \
-			   sane_grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1
+			   grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1
 			then
 				warn "gpg signature stripped from tag object $sha1t"
 			fi
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 54094fbe8de..4349566c891 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -49,7 +49,7 @@ resolve_full_httpd () {
 	*apache2*|*lighttpd*|*httpd*)
 		# yes, *httpd* covers *lighttpd* above, but it is there for clarity
 		# ensure that the apache2/lighttpd command ends with "-f"
-		if ! echo "$httpd" | sane_grep -- '-f *$' >/dev/null 2>&1
+		if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1
 		then
 			httpd="$httpd -f"
 		fi
@@ -399,7 +399,7 @@ EOF
 		# plain-old CGI
 		resolve_full_httpd
 		list_mods=$(echo "$full_httpd" | sed 's/-f$/-l/')
-		$list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \
+		$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
 		if test -f "$module_path/mod_cgi.so"
 		then
 			echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 758520f5a61..1eb79458b48 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -173,10 +173,6 @@ git_pager() {
 	eval "$GIT_PAGER" '"$@"'
 }
 
-sane_grep () {
-	GREP_OPTIONS= LC_ALL=C grep @@SANE_TEXT_GREP@@ "$@"
-}
-
 is_bare_repository () {
 	git rev-parse --is-bare-repository
 }
-- 
2.33.1.1494.g88b39a443e1


  parent reply	other threads:[~2021-10-21 19:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 19:57 [PATCH 0/6] Makefile: be less eager to re-build, *.sh code cleanups Ævar Arnfjörð Bjarmason
2021-10-21 19:57 ` [PATCH 1/6] Makefile: move git-SCRIPT-DEFINES adjacent to $(SCRIPT_DEFINES) Ævar Arnfjörð Bjarmason
2021-10-21 19:57 ` [PATCH 2/6] Makefile: remove $(GIT_VERSION) from $(SCRIPT_DEFINES) Ævar Arnfjörð Bjarmason
2021-10-25 18:57   ` Jeff King
2021-10-21 19:57 ` [PATCH 3/6] Makefile: remove $(NO_CURL) " Ævar Arnfjörð Bjarmason
2021-10-21 19:57 ` [PATCH 4/6] git-instaweb: unconditionally assume that gitweb is mod_perl capable Ævar Arnfjörð Bjarmason
2021-10-21 19:57 ` [PATCH 5/6] git-sh-setup: remove unused sane_egrep() function Ævar Arnfjörð Bjarmason
2021-10-22  0:27   ` Junio C Hamano
2021-10-21 19:58 ` Ævar Arnfjörð Bjarmason [this message]
2021-10-21 23:17   ` [PATCH 6/6] git-sh-setup: remove "sane_grep", it's not needed anymore Junio C Hamano
2021-10-22 14:27     ` Johannes Schindelin
2021-10-24  9:08       ` Junio C Hamano
2021-10-25 13:09         ` Johannes Schindelin
2021-10-25 17:14           ` Junio C Hamano
2021-10-25 19:08 ` [PATCH 0/6] Makefile: be less eager to re-build, *.sh code cleanups Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-6.6-556fa96dde7-20211021T195538Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).