Merge branch 'lh/merge'
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Oct 2007 10:05:58 +0000 (03:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Oct 2007 10:05:58 +0000 (03:05 -0700)
* lh/merge:
git-merge: add --ff and --no-ff options
git-merge: add support for --commit and --no-squash
git-merge: add support for branch.<name>.mergeoptions
git-merge: refactor option parsing
git-merge: fix faulty SQUASH_MSG
Add test-script for git-merge porcelain

1  2 
Documentation/config.txt
Documentation/git-merge.txt
git-merge.sh
diff --combined Documentation/config.txt
index eebb0b6ba2a2397ee867310d3b9ea4979f7b7510,d3c25f30f56c2c26f7ad827455397c2df8105aeb..971fd9f16fba0bf07983a5aa9d016a20e059d7b6
@@@ -337,6 -337,12 +337,12 @@@ branch.<name>.merge:
        branch.<name>.merge to the desired branch, and use the special setting
        `.` (a period) for branch.<name>.remote.
  
+ branch.<name>.mergeoptions::
+       Sets default options for merging into branch <name>. The syntax and
+       supported options are equal to that of gitlink:git-merge[1], but
+       option values containing whitespace characters are currently not
+       supported.
  clean.requireForce::
        A boolean to make git-clean do nothing unless given -f or -n.  Defaults
        to false.
@@@ -439,19 -445,6 +445,19 @@@ gc.aggressiveWindow:
        algorithm used by 'git gc --aggressive'.  This defaults
        to 10.
  
 +gc.auto::
 +      When there are approximately more than this many loose
 +      objects in the repository, `git gc --auto` will pack them.
 +      Some Porcelain commands use this command to perform a
 +      light-weight garbage collection from time to time.  Setting
 +      this to 0 disables it.
 +
 +gc.autopacklimit::
 +      When there are more than this many packs that are not
 +      marked with `*.keep` file in the repository, `git gc
 +      --auto` consolidates them into one larger pack.  Setting
 +      this to 0 disables this.
 +
  gc.packrefs::
        `git gc` does not run `git pack-refs` in a bare repository by
        default so that older dumb-transport clients can still fetch
@@@ -592,7 -585,7 +598,7 @@@ merge.summary:
  
  merge.tool::
        Controls which merge resolution program is used by
 -      gitlink:git-mergetool[l].  Valid values are: "kdiff3", "tkdiff",
 +      gitlink:git-mergetool[1].  Valid values are: "kdiff3", "tkdiff",
        "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff".
  
  merge.verbosity::
index eae49c4876caf6b2e6a8bd9770b3981fb8133edd,b1771a13c88fa8ec8d5ca6e04c8d5b73bee3209e..bca4212e565c95f79a76a14cc4444e72e472a22c
@@@ -56,8 -56,12 +56,12 @@@ merge.verbosity:
        message if conflicts were detected. Level 1 outputs only
        conflicts, 2 outputs conflicts and file changes.  Level 5 and
        above outputs debugging information.  The default is level 2.
 -      Can be overriden by 'GIT_MERGE_VERBOSITY' environment variable.
 +      Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
  
+ branch.<name>.mergeoptions::
+       Sets default options for merging into branch <name>. The syntax and
+       supported options are equal to that of git-merge, but option values
+       containing whitespace characters are currently not supported.
  
  HOW MERGE WORKS
  ---------------
diff --combined git-merge.sh
index bf18f582da53200fb422bf35c85c1f05c5f7c88d,ce66524340322ba02666c5f68bee1a1ec4a8d4ad..c2092a204035ad0315a3d37ed2f70097e68ed052
@@@ -3,7 -3,7 +3,7 @@@
  # Copyright (c) 2005 Junio C Hamano
  #
  
- USAGE='[-n] [--summary] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
+ USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s <strategy>] [-m=<merge-message>] <commit>+'
  
  SUBDIRECTORY_OK=Yes
  . git-sh-setup
@@@ -59,7 -59,7 +59,7 @@@ finish_up_to_date () 
  squash_message () {
        echo Squashed commit of the following:
        echo
-       git log --no-merges ^"$head" $remote
+       git log --no-merges ^"$head" $remoteheads
  }
  
  finish () {
@@@ -82,7 -82,6 +82,7 @@@
                        ;;
                *)
                        git update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
 +                      git gc --auto
                        ;;
                esac
                ;;
                fi
                ;;
        esac
 +
 +      # Run a post-merge hook
 +        if test -x "$GIT_DIR"/hooks/post-merge
 +        then
 +          case "$squash" in
 +          t)
 +                "$GIT_DIR"/hooks/post-merge 1
 +              ;;
 +          '')
 +                "$GIT_DIR"/hooks/post-merge 0
 +              ;;
 +          esac
 +        fi
  }
  
  merge_name () {
        fi
  }
  
- case "$#" in 0) usage ;; esac
- have_message=
- while test $# != 0
- do
+ parse_option () {
        case "$1" in
        -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
                --no-summa|--no-summar|--no-summary)
        --summary)
                show_diffstat=t ;;
        --sq|--squ|--squa|--squas|--squash)
-               squash=t no_commit=t ;;
+               allow_fast_forward=t squash=t no_commit=t ;;
+       --no-sq|--no-squ|--no-squa|--no-squas|--no-squash)
+               allow_fast_forward=t squash= no_commit= ;;
+       --c|--co|--com|--comm|--commi|--commit)
+               allow_fast_forward=t squash= no_commit= ;;
        --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
-               no_commit=t ;;
+               allow_fast_forward=t squash= no_commit=t ;;
+       --ff)
+               allow_fast_forward=t squash= no_commit= ;;
+       --no-ff)
+               allow_fast_forward=false squash= no_commit= ;;
        -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
                --strateg=*|--strategy=*|\
        -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
                have_message=t
                ;;
        -*)     usage ;;
-       *)      break ;;
+       *)      return 1 ;;
        esac
        shift
+       args_left=$#
+ }
+ parse_config () {
+       while test $# -gt 0
+       do
+               parse_option "$@" || usage
+               while test $args_left -lt $#
+               do
+                       shift
+               done
+       done
+ }
+ test $# != 0 || usage
+ have_message=
+ if branch=$(git-symbolic-ref -q HEAD)
+ then
+       mergeopts=$(git config "branch.${branch#refs/heads/}.mergeoptions")
+       if test -n "$mergeopts"
+       then
+               parse_config $mergeopts
+       fi
+ fi
+ while parse_option "$@"
+ do
+       while test $args_left -lt $#
+       do
+               shift
+       done
  done
  
  if test -z "$show_diffstat"; then
@@@ -458,7 -481,13 +495,13 @@@ don
  # auto resolved the merge cleanly.
  if test '' != "$result_tree"
  then
-     parents=$(git show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
+     if test "$allow_fast_forward" = "t"
+     then
+         parents=$(git show-branch --independent "$head" "$@")
+     else
+         parents=$(git rev-parse "$head" "$@")
+     fi
+     parents=$(echo "$parents" | sed -e 's/^/-p /')
      result_commit=$(printf '%s\n' "$merge_msg" | git commit-tree $result_tree $parents) || exit
      finish "$result_commit" "Merge made by $wt_strategy."
      dropsave