From: Junio C Hamano Date: Wed, 25 Nov 2009 19:45:07 +0000 (-0800) Subject: Merge branch 'rs/work-around-grep-opt-insanity' X-Git-Tag: v1.6.6-rc1~28 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ad7ace714d353ef49045bc37c1363e8fc904792d?ds=inline;hp=-c Merge branch 'rs/work-around-grep-opt-insanity' * rs/work-around-grep-opt-insanity: Protect scripted Porcelains from GREP_OPTIONS insanity mergetool--lib: simplify guess_merge_tool() Conflicts: git-instaweb.sh --- ad7ace714d353ef49045bc37c1363e8fc904792d diff --combined git-am.sh index 151512afd3,b49f26a49c..512891d217 --- a/git-am.sh +++ 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" @@@ -496,12 -495,6 +496,12 @@@ t 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 @@@ -556,12 -549,12 +556,12 @@@ d # 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 @@@ -656,10 -649,7 +656,10 @@@ [eE]*) git_editor "$dotest/final-commit" action=again ;; [vV]*) action=again - LESS=-S ${PAGER:-less} "$dotest/patch" ;; + : ${GIT_PAGER=$(git var GIT_PAGER)} + : ${LESS=-FRSX} + export LESS + $GIT_PAGER "$dotest/patch" ;; *) action=again ;; esac done diff --combined git-bisect.sh index a5ea843fbf,0c422d5fb5..6e2acb8ef2 --- a/git-bisect.sh +++ b/git-bisect.sh @@@ -13,8 -13,8 +13,8 @@@ git bisect skip [(|)... mark ... untestable revisions. git bisect next find next bisection to test and check it out. -git bisect reset [] - finish bisection search and go back to branch. +git bisect reset [] + finish bisection search and go back to commit. git bisect visualize show bisect status in gitk. git bisect replay @@@ -300,7 -300,8 +300,7 @@@ bisect_visualize() esac fi - not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*") - eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") + eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") } bisect_reset() { @@@ -310,8 -311,8 +310,8 @@@ } case "$#" in 0) branch=$(cat "$GIT_DIR/BISECT_START") ;; - 1) git show-ref --verify --quiet -- "refs/heads/$1" || - die "$1 does not seem to be a valid branch" + 1) git rev-parse --quiet --verify "$1^{commit}" > /dev/null || + die "'$1' is not a valid commit" branch="$1" ;; *) usage ;; @@@ -392,7 -393,7 +392,7 @@@ bisect_run () cat "$GIT_DIR/BISECT_RUN" - if grep "first bad commit could be any of" "$GIT_DIR/BISECT_RUN" \ + if sane_grep "first bad commit could be any of" "$GIT_DIR/BISECT_RUN" \ > /dev/null; then echo >&2 "bisect run cannot continue any more" exit $res @@@ -404,7 -405,7 +404,7 @@@ exit $res fi - if grep "is the first bad commit" "$GIT_DIR/BISECT_RUN" > /dev/null; then + if sane_grep "is the first bad commit" "$GIT_DIR/BISECT_RUN" > /dev/null; then echo "bisect run success" exit 0; fi diff --combined git-filter-branch.sh index 6b8b6a4f26,8ef1bde710..cb9d2022cc --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@@ -125,7 -125,6 +125,7 @@@ filter_subdir orig_namespace=refs/original/ force= prune_empty= +remap_to_ancestor= while : do case "$1" in @@@ -138,11 -137,6 +138,11 @@@ force=t continue ;; + --remap-to-ancestor) + shift + remap_to_ancestor=t + continue + ;; --prune-empty) shift prune_empty=t @@@ -188,7 -182,6 +188,7 @@@ ;; --subdirectory-filter) filter_subdir="$OPTARG" + remap_to_ancestor=t ;; --original) orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/ @@@ -264,24 -257,15 +264,24 @@@ git read-tree || die "Could not seed th # map old->new commit ids for rewriting parents mkdir ../map || die "Could not create map/ directory" +# we need "--" only if there are no path arguments in $@ +nonrevs=$(git rev-parse --no-revs "$@") || exit +test -z "$nonrevs" && dashdash=-- || dashdash= +rev_args=$(git rev-parse --revs-only "$@") + case "$filter_subdir" in "") - git rev-list --reverse --topo-order --default HEAD \ - --parents --simplify-merges "$@" + eval set -- "$(git rev-parse --sq --no-revs "$@")" ;; *) - git rev-list --reverse --topo-order --default HEAD \ - --parents --simplify-merges "$@" -- "$filter_subdir" -esac > ../revs || die "Could not get the commits" + eval set -- "$(git rev-parse --sq --no-revs "$@" $dashdash \ + "$filter_subdir")" + ;; +esac + +git rev-list --reverse --topo-order --default HEAD \ + --parents --simplify-merges $rev_args "$@" > ../revs || + die "Could not get the commits" commits=$(wc -l <../revs | tr -d " ") test $commits -eq 0 && die "Found nothing to rewrite" @@@ -361,19 -345,19 +361,19 @@@ while read commit parents; d die "could not write rewritten commit" done <../revs -# In case of a subdirectory filter, it is possible that a specified head -# is not in the set of rewritten commits, because it was pruned by the -# revision walker. Fix it by mapping these heads to the unique nearest -# ancestor that survived the pruning. +# If we are filtering for paths, as in the case of a subdirectory +# filter, it is possible that a specified head is not in the set of +# rewritten commits, because it was pruned by the revision walker. +# Ancestor remapping fixes this by mapping these heads to the unique +# nearest ancestor that survived the pruning. -if test "$filter_subdir" +if test "$remap_to_ancestor" = t then while read ref do sha1=$(git rev-parse "$ref"^0) test -f "$workdir"/../map/$sha1 && continue - ancestor=$(git rev-list --simplify-merges -1 \ - $ref -- "$filter_subdir") + ancestor=$(git rev-list --simplify-merges -1 "$ref" "$@") test "$ancestor" && echo $(map $ancestor) >> "$workdir"/../map/$sha1 done < "$tempdir"/heads fi @@@ -473,7 -457,7 +473,7 @@@ if [ "$filter_tag_name" ]; the git mktag) || die "Could not create new tag object for $ref" if git cat-file tag "$ref" | \ - grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1 + sane_grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1 then warn "gpg signature stripped from tag object $sha1t" fi diff --combined git-instaweb.sh index ffc2ab62bc,84805c61e5..341930ca9d --- a/git-instaweb.sh +++ b/git-instaweb.sh @@@ -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 @@@ -73,11 -73,6 +73,11 @@@ } 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" </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" + if test -f "$module_path/mod_cgi.so" + then + echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf" + else + $list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \ + if test -f "$module_path/mod_cgid.so" + then + echo "LoadModule cgid_module $module_path/mod_cgid.so" \ + >> "$conf" + else + echo "You have no CGI support!" + exit 2 + fi + echo "ScriptSock logs/gitweb.sock" >> "$conf" + fi cat >> "$conf" < diff --combined git-mergetool--lib.sh index f7c571e73c,334af7c347..5b6278572a --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@@ -46,7 -46,7 +46,7 @@@ check_unchanged () valid_tool () { case "$1" in kdiff3 | tkdiff | xxdiff | meld | opendiff | \ - emerge | vimdiff | gvimdiff | ecmerge | diffuse | araxis) + emerge | vimdiff | gvimdiff | ecmerge | diffuse | araxis | p4merge) ;; # happy tortoisemerge) if ! merge_mode; then @@@ -130,19 -130,6 +130,19 @@@ run_merge_tool () "$merge_tool_path" "$LOCAL" "$REMOTE" fi ;; + p4merge) + if merge_mode; then + touch "$BACKUP" + if $base_present; then + "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" + else + "$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED" + fi + check_unchanged + else + "$merge_tool_path" "$LOCAL" "$REMOTE" + fi + ;; meld) if merge_mode; then touch "$BACKUP" @@@ -336,17 -323,16 +336,16 @@@ guess_merge_tool () else tools="opendiff kdiff3 tkdiff xxdiff meld $tools" fi - tools="$tools gvimdiff diffuse ecmerge araxis" + tools="$tools gvimdiff diffuse ecmerge p4merge araxis" fi - if echo "${VISUAL:-$EDITOR}" | grep emacs > /dev/null 2>&1; then - # $EDITOR is emacs so add emerge as a candidate - tools="$tools emerge vimdiff" - elif echo "${VISUAL:-$EDITOR}" | grep vim > /dev/null 2>&1; then - # $EDITOR is vim so add vimdiff as a candidate + case "${VISUAL:-$EDITOR}" in + *vim*) tools="$tools vimdiff emerge" - else + ;; + *) tools="$tools emerge vimdiff" - fi + ;; + esac echo >&2 "merge tool candidates: $tools" # Loop over each candidate and stop when a valid merge tool is found. diff --combined git-rebase--interactive.sh index 27daaa9ded,6268e76bd9..0bd3bf78b8 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -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 () { @@@ -168,7 -168,7 +168,7 @@@ output git reset --hard $sha1 test "a$1" = a-n && output git reset --soft $current_sha1 sha1=$(git rev-parse --short $sha1) - output warn Fast forward to $sha1 + output warn Fast-forward to $sha1 else output git cherry-pick "$@" fi @@@ -248,9 -248,9 +248,9 @@@ pick_one_preserving_merges () done case $fast_forward in t) - output warn "Fast forward to $sha1" + output warn "Fast-forward to $sha1" output git reset --hard $sha1 || - die "Cannot fast forward to $sha1" + die "Cannot fast-forward to $sha1" ;; f) first_parent=$(expr "$new_parents" : ' \([^ ]*\)') @@@ -340,14 -340,6 +340,14 @@@ do_next () pick_one $sha1 || die_with_patch $sha1 "Could not apply $sha1... $rest" ;; + reword|r) + comment_for_reflog reword + + mark_action_done + pick_one $sha1 || + die_with_patch $sha1 "Could not apply $sha1... $rest" + git commit --amend + ;; edit|e) comment_for_reflog edit @@@ -416,12 -408,7 +416,12 @@@ ;; *) 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 @@@ -744,7 -731,7 +744,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, @@@ -752,7 -739,7 +752,7 @@@ # 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 @@@ -765,7 -752,6 +765,7 @@@ # # Commands: # p, pick = use commit +# r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # diff --combined git-rebase.sh index 6830e1627d,0ec435558f..b121f4537c --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -467,7 -467,7 +467,7 @@@ orig_head=$branc mb=$(git merge-base "$onto" "$branch") if test "$upstream" = "$onto" && test "$mb" = "$onto" && # linear history? - ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null + ! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null then if test -z "$force_rebase" then @@@ -496,7 -496,7 +496,7 @@@ the fi # If the $onto is a proper descendant of the tip of the branch, then -# we just fast forwarded. +# we just fast-forwarded. if test "$mb" = "$branch" then say "Fast-forwarded $branch_name to $onto_name." diff --combined git-sh-setup.sh index 99cceeb858,aa07cc3d18..dfcb8078f5 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@@ -99,14 -99,29 +99,22 @@@ set_reflog_action() } git_editor() { - : "${GIT_EDITOR:=$(git config core.editor)}" - : "${GIT_EDITOR:=${VISUAL:-${EDITOR}}}" - case "$GIT_EDITOR,$TERM" in - ,dumb) - echo >&2 "No editor specified in GIT_EDITOR, core.editor, VISUAL," - echo >&2 "or EDITOR. Tried to fall back to vi but terminal is dumb." - echo >&2 "Please set one of these variables to an appropriate" - echo >&2 "editor or run $0 with options that will not cause an" - echo >&2 "editor to be invoked (e.g., -m or -F for git-commit)." - exit 1 - ;; - esac - eval "${GIT_EDITOR:=vi}" '"$@"' + if test -z "${GIT_EDITOR:+set}" + then + GIT_EDITOR="$(git var GIT_EDITOR)" || return $? + fi + + eval "$GIT_EDITOR" '"$@"' } + sane_grep () { + GREP_OPTIONS= LC_ALL=C grep "$@" + } + + sane_egrep () { + GREP_OPTIONS= LC_ALL=C egrep "$@" + } + is_bare_repository () { git rev-parse --is-bare-repository } diff --combined git-submodule.sh index 850d4235a0,b7ccd12d72..77d223292c --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -5,7 -5,7 +5,7 @@@ # Copyright (c) 2007 Lars Hjemli dashless=$(basename "$0" | sed -e 's/-/ /') -USAGE="[--quiet] add [-b branch] [--reference ] [--] +USAGE="[--quiet] add [-b branch] [--reference ] [--] [] or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] or: $dashless [--quiet] init [--] [...] or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference ] [--merge] [--recursive] [--] [...] @@@ -57,7 -57,7 +57,7 @@@ resolve_relative_url ( # module_list() { - git ls-files --error-unmatch --stage -- "$@" | grep '^160000 ' + git ls-files --error-unmatch --stage -- "$@" | sane_grep '^160000 ' } # @@@ -160,11 -160,6 +160,11 @@@ cmd_add( repo=$1 path=$2 + if test -z "$path"; then + path=$(echo "$repo" | + sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g') + fi + if test -z "$repo" -o -z "$path"; then usage fi @@@ -572,7 -567,7 +572,7 @@@ cmd_summary() cd_to_toplevel # Get modified modules cared by user modules=$(git $diff_cmd $cached --raw $head -- "$@" | - egrep '^:([0-7]* )?160000' | + sane_egrep '^:([0-7]* )?160000' | while read mod_src mod_dst sha1_src sha1_dst status name do # Always show modules deleted or type-changed (blob<->module) @@@ -586,7 -581,7 +586,7 @@@ test -z "$modules" && return git $diff_cmd $cached --raw $head -- $modules | - egrep '^:([0-7]* )?160000' | + sane_egrep '^:([0-7]* )?160000' | cut -c2- | while read mod_src mod_dst sha1_src sha1_dst status name do