Merge branch 'mg/rebase-i-onto-reflog-in-full' into maint-1.7.11
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Sep 2012 22:26:03 +0000 (15:26 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Sep 2012 22:26:03 +0000 (15:26 -0700)
The reflog entries left by "git rebase" and "git rebase -i" were
inconsistent (the interactive one gave an abbreviated object name).

* mg/rebase-i-onto-reflog-in-full:
rebase -i: use full onto sha1 in reflog

1  2 
git-rebase--interactive.sh
index 0c19b7c7539192851d5bd43df686baa97dc0df73,905346084ce0fbbb65273a8d2dbc42408289ea73..84926783d1c4956727226bbabe796467819d36e5
@@@ -167,14 -167,6 +167,14 @@@ has_action () 
        sane_grep '^[^#]' "$1" >/dev/null
  }
  
 +is_empty_commit() {
 +      tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null ||
 +              die "$1: not a commit that can be picked")
 +      ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null ||
 +              ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904)
 +      test "$tree" = "$ptree"
 +}
 +
  # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
  # GIT_AUTHOR_DATE exported from the current environment.
  do_with_author () {
@@@ -199,19 -191,12 +199,19 @@@ git_sequence_editor () 
  
  pick_one () {
        ff=--ff
 +
        case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
        case "$force_rebase" in '') ;; ?*) ff= ;; esac
        output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
 +
 +      if is_empty_commit "$sha1"
 +      then
 +              empty_args="--allow-empty"
 +      fi
 +
        test -d "$rewritten" &&
                pick_one_preserving_merges "$@" && return
 -      output git cherry-pick $ff "$@"
 +      output git cherry-pick $empty_args $ff "$@"
  }
  
  pick_one_preserving_merges () {
@@@ -548,11 -533,10 +548,10 @@@ do_next () 
        test -s "$todo" && return
  
        comment_for_reflog finish &&
-       shortonto=$(git rev-parse --short $onto) &&
        newhead=$(git rev-parse HEAD) &&
        case $head_name in
        refs/*)
-               message="$GIT_REFLOG_ACTION: $head_name onto $shortonto" &&
+               message="$GIT_REFLOG_ACTION: $head_name onto $onto" &&
                git update-ref -m "$message" $head_name $newhead $orig_head &&
                git symbolic-ref \
                  -m "$GIT_REFLOG_ACTION: returning to $head_name" \
@@@ -795,17 -779,9 +794,17 @@@ git rev-list $merges_option --pretty=on
        sed -n "s/^>//p" |
  while read -r shortsha1 rest
  do
 +
 +      if test -z "$keep_empty" && is_empty_commit $shortsha1
 +      then
 +              comment_out="# "
 +      else
 +              comment_out=
 +      fi
 +
        if test t != "$preserve_merges"
        then
 -              printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
 +              printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo"
        else
                sha1=$(git rev-parse $shortsha1)
                if test -z "$rebase_root"
                if test f = "$preserve"
                then
                        touch "$rewritten"/$sha1
 -                      printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
 +                      printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo"
                fi
        fi
  done
@@@ -876,12 -852,6 +875,12 @@@ cat >> "$todo" << EO
  #
  EOF
  
 +if test -z "$keep_empty"
 +then
 +      echo "# Note that empty commits are commented out" >>"$todo"
 +fi
 +
 +
  has_action "$todo" ||
        die_abort "Nothing to do"