Merge branch 'rs/work-around-grep-opt-insanity' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 Dec 2009 21:53:58 +0000 (13:53 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Dec 2009 21:53:58 +0000 (13:53 -0800)
* rs/work-around-grep-opt-insanity:
Protect scripted Porcelains from GREP_OPTIONS insanity
mergetool--lib: simplify guess_merge_tool()

1  2 
git-am.sh
git-instaweb.sh
git-rebase--interactive.sh
diff --combined git-am.sh
index 96869a24530be7c560048261da135e89556842f2,b49f26a49c3af272ef454c5f6e05d0266177a3bd..185ea23af63223f5b20fce983d2b7086c87c0957
+++ b/git-am.sh
@@@ -205,7 -205,7 +205,7 @@@ check_patch_format () 
                        # and see if it looks like that they all begin with the
                        # header field names...
                        sed -n -e '/^$/q' -e '/^[       ]/d' -e p "$1" |
-                       LC_ALL=C egrep -v '^[!-9;-~]+:' >/dev/null ||
+                       sane_egrep -v '^[!-9;-~]+:' >/dev/null ||
                        patch_format=mbox
                fi
        } < "$1" || clean_abort
@@@ -289,7 -289,7 +289,7 @@@ split_patches () 
  prec=4
  dotest="$GIT_DIR/rebase-apply"
  sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
 -resolvemsg= resume= scissors=
 +resolvemsg= resume= scissors= no_inbody_headers=
  git_apply_opt=
  committer_date_is_author_date=
  ignore_date=
@@@ -322,7 -322,7 +322,7 @@@ d
        --abort)
                abort=t ;;
        --rebasing)
 -              rebasing=t threeway=t keep=t scissors=f ;;
 +              rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
        -d|--dotest)
                die "-d option is no longer supported.  Do not use."
                ;;
@@@ -448,7 -448,6 +448,7 @@@ els
        echo "$utf8" >"$dotest/utf8"
        echo "$keep" >"$dotest/keep"
        echo "$scissors" >"$dotest/scissors"
 +      echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
        echo "$GIT_QUIET" >"$dotest/quiet"
        echo 1 >"$dotest/next"
        if test -n "$rebasing"
  f)
        scissors=--no-scissors ;;
  esac
 +if test "$(cat "$dotest/no_inbody_headers")" = t
 +then
 +      no_inbody_headers=--no-inbody-headers
 +else
 +      no_inbody_headers=
 +fi
  if test "$(cat "$dotest/quiet")" = t
  then
        GIT_QUIET=t
        # by the user, or the user can tell us to do so by --resolved flag.
        case "$resume" in
        '')
 -              git mailinfo $keep $scissors $utf8 "$dotest/msg" "$dotest/patch" \
 +              git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
                        <"$dotest/$msgnum" >"$dotest/info" ||
                        stop_here $this
  
                # skip pine's internal folder data
-               grep '^Author: Mail System Internal Data$' \
+               sane_grep '^Author: Mail System Internal Data$' \
                        <"$dotest"/info >/dev/null &&
                        go_next && continue
  
diff --combined git-instaweb.sh
index 80a7f74feabf7e8c7a72e1e2e6c2f233e7ba5d7c,84805c61e584f7cd01145805c43944b5ba8b8311..e9fb5aa67ab5d0ea9aa87cf3ef3cd045278c4ac4
@@@ -41,7 -41,7 +41,7 @@@ resolve_full_httpd () 
        case "$httpd" in
        *apache2*|*lighttpd*)
                # ensure that the apache2/lighttpd command ends with "-f"
-               if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1
+               if ! echo "$httpd" | sane_grep -- '-f *$' >/dev/null 2>&1
                then
                        httpd="$httpd -f"
                fi
  }
  
  start_httpd () {
 +      if test -f "$fqgitdir/pid"; then
 +              say "Instance already running. Restarting..."
 +              stop_httpd
 +      fi
 +
        # here $httpd should have a meaningful value
        resolve_full_httpd
  
@@@ -302,8 -297,8 +302,8 @@@ EO
  
        # check to see if Dennis Stosberg's mod_perl compatibility patch
        # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
-       if test -f "$module_path/mod_perl.so" && grep 'MOD_PERL' \
-                               "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
+       if test -f "$module_path/mod_perl.so" &&
+          sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
        then
                # favor mod_perl if available
                cat >> "$conf" <<EOF
@@@ -321,7 -316,7 +321,7 @@@ EO
                # plain-old CGI
                resolve_full_httpd
                list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
-               $list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
+               $list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \
                echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
                cat >> "$conf" <<EOF
  AddHandler cgi-script .cgi
index 9b1e899e279e63cf3b952d910974ebf619d63bee,6268e76bd922af99088c3ed840876f0ea186df55..3853b513b55820d316db436373742af5bb26e6b7
@@@ -106,8 -106,8 +106,8 @@@ mark_action_done () 
        sed -e 1q < "$TODO" >> "$DONE"
        sed -e 1d < "$TODO" >> "$TODO".new
        mv -f "$TODO".new "$TODO"
-       count=$(grep -c '^[^#]' < "$DONE")
-       total=$(($count+$(grep -c '^[^#]' < "$TODO")))
+       count=$(sane_grep -c '^[^#]' < "$DONE")
+       total=$(($count+$(sane_grep -c '^[^#]' < "$TODO")))
        if test "$last_count" != "$count"
        then
                last_count=$count
@@@ -147,7 -147,7 +147,7 @@@ die_abort () 
  }
  
  has_action () {
-       grep '^[^#]' "$1" >/dev/null
+       sane_grep '^[^#]' "$1" >/dev/null
  }
  
  pick_one () {
@@@ -408,12 -408,7 +408,12 @@@ do_next () 
                ;;
        *)
                warn "Unknown command: $command $sha1 $rest"
 -              die_with_patch $sha1 "Please fix this in the file $TODO."
 +              if git rev-parse --verify -q "$sha1" >/dev/null
 +              then
 +                      die_with_patch $sha1 "Please fix this in the file $TODO."
 +              else
 +                      die "Please fix this in the file $TODO."
 +              fi
                ;;
        esac
        test -s "$TODO" && return
@@@ -736,7 -731,7 +736,7 @@@ first and then run 'git rebase --contin
                        git rev-list $REVISIONS |
                        while read rev
                        do
-                               if test -f "$REWRITTEN"/$rev -a "$(grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
+                               if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
                                then
                                        # Use -f2 because if rev-list is telling us this commit is
                                        # not worthwhile, we don't want to track its multiple heads,
                                        # be rebasing on top of it
                                        git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$DROPPED"/$rev
                                        short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
-                                       grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
+                                       sane_grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
                                        rm "$REWRITTEN"/$rev
                                fi
                        done