Merge branch 'es/rebase-i-respect-core-commentchar' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 17 Oct 2013 22:45:24 +0000 (15:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Oct 2013 22:45:24 +0000 (15:45 -0700)
* es/rebase-i-respect-core-commentchar:
rebase -i: fix cases ignoring core.commentchar

1  2 
git-rebase--interactive.sh
index 83d6d4676bc1cadcec5ea5889fcf4a0769ee8d31,1e3097ed243ab15089e4d90166cdf310889829cb..9dfeb539536c55ba3958032d19c539be9ff4750f
@@@ -80,18 -80,6 +80,18 @@@ amend="$state_dir"/amen
  rewritten_list="$state_dir"/rewritten-list
  rewritten_pending="$state_dir"/rewritten-pending
  
 +strategy_args=
 +if test -n "$do_merge"
 +then
 +      strategy_args=${strategy:+--strategy=$strategy}
 +      eval '
 +              for strategy_opt in '"$strategy_opts"'
 +              do
 +                      strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
 +              done
 +      '
 +fi
 +
  GIT_CHERRY_PICK_HELP="$resolvemsg"
  export GIT_CHERRY_PICK_HELP
  
@@@ -251,7 -239,7 +251,7 @@@ pick_one () 
  
        test -d "$rewritten" &&
                pick_one_preserving_merges "$@" && return
 -      output git cherry-pick $empty_args $ff "$@"
 +      output eval git cherry-pick "$strategy_args" $empty_args $ff "$@"
  }
  
  pick_one_preserving_merges () {
                        msg_content="$(commit_message $sha1)"
                        # No point in merging the first parent, that's HEAD
                        new_parents=${new_parents# $first_parent}
 -                      if ! do_with_author output \
 -                              git merge --no-ff ${strategy:+-s $strategy} -m \
 -                                      "$msg_content" $new_parents
 +                      if ! do_with_author output eval \
 +                      'git merge --no-ff $strategy_args -m "$msg_content" $new_parents'
                        then
                                printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
                                die_with_patch $sha1 "Error redoing merge $sha1"
                        echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
                        ;;
                *)
 -                      output git cherry-pick "$@" ||
 +                      output eval git cherry-pick "$strategy_args" "$@" ||
                                die_with_patch $sha1 "Could not pick $sha1"
                        ;;
                esac
@@@ -639,16 -628,17 +639,16 @@@ do_next () 
                "$GIT_DIR"/hooks/post-rewrite rebase < "$rewritten_list"
                true # we don't care if this hook failed
        fi &&
 -      rm -rf "$state_dir" &&
 -      git gc --auto &&
        warn "Successfully rebased and updated $head_name."
  
 -      exit
 +      return 1 # not failure; just to break the do_rest loop
  }
  
 +# can only return 0, when the infinite loop breaks
  do_rest () {
        while :
        do
 -              do_next
 +              do_next || break
        done
  }
  
@@@ -671,7 -661,7 +671,7 @@@ skip_unnecessary_picks () 
                                ;;
                        esac
                        ;;
-               3,#*|3,)
+               3,"$comment_char"*|3,)
                        # copy comments
                        ;;
                *)
@@@ -700,22 -690,8 +700,22 @@@ rearrange_squash () 
                case "$message" in
                "squash! "*|"fixup! "*)
                        action="${message%%!*}"
 -                      rest="${message#*! }"
 -                      echo "$sha1 $action $rest"
 +                      rest=$message
 +                      prefix=
 +                      # skip all squash! or fixup! (but save for later)
 +                      while :
 +                      do
 +                              case "$rest" in
 +                              "squash! "*|"fixup! "*)
 +                                      prefix="$prefix${rest%%!*},"
 +                                      rest="${rest#*! }"
 +                                      ;;
 +                              *)
 +                                      break
 +                                      ;;
 +                              esac
 +                      done
 +                      echo "$sha1 $action $prefix $rest"
                        # if it's a single word, try to resolve to a full sha1 and
                        # emit a second copy. This allows us to match on both message
                        # and on sha1 prefix
                                if test -n "$fullsha"; then
                                        # prefix the action to uniquely identify this line as
                                        # intended for full sha1 match
 -                                      echo "$sha1 +$action $fullsha"
 +                                      echo "$sha1 +$action $prefix $fullsha"
                                fi
                        fi
                esac
                esac
                printf '%s\n' "$pick $sha1 $message"
                used="$used$sha1 "
 -              while read -r squash action msg_content
 +              while read -r squash action msg_prefix msg_content
                do
                        case " $used" in
                        *" $squash "*) continue ;;
                                case "$message" in "$msg_content"*) emit=1;; esac ;;
                        esac
                        if test $emit = 1; then
 -                              printf '%s\n' "$action $squash $action! $msg_content"
 +                              real_prefix=$(echo "$msg_prefix" | sed "s/,/! /g")
 +                              printf '%s\n' "$action $squash ${real_prefix}$msg_content"
                                used="$used$squash "
                        fi
                done <"$1.sq"
@@@ -830,13 -805,11 +830,13 @@@ first and then run 'git rebase --contin
  
        require_clean_work_tree "rebase"
        do_rest
 +      return 0
        ;;
  skip)
        git rerere clear
  
        do_rest
 +      return 0
        ;;
  edit-todo)
        git stripspace --strip-comments <"$todo" >"$todo".new
@@@ -864,15 -837,12 +864,15 @@@ comment_for_reflog star
  
  if test ! -z "$switch_to"
  then
 +      GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
        output git checkout "$switch_to" -- ||
 -              die "Could not checkout $switch_to"
 +      die "Could not checkout $switch_to"
 +
 +      comment_for_reflog start
  fi
  
  orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
 -mkdir "$state_dir" || die "Could not create temporary $state_dir"
 +mkdir -p "$state_dir" || die "Could not create temporary $state_dir"
  
  : > "$state_dir"/interactive || die "Could not mark as interactive"
  write_basic_state
@@@ -1010,7 -980,6 +1010,7 @@@ has_action "$todo" |
  
  test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
  
 +GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
  output git checkout $onto || die_abort "could not detach HEAD"
  git update-ref ORIG_HEAD $orig_head
  do_rest