Fix fd leak in http-fetch
[gitweb.git] / git-pull.sh
index d4765188b4ad9d41a0ffec333d9b449de03968a6..3b875ad438c21df50c0b1f26bc8fac5ab1bc9740 100755 (executable)
@@ -7,16 +7,25 @@
 . git-sh-setup || die "Not a git archive"
 
 usage () {
-    die "git pull [-n] [-s strategy]... <repo> <head>..."
+    echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help]
+    [-s strategy]...
+    [<fetch-options>]
+    <repo> <head>...
+
+Fetch one or more remote refs and merge it/them into the current HEAD.
+'
+    exit 1
 }
 
-strategy_args= no_summary=
+strategy_args= no_summary= no_commit=
 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
 do
        case "$1" in
        -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
                --no-summa|--no-summar|--no-summary)
                no_summary=-n ;;
+       --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
+               no_commit=--no-commit ;;
        -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
                --strateg=*|--strategy=*|\
        -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@ -31,6 +40,9 @@ do
                esac
                strategy_args="${strategy_args}-s $strategy "
                ;;
+       -h|--h|--he|--hel|--help)
+               usage
+               ;;
        -*)
                # Pass thru anything that is meant for fetch.
                break
@@ -67,10 +79,22 @@ case "$merge_head" in
        exit 0
        ;;
 ?*' '?*)
-       strategy_default_args='-s octopus'
+       var=`git-var -l | sed -ne 's/^pull\.octopus=/-s /p'`
+       if test '' = "$var"
+       then
+               strategy_default_args='-s octopus'
+       else
+               strategy_default_args=$var
+       fi
        ;;
 *)
-       strategy_default_args='-s resolve'
+       var=`git-var -l | sed -ne 's/^pull\.twohead=/-s /p'`
+       if test '' = "$var"
+       then
+               strategy_default_args='-s recursive'
+       else
+               strategy_default_args=$var
+       fi
        ;;
 esac
 
@@ -81,4 +105,4 @@ case "$strategy_args" in
 esac
 
 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
-git-merge $no_summary $strategy_args "$merge_name" HEAD $merge_head
+git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head