rebase: remove unused code paths from git_rebase__interactive__preserve_merges

Since git_rebase__interactive__preserve_merges is now always called with
$preserve_merges = t we can remove the unused code paths.

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Wink Saville 2018-03-23 14:25:28 -07:00 committed by Junio C Hamano
parent c04549b263
commit ca3d446e44
1 changed files with 69 additions and 83 deletions

View File

@ -982,100 +982,86 @@ git_rebase__interactive__preserve_merges () {
setup_reflog_action setup_reflog_action
init_basic_state init_basic_state


if test t = "$preserve_merges" if test -z "$rebase_root"
then then
if test -z "$rebase_root" mkdir "$rewritten" &&
then for c in $(git merge-base --all $orig_head $upstream)
mkdir "$rewritten" && do
for c in $(git merge-base --all $orig_head $upstream) echo $onto > "$rewritten"/$c ||
do
echo $onto > "$rewritten"/$c ||
die "$(gettext "Could not init rewritten commits")"
done
else
mkdir "$rewritten" &&
echo $onto > "$rewritten"/root ||
die "$(gettext "Could not init rewritten commits")" die "$(gettext "Could not init rewritten commits")"
fi done
# No cherry-pick because our first pass is to determine
# parents to rewrite and skipping dropped commits would
# prematurely end our probe
merges_option=
else else
merges_option="--no-merges --cherry-pick" mkdir "$rewritten" &&
echo $onto > "$rewritten"/root ||
die "$(gettext "Could not init rewritten commits")"
fi fi


# No cherry-pick because our first pass is to determine
# parents to rewrite and skipping dropped commits would
# prematurely end our probe
merges_option=

init_revisions_and_shortrevisions init_revisions_and_shortrevisions


if test t != "$preserve_merges" format=$(git config --get rebase.instructionFormat)
then # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse
git rebase--helper --make-script ${keep_empty:+--keep-empty} \ git rev-list $merges_option --format="%m%H ${format:-%s}" \
$revisions ${restrict_revision+^$restrict_revision} >"$todo" || --reverse --left-right --topo-order \
die "$(gettext "Could not generate todo list")" $revisions ${restrict_revision+^$restrict_revision} | \
else sed -n "s/^>//p" |
format=$(git config --get rebase.instructionFormat) while read -r sha1 rest
# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse do
git rev-list $merges_option --format="%m%H ${format:-%s}" \
--reverse --left-right --topo-order \
$revisions ${restrict_revision+^$restrict_revision} | \
sed -n "s/^>//p" |
while read -r sha1 rest
do


if test -z "$keep_empty" && is_empty_commit $sha1 && ! is_merge_commit $sha1 if test -z "$keep_empty" && is_empty_commit $sha1 && ! is_merge_commit $sha1
then then
comment_out="$comment_char " comment_out="$comment_char "
else else
comment_out= comment_out=
fi fi


if test -z "$rebase_root" if test -z "$rebase_root"
then then
preserve=t preserve=t
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-) for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
do do
if test -f "$rewritten"/$p if test -f "$rewritten"/$p
then then
preserve=f preserve=f
fi fi
done done
else else
preserve=f preserve=f
fi fi
if test f = "$preserve" if test f = "$preserve"
then then
touch "$rewritten"/$sha1 touch "$rewritten"/$sha1
printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo"
fi fi
done done
fi


# Watch for commits that been dropped by --cherry-pick # Watch for commits that been dropped by --cherry-pick
if test t = "$preserve_merges" mkdir "$dropped"
then # Save all non-cherry-picked changes
mkdir "$dropped" git rev-list $revisions --left-right --cherry-pick | \
# Save all non-cherry-picked changes sed -n "s/^>//p" > "$state_dir"/not-cherry-picks
git rev-list $revisions --left-right --cherry-pick | \ # Now all commits and note which ones are missing in
sed -n "s/^>//p" > "$state_dir"/not-cherry-picks # not-cherry-picks and hence being dropped
# Now all commits and note which ones are missing in git rev-list $revisions |
# not-cherry-picks and hence being dropped while read rev
git rev-list $revisions | do
while read rev if test -f "$rewritten"/$rev &&
do ! sane_grep "$rev" "$state_dir"/not-cherry-picks >/dev/null
if test -f "$rewritten"/$rev && then
! sane_grep "$rev" "$state_dir"/not-cherry-picks >/dev/null # Use -f2 because if rev-list is telling us this commit is
then # not worthwhile, we don't want to track its multiple heads,
# Use -f2 because if rev-list is telling us this commit is # just the history of its first-parent for others that will
# not worthwhile, we don't want to track its multiple heads, # be rebasing on top of it
# just the history of its first-parent for others that will git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$dropped"/$rev
# be rebasing on top of it sha1=$(git rev-list -1 $rev)
git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$dropped"/$rev sane_grep -v "^[a-z][a-z]* $sha1" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
sha1=$(git rev-list -1 $rev) rm "$rewritten"/$rev
sane_grep -v "^[a-z][a-z]* $sha1" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo" fi
rm "$rewritten"/$rev done
fi
done
fi


complete_action complete_action
} }