Skip to content

Commit

Permalink
git-sh-setup: remove "sane_grep", it's not needed anymore
Browse files Browse the repository at this point in the history
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
   e1622bf (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 71b4010 (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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
avar authored and gitster committed Oct 21, 2021
1 parent d7927d4 commit ebeb39f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 22 deletions.
6 changes: 1 addition & 5 deletions Makefile
Expand Up @@ -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'.
Expand Down Expand Up @@ -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)'; \
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion config.mak.uname
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions configure.ac
Expand Up @@ -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])
#
Expand Down
1 change: 0 additions & 1 deletion contrib/buildsystems/CMakeLists.txt
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion git-filter-branch.sh
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions git-instaweb.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions git-sh-setup.sh
Expand Up @@ -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
}
Expand Down

0 comments on commit ebeb39f

Please sign in to comment.