From: "David A. Greene" <greened@xxxxxxxxxxxxx> Teach rebase to ignore redundant commits if told. Since rebase normally automatically skips redundant commits, this only applies when it has to use cherry-pick to do its work. In that case, pass the --skip-redundant-commits flag to cherry-pick. This allows scripted use of rebase with options like --preserve-merges that tend to invoke cherry-pick. Signed-off-by: David A. Greene <greened@xxxxxxxxxxxxx> --- git-rebase--interactive.sh | 14 ++++++++++++-- git-rebase.sh | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index c0cfe88..5891ff5 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -269,9 +269,14 @@ pick_one () { test -d "$rewritten" && pick_one_preserving_merges "$@" && return + redundant_args= + if test -n "$skip_redundant_commits" + then + redundant_args="--skip-redundant-commits" + fi output eval git cherry-pick \ ${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \ - "$strategy_args" $empty_args $ff "$@" + "$strategy_args" $empty_args $redundant_args $ff "$@" # If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule # previous task so this commit is not lost. @@ -389,9 +394,14 @@ pick_one_preserving_merges () { echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list" ;; *) + redundant_args= + if test -n "$skip_redundant_commits" + then + redundant_args="--skip-redundant-commits" + fi output eval git cherry-pick \ ${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \ - "$strategy_args" "$@" || + "$strategy_args" $redundant_args "$@" || die_with_patch $sha1 "Could not pick $sha1" ;; esac diff --git a/git-rebase.sh b/git-rebase.sh index af7ba5f..420a54f 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -24,6 +24,7 @@ m,merge! use merging strategies to rebase i,interactive! let the user edit the list of commits to rebase x,exec=! add exec lines after each commit of the editable list k,keep-empty preserve empty commits during rebase +skip-redundant-commits ignore redundant commits during rebase f,force-rebase! force rebase even if branch is up to date X,strategy-option=! pass the argument through to the merge strategy stat! display a diffstat of what changed upstream @@ -86,6 +87,7 @@ action= preserve_merges= autosquash= keep_empty= +skip_redundant_commits= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t gpg_sign_opt= @@ -255,6 +257,9 @@ do --keep-empty) keep_empty=yes ;; + --skip-redundant-commits) + skip_redundant_commits=yes + ;; --preserve-merges) preserve_merges=t test -z "$interactive_rebase" && interactive_rebase=implied -- 2.6.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html