Merge branch 'ae/preservemerge'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 Oct 2008 23:06:31 +0000 (16:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Oct 2008 23:06:31 +0000 (16:06 -0700)
* ae/preservemerge:
rebase: Support preserving merges in non-interactive mode

1  2 
Documentation/git-rebase.txt
git-rebase.sh
index 4e8438098fc9862ae83280f8f191329d1251bc55,b86e80bb669081a9e86b14be61ad7604ec5d275b..d639985693705930cba6f078b0bd1f8b61b65da4
@@@ -9,7 -9,7 +9,7 @@@ SYNOPSI
  --------
  [verse]
  'git rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
 -      [-s <strategy> | --strategy=<strategy>]
 +      [-s <strategy> | --strategy=<strategy>] [--no-verify]
        [-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
        [--onto <newbase>] <upstream> [<branch>]
  'git rebase' --continue | --skip | --abort
@@@ -232,9 -232,6 +232,9 @@@ OPTION
  --verbose::
        Display a diffstat of what changed upstream since the last rebase.
  
 +--no-verify::
 +      This option bypasses the pre-rebase hook.  See also linkgit:githooks[5].
 +
  -C<n>::
        Ensure at least <n> lines of surrounding context match before
        and after each change.  When fewer lines of surrounding
  
  -p::
  --preserve-merges::
-       Instead of ignoring merges, try to recreate them.  This option
-       only works in interactive mode.
+       Instead of ignoring merges, try to recreate them.
  
  include::merge-strategies.txt[]
  
diff --combined git-rebase.sh
index f2742aa054d2080a4a554ade3916c3bfa110af67,03e5f95051382fb1a9b811e9974cb5424fee883b..023a6dc94a48f7abf2801359ad68d40909e9b6aa
@@@ -34,7 -34,6 +34,7 @@@ set_reflog_action rebas
  require_work_tree
  cd_to_toplevel
  
 +OK_TO_SKIP_PRE_REBASE=
  RESOLVEMSG="
  When you have resolved this problem run \"git rebase --continue\".
  If you would prefer to skip this patch, instead run \"git rebase --skip\".
@@@ -139,23 -138,28 +139,39 @@@ finish_rb_merge () 
  }
  
  is_interactive () {
-       test -f "$dotest"/interactive ||
-       while :; do case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
+       while test $# != 0
+       do
+               case "$1" in
+                       -i|--interactive)
+                               interactive_rebase=explicit
+                               break
+                       ;;
+                       -p|--preserve-merges)
+                               interactive_rebase=implied
+                       ;;
+               esac
                shift
-       done && test -n "$1"
+       done
+       if [ "$interactive_rebase" = implied ]; then
+               GIT_EDITOR=:
+               export GIT_EDITOR
+       fi
+       test -n "$interactive_rebase" || test -f "$dotest"/interactive
  }
  
 +run_pre_rebase_hook () {
 +      if test -z "$OK_TO_SKIP_PRE_REBASE" &&
 +         test -x "$GIT_DIR/hooks/pre-rebase"
 +      then
 +              "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
 +                      echo >&2 "The pre-rebase hook refused to rebase."
 +                      exit 1
 +              }
 +      fi
 +}
 +
  test -f "$GIT_DIR"/rebase-apply/applying &&
        die 'It looks like git-am is in progress. Cannot rebase.'
  
@@@ -172,9 -176,6 +188,9 @@@ f
  while test $# != 0
  do
        case "$1" in
 +      --no-verify)
 +              OK_TO_SKIP_PRE_REBASE=yes
 +              ;;
        --continue)
                test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
                        die "No rebase in progress?"
@@@ -335,7 -336,13 +351,7 @@@ onto_name=${newbase-"$upstream_name"
  onto=$(git rev-parse --verify "${onto_name}^0") || exit
  
  # If a hook exists, give it a chance to interrupt
 -if test -x "$GIT_DIR/hooks/pre-rebase"
 -then
 -      "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
 -              echo >&2 "The pre-rebase hook refused to rebase."
 -              exit 1
 -      }
 -fi
 +run_pre_rebase_hook ${1+"$@"}
  
  # If the branch to rebase is given, that is the branch we will rebase
  # $branch_name -- branch being rebased, or HEAD (already detached)