* Re[2]: [PATCH 3/3] Fixes bug: GIT_PS1_SHOWDIRTYSTATE is no not respect diff.ignoreSubmodules config variable
From: Алексей Шумкин @ 2010-12-28 12:14 UTC (permalink / raw)
To: Jens Lehmann; +Cc: git, Johannes Schindelin
In-Reply-To: <4D15E48A.9050805@web.de>
Hi, all.
Well, I rolled back my so-called patch which rose up such a
discussion, and what I did see? Annoying behaviuor is vanished and perfomance of $PS1 is
acceptable (as fast as with the "patch").
I guess, as I said, something changed in Git since I discovered
and solved the problem such a weird way.
So, it seems to me, this patch might be considered unnecessary?
^ permalink raw reply
* [PATCH 00/31] Refactor rebase
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
For the past two months, I have been working on refactoring the rebase
code. See [1] for background information. I have been trying to polish
the patch set for some time, but now I don't think I will get much
further without your help.
My goals with this series were:
(1) Make it easier to add new features to git rebase by reducing the
amount of duplicated code. FWIW, this series removes about 140 lines
non-test code.
(2) Make the behavior (towards the user) more consistent between
interactive and non-interactive rebase. This mainly involves error
messages and command line options.
While not being a goal from the beginning, I have also tried to make
the code more readable. This is of course very subjective, so we'll
see - maybe in your eyes I just made things worse :-).
At a high level, I tried to do what was suggested by Johannes Sixt in
the second entry on [1], namely
"... to write a command line processor, git-rebase.sh, that sets shell
variables from options that it collects from various sources, then
dispatches to one of git-rebase--interactive.sh, git-rebase--merge.sh,
or git-rebase--am.sh (the latter two would be stripped-down copies of
the current git-rebase.sh)."
Patches 01-04 try to make git-rebase.sh more readable and extensible
by factoring out the code that reads the saved state from
.git/rebase-apply or .git/rebase-merge.
Patches 05-09 set the stage for further refactoring by aligning
git-rebase.sh and git-rebase--interactive.sh.
Patches 10-16 factor out parts from git-rebase--interactive.sh and let
it rely on the corresponding code in git-rebase.sh.
Patch 17 just removes a duplicated variable.
Patches 18 and 19 extract the am-specific and merge-specifc rebase
code into two new source files (as suggested by Hannes).
Patch 20 makes interactive rebase print the same message as
non-interactive rebase in case of conflict.
Patches 21 and 22 prepare for further refactoring by aligning
interactive and non-interactive rebase a bit more.
Patch 23 factors out part or all of the handling of --continue, --skip
and --abort from git-rebase--interactive to git-rebase.sh.
Patches 24-27 makes rebase remember more options passed on the command
line thoughout the rebase (past any conflicts).
Patches 28-31 remove some unnecessary code.
I have tried to separate pure refactoring from changes that make
functional changes, but there are still some functional changes hiding
in the "refactoring" patches. I have tried to point this out in the
commit message where applicable, but I'm sure I have missed a lot of
places.
/Martin
[1] http://thread.gmane.org/gmane.comp.version-control.git/160517
Martin von Zweigbergk (31):
rebase: clearer names for directory variables
rebase: refactor reading of state
rebase: read state outside loop
rebase: remove unused rebase state 'prev_head'
rebase: improve detection of rebase in progress
rebase: act on command line outside parsing loop
rebase: stricter check of standalone sub command
rebase: align variable names
rebase: align variable content
rebase: factor out command line option processing
rebase -i: remove now unnecessary directory checks
rebase: reorder validation steps
rebase: factor out reference parsing
rebase: factor out clean work tree check
rebase: factor out call to pre-rebase hook
rebase -i: support --stat
rebase: remove $branch as synonym for $orig_head
rebase: extract merge code to new source file
rebase: extract am code to new source file
rebase: show consistent conflict resolution hint
rebase -i: align variable names
rebase: make -v a tiny bit more verbose
rebase: factor out sub command handling
rebase: extract code for writing basic state
rebase: remember verbose option
rebase: remember strategy and strategy options
rebase -m: remember allow_rerere_autoupdate option
rebase -m: don't print exit code 2 when merge fails
git-rebase--am: remove unnecessary --3way option
rebase -i: don't read unused variable preserve_merges
rebase -i: remove unnecessary state rebase-root
.gitignore | 2 +
Makefile | 2 +
git-rebase--am.sh | 30 +++
git-rebase--interactive.sh | 589 ++++++++++++++------------------------------
git-rebase--merge.sh | 151 +++++++++++
git-rebase.sh | 477 ++++++++++++++---------------------
t/t3403-rebase-skip.sh | 5 +
t/t3407-rebase-abort.sh | 10 +
t/t3418-rebase-continue.sh | 55 ++++
9 files changed, 627 insertions(+), 694 deletions(-)
create mode 100644 git-rebase--am.sh
create mode 100644 git-rebase--merge.sh
--
1.7.3.2.864.gbbb96
^ permalink raw reply
* "git show" does not use diff.external like "git diff" does
From: Bruce Momjian @ 2010-12-28 15:10 UTC (permalink / raw)
To: git
I have diff.external configured properly, and it is used by "git diff",
but "git show" does not call the script and only returns unified diffs.
Is there a way to make "git show" use an external diff script?
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply
* [PATCH 04/31] rebase: remove unused rebase state 'prev_head'
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
The state stored in $GIT_DIR/rebase-merge/prev_head was introduced in
58634db (rebase: Allow merge strategies to be used when rebasing,
2006-06-21), but it was never used and should therefore be removed.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 9be831e..af9bd14 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -61,7 +61,6 @@ read_state () {
if test -d "$merge_dir"
then
state_dir="$merge_dir"
- prev_head=$(cat "$merge_dir"/prev_head) &&
onto_name=$(cat "$merge_dir"/onto_name) &&
end=$(cat "$merge_dir"/end) &&
msgnum=$(cat "$merge_dir"/msgnum)
@@ -75,7 +74,6 @@ read_state () {
}
continue_merge () {
- test -n "$prev_head" || die "prev_head must be defined"
test -d "$merge_dir" || die "$merge_dir directory does not exist"
unmerged=$(git ls-files -u)
@@ -109,10 +107,6 @@ continue_merge () {
test -z "$GIT_QUIET" &&
GIT_PAGER='' git log --format=%s -1 "$cmt"
- prev_head=`git rev-parse HEAD^0`
- # save the resulting commit so we can read-tree on it later
- echo "$prev_head" > "$merge_dir/prev_head"
-
# onto the next patch:
msgnum=$(($msgnum + 1))
echo "$msgnum" >"$merge_dir/msgnum"
@@ -567,8 +561,6 @@ fi
mkdir -p "$merge_dir"
echo "$onto_name" > "$merge_dir/onto_name"
-prev_head=$orig_head
-echo "$prev_head" > "$merge_dir/prev_head"
echo "$head_name" > "$merge_dir/head-name"
echo "$onto" > "$merge_dir/onto"
echo "$orig_head" > "$merge_dir/orig-head"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 05/31] rebase: improve detection of rebase in progress
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Detect early on if a rebase is in progress and what type of rebase it
is (interactive, merge-based or am-based). This prepares for further
refactoring where am-based rebase will be dispatched to
git-rebase--am.sh and merge-based rebase will be dispatched to
git-rebase--merge.sh.
The idea is to use the same variables whether the type of rebase was
detected from rebase-apply/ or rebase-merge/ directories or from the
command line options. This will make the code more readable and will
later also make it easier to dispatch to the type-specific scripts.
Also show a consistent error message independent of the type of rebase
that was in progress and remove the obsolete wording about being in
the middle of a 'patch application', since that (an existing
"$GIT_DIR"/rebase-apply/applying) aborts 'git rebase' at an earlier
stage.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Currently, the existence of rebase-merge/ is tested with 'test -d',
while the existence of rebase-apply/ is tested by creating the
directory and then deleting it again. Any good reason for this?
git-rebase.sh | 80 +++++++++++++++++++++++++++++---------------------------
1 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index af9bd14..718cb26 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -56,16 +56,19 @@ git_am_opt=
rebase_root=
force_rebase=
allow_rerere_autoupdate=
+# Non-empty if a rebase was in progress when 'git rebase' was invoked
+in_progress=
+# One of {am, merge, interactive}
+type=
+# One of {"$GIT_DIR"/rebase-apply, "$GIT_DIR"/rebase-merge}
+state_dir=
read_state () {
- if test -d "$merge_dir"
+ if test "$type" = merge
then
- state_dir="$merge_dir"
- onto_name=$(cat "$merge_dir"/onto_name) &&
- end=$(cat "$merge_dir"/end) &&
- msgnum=$(cat "$merge_dir"/msgnum)
- else
- state_dir="$apply_dir"
+ onto_name=$(cat "$state_dir"/onto_name) &&
+ end=$(cat "$state_dir"/end) &&
+ msgnum=$(cat "$state_dir"/msgnum)
fi &&
head_name=$(cat "$state_dir"/head-name) &&
onto=$(cat "$state_dir"/onto) &&
@@ -207,6 +210,23 @@ test -f "$apply_dir"/applying &&
is_interactive "$@" && exec git-rebase--interactive "$@"
+if test -d "$apply_dir"
+then
+ type=am
+ state_dir="$apply_dir"
+elif test -d "$merge_dir"
+then
+ if test -f "$merge_dir"/interactive
+ then
+ type=interactive
+ interactive_rebase=explicit
+ else
+ type=merge
+ fi
+ state_dir="$merge_dir"
+fi
+test -n "$type" && in_progress=t
+
while test $# != 0
do
case "$1" in
@@ -217,8 +237,7 @@ do
OK_TO_SKIP_PRE_REBASE=
;;
--continue)
- test -d "$merge_dir" -o -d "$apply_dir" ||
- die "No rebase in progress?"
+ test -z "$in_progress" && die "No rebase in progress?"
git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules || {
@@ -243,8 +262,7 @@ do
exit
;;
--skip)
- test -d "$merge_dir" -o -d "$apply_dir" ||
- die "No rebase in progress?"
+ test -z "$in_progress" && die "No rebase in progress?"
git reset --hard HEAD || exit $?
read_state
@@ -265,8 +283,7 @@ do
exit
;;
--abort)
- test -d "$merge_dir" -o -d "$apply_dir" ||
- die "No rebase in progress?"
+ test -z "$in_progress" && die "No rebase in progress?"
git rerere clear
read_state
@@ -374,37 +391,22 @@ do
done
test $# -gt 2 && usage
-if test $# -eq 0 && test -z "$rebase_root"
+# Make sure no rebase is in progress
+if test -n "$in_progress"
then
- test -d "$merge_dir" -o -d "$apply_dir" || usage
- test -d "$merge_dir" -o -f "$apply_dir"/rebasing &&
- die 'A rebase is in progress, try --continue, --skip or --abort.'
-fi
-
-# Make sure we do not have $apply_dir or $merge_dir
-if test -z "$do_merge"
-then
- if mkdir "$apply_dir" 2>/dev/null
- then
- rmdir "$apply_dir"
- else
- echo >&2 '
-It seems that I cannot create a rebase-apply directory, and
-I wonder if you are in the middle of patch application or another
-rebase. If that is not the case, please
- rm -fr '"$apply_dir"'
+ die '
+It seems that there is already a '"${state_dir##*/}"' directory, and
+I wonder if you are in the middle of another rebase. If that is the
+case, please try
+ git rebase (--continue | --abort | --skip)
+If that is not the case, please
+ rm -fr '"$state_dir"'
and run me again. I am stopping in case you still have something
valuable there.'
- exit 1
- fi
-else
- if test -d "$merge_dir"
- then
- die "previous rebase directory $merge_dir still exists." \
- 'Try git rebase (--continue | --abort | --skip)'
- fi
fi
+test $# -eq 0 && test -z "$rebase_root" && usage
+
require_clean_work_tree "rebase" "Please commit or stash them."
if test -z "$rebase_root"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 06/31] rebase: act on command line outside parsing loop
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
To later be able to use the command line processing in git-rebase.sh
for both interactive and non-interactive rebases, move anything that
is specific to non-interactive rebase outside of the parsing
loop. Keep only parsing and validation of command line options in the
loop.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
May want to view this patch with --ignore-all-space.
git-rebase--interactive.sh | 300 ++++++++++++++++++++++----------------------
git-rebase.sh | 126 ++++++++++---------
2 files changed, 217 insertions(+), 209 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a5ffd9a..8cbdd3f 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -866,152 +866,158 @@ first and then run 'git rebase --continue' again."
;;
--)
shift
- test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
- test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
- test -d "$DOTEST" &&
- die "Interactive rebase already started"
-
- git var GIT_COMMITTER_IDENT >/dev/null ||
- die "You need to set your committer info first"
-
- if test -z "$REBASE_ROOT"
- then
- UPSTREAM_ARG="$1"
- UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
- test -z "$ONTO" && ONTO=$UPSTREAM
- shift
- else
- UPSTREAM=
- UPSTREAM_ARG=--root
- test -z "$ONTO" &&
- die "You must specify --onto when using --root"
- fi
- run_pre_rebase_hook "$UPSTREAM_ARG" "$@"
-
- comment_for_reflog start
-
- require_clean_work_tree "rebase" "Please commit or stash them."
-
- if test ! -z "$1"
- then
- output git checkout "$1" ||
- die "Could not checkout $1"
- fi
+ break
+ ;;
+ esac
+ shift
+done
- HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
- mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
+test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
+test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
+test -d "$DOTEST" &&
+ die "Interactive rebase already started"
- : > "$DOTEST"/interactive || die "Could not mark as interactive"
- git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
- echo "detached HEAD" > "$DOTEST"/head-name
+git var GIT_COMMITTER_IDENT >/dev/null ||
+ die "You need to set your committer info first"
- echo $HEAD > "$DOTEST"/head
- case "$REBASE_ROOT" in
- '')
- rm -f "$DOTEST"/rebase-root ;;
- *)
- : >"$DOTEST"/rebase-root ;;
- esac
- echo $ONTO > "$DOTEST"/onto
- test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
- test t = "$VERBOSE" && : > "$DOTEST"/verbose
- if test t = "$PRESERVE_MERGES"
- then
- if test -z "$REBASE_ROOT"
- then
- mkdir "$REWRITTEN" &&
- for c in $(git merge-base --all $HEAD $UPSTREAM)
- do
- echo $ONTO > "$REWRITTEN"/$c ||
- die "Could not init rewritten commits"
- done
- else
- mkdir "$REWRITTEN" &&
- echo $ONTO > "$REWRITTEN"/root ||
- die "Could not init rewritten commits"
- 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=
- first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
- else
- MERGES_OPTION="--no-merges --cherry-pick"
- fi
-
- SHORTHEAD=$(git rev-parse --short $HEAD)
- SHORTONTO=$(git rev-parse --short $ONTO)
- if test -z "$REBASE_ROOT"
- # this is now equivalent to ! -z "$UPSTREAM"
- then
- SHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)
- REVISIONS=$UPSTREAM...$HEAD
- SHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD
- else
- REVISIONS=$ONTO...$HEAD
- SHORTREVISIONS=$SHORTHEAD
- fi
- git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
- --abbrev=7 --reverse --left-right --topo-order \
- $REVISIONS | \
- sed -n "s/^>//p" |
- while read -r shortsha1 rest
+if test -z "$REBASE_ROOT"
+then
+ UPSTREAM_ARG="$1"
+ UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
+ test -z "$ONTO" && ONTO=$UPSTREAM
+ shift
+else
+ UPSTREAM=
+ UPSTREAM_ARG=--root
+ test -z "$ONTO" &&
+ die "You must specify --onto when using --root"
+fi
+run_pre_rebase_hook "$UPSTREAM_ARG" "$@"
+
+comment_for_reflog start
+
+require_clean_work_tree "rebase" "Please commit or stash them."
+
+if test ! -z "$1"
+then
+ output git checkout "$1" ||
+ die "Could not checkout $1"
+fi
+
+HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
+mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
+
+: > "$DOTEST"/interactive || die "Could not mark as interactive"
+git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
+ echo "detached HEAD" > "$DOTEST"/head-name
+
+echo $HEAD > "$DOTEST"/head
+case "$REBASE_ROOT" in
+'')
+ rm -f "$DOTEST"/rebase-root ;;
+*)
+ : >"$DOTEST"/rebase-root ;;
+esac
+echo $ONTO > "$DOTEST"/onto
+test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
+test t = "$VERBOSE" && : > "$DOTEST"/verbose
+if test t = "$PRESERVE_MERGES"
+then
+ if test -z "$REBASE_ROOT"
+ then
+ mkdir "$REWRITTEN" &&
+ for c in $(git merge-base --all $HEAD $UPSTREAM)
do
- if test t != "$PRESERVE_MERGES"
- then
- printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
- else
- sha1=$(git rev-parse $shortsha1)
- if test -z "$REBASE_ROOT"
- then
- preserve=t
- for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
- do
- if test -f "$REWRITTEN"/$p -a \( $p != $ONTO -o $sha1 = $first_after_upstream \)
- then
- preserve=f
- fi
- done
- else
- preserve=f
- fi
- if test f = "$preserve"
- then
- touch "$REWRITTEN"/$sha1
- printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
- fi
- fi
+ echo $ONTO > "$REWRITTEN"/$c ||
+ die "Could not init rewritten commits"
done
-
- # Watch for commits that been dropped by --cherry-pick
- if test t = "$PRESERVE_MERGES"
+ else
+ mkdir "$REWRITTEN" &&
+ echo $ONTO > "$REWRITTEN"/root ||
+ die "Could not init rewritten commits"
+ 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=
+ first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
+else
+ MERGES_OPTION="--no-merges --cherry-pick"
+fi
+
+SHORTHEAD=$(git rev-parse --short $HEAD)
+SHORTONTO=$(git rev-parse --short $ONTO)
+if test -z "$REBASE_ROOT"
+ # this is now equivalent to ! -z "$UPSTREAM"
+then
+ SHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)
+ REVISIONS=$UPSTREAM...$HEAD
+ SHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD
+else
+ REVISIONS=$ONTO...$HEAD
+ SHORTREVISIONS=$SHORTHEAD
+fi
+git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
+ --abbrev=7 --reverse --left-right --topo-order \
+ $REVISIONS | \
+ sed -n "s/^>//p" |
+while read -r shortsha1 rest
+do
+ if test t != "$PRESERVE_MERGES"
+ then
+ printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
+ else
+ sha1=$(git rev-parse $shortsha1)
+ if test -z "$REBASE_ROOT"
then
- mkdir "$DROPPED"
- # Save all non-cherry-picked changes
- git rev-list $REVISIONS --left-right --cherry-pick | \
- sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
- # Now all commits and note which ones are missing in
- # not-cherry-picks and hence being dropped
- git rev-list $REVISIONS |
- while read rev
+ preserve=t
+ for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
do
- if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
+ if test -f "$REWRITTEN"/$p -a \( $p != $ONTO -o $sha1 = $first_after_upstream \)
then
- # Use -f2 because if rev-list is telling us this commit is
- # not worthwhile, we don't want to track its multiple heads,
- # just the history of its first-parent for others that will
- # be rebasing on top of it
- git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$DROPPED"/$rev
- short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
- sane_grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
- rm "$REWRITTEN"/$rev
+ preserve=f
fi
done
+ else
+ preserve=f
+ fi
+ if test f = "$preserve"
+ then
+ touch "$REWRITTEN"/$sha1
+ printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
fi
+ fi
+done
- test -s "$TODO" || echo noop >> "$TODO"
- test -n "$AUTOSQUASH" && rearrange_squash "$TODO"
- cat >> "$TODO" << EOF
+# Watch for commits that been dropped by --cherry-pick
+if test t = "$PRESERVE_MERGES"
+then
+ mkdir "$DROPPED"
+ # Save all non-cherry-picked changes
+ git rev-list $REVISIONS --left-right --cherry-pick | \
+ sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
+ # Now all commits and note which ones are missing in
+ # not-cherry-picks and hence being dropped
+ git rev-list $REVISIONS |
+ while read rev
+ do
+ if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
+ then
+ # Use -f2 because if rev-list is telling us this commit is
+ # not worthwhile, we don't want to track its multiple heads,
+ # just the history of its first-parent for others that will
+ # be rebasing on top of it
+ git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$DROPPED"/$rev
+ short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
+ sane_grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
+ rm "$REWRITTEN"/$rev
+ fi
+ done
+fi
+
+test -s "$TODO" || echo noop >> "$TODO"
+test -n "$AUTOSQUASH" && rearrange_squash "$TODO"
+cat >> "$TODO" << EOF
# Rebase $SHORTREVISIONS onto $SHORTONTO
#
@@ -1028,22 +1034,18 @@ first and then run 'git rebase --continue' again."
#
EOF
- has_action "$TODO" ||
- die_abort "Nothing to do"
+has_action "$TODO" ||
+ die_abort "Nothing to do"
- cp "$TODO" "$TODO".backup
- git_editor "$TODO" ||
- die_abort "Could not execute editor"
+cp "$TODO" "$TODO".backup
+git_editor "$TODO" ||
+ die_abort "Could not execute editor"
- has_action "$TODO" ||
- die_abort "Nothing to do"
+has_action "$TODO" ||
+ die_abort "Nothing to do"
- test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
+test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
- output git checkout $ONTO || die_abort "could not detach HEAD"
- git update-ref ORIG_HEAD $HEAD
- do_rest
- ;;
- esac
- shift
-done
+output git checkout $ONTO || die_abort "could not detach HEAD"
+git update-ref ORIG_HEAD $HEAD
+do_rest
diff --git a/git-rebase.sh b/git-rebase.sh
index 718cb26..29f1214 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -62,6 +62,8 @@ in_progress=
type=
# One of {"$GIT_DIR"/rebase-apply, "$GIT_DIR"/rebase-merge}
state_dir=
+# One of {'', continue, skip, abort}, as parsed from command line
+action=
read_state () {
if test "$type" = merge
@@ -236,66 +238,10 @@ do
--verify)
OK_TO_SKIP_PRE_REBASE=
;;
- --continue)
- test -z "$in_progress" && die "No rebase in progress?"
-
- git update-index --ignore-submodules --refresh &&
- git diff-files --quiet --ignore-submodules || {
- echo "You must edit all merge conflicts and then"
- echo "mark them as resolved using git add"
- exit 1
- }
- read_state
- if test -d "$merge_dir"
- then
- continue_merge
- while test "$msgnum" -le "$end"
- do
- call_merge "$msgnum"
- continue_merge
- done
- finish_rb_merge
- exit
- fi
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
- move_to_original_branch
- exit
- ;;
- --skip)
- test -z "$in_progress" && die "No rebase in progress?"
-
- git reset --hard HEAD || exit $?
- read_state
- if test -d "$merge_dir"
- then
- git rerere clear
- msgnum=$(($msgnum + 1))
- while test "$msgnum" -le "$end"
- do
- call_merge "$msgnum"
- continue_merge
- done
- finish_rb_merge
- exit
- fi
- git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
- move_to_original_branch
- exit
- ;;
- --abort)
- test -z "$in_progress" && die "No rebase in progress?"
-
- git rerere clear
- read_state
- case "$head_name" in
- refs/*)
- git symbolic-ref HEAD $head_name ||
- die "Could not move back to $head_name"
- ;;
- esac
- git reset --hard $orig_head
- rm -r "$state_dir"
- exit
+ --continue|--skip|--abort)
+ action=${1##--}
+ shift
+ break
;;
--onto)
test 2 -le "$#" || usage
@@ -391,6 +337,66 @@ do
done
test $# -gt 2 && usage
+test -n "$action" && test -z "$in_progress" && die "No rebase in progress?"
+
+case "$action" in
+continue)
+ git update-index --ignore-submodules --refresh &&
+ git diff-files --quiet --ignore-submodules || {
+ echo "You must edit all merge conflicts and then"
+ echo "mark them as resolved using git add"
+ exit 1
+ }
+ read_state
+ if test -d "$merge_dir"
+ then
+ continue_merge
+ while test "$msgnum" -le "$end"
+ do
+ call_merge "$msgnum"
+ continue_merge
+ done
+ finish_rb_merge
+ exit
+ fi
+ git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
+ move_to_original_branch
+ exit
+ ;;
+skip)
+ git reset --hard HEAD || exit $?
+ read_state
+ if test -d "$merge_dir"
+ then
+ git rerere clear
+ msgnum=$(($msgnum + 1))
+ while test "$msgnum" -le "$end"
+ do
+ call_merge "$msgnum"
+ continue_merge
+ done
+ finish_rb_merge
+ exit
+ fi
+ git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
+ move_to_original_branch
+ exit
+ ;;
+abort)
+ git rerere clear
+ read_state
+ case "$head_name" in
+ refs/*)
+ git symbolic-ref HEAD $head_name ||
+ die "Could not move back to $head_name"
+ ;;
+ esac
+ git reset --hard $orig_head
+ rm -r "$state_dir"
+ exit
+ ;;
+esac
+
# Make sure no rebase is in progress
if test -n "$in_progress"
then
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 09/31] rebase: align variable content
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Make sure to interpret variables with the same name in the same way in
git-rebase.sh and git-rebase--interactive.sh. This will make it easier
to factor out code from git-rebase.sh to git-rebase--interactive and
export the variables.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 16 +++++++++++-----
git-rebase.sh | 4 +++-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 310d80e..1af739a 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -339,7 +339,8 @@ pick_one_preserving_merges () {
# No point in merging the first parent, that's HEAD
new_parents=${new_parents# $first_parent}
if ! do_with_author output \
- git merge $strategy -m "$msg" $new_parents
+ git merge ${strategy:+-s $strategy} -m "$msg" \
+ $new_parents
then
printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
die_with_patch $sha1 "Error redoing merge $sha1"
@@ -827,11 +828,11 @@ first and then run 'git rebase --continue' again."
-s)
case "$#,$1" in
*,*=*)
- strategy="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
+ strategy=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
1,*)
usage ;;
*)
- strategy="-s $2"
+ strategy="$2"
shift ;;
esac
;;
@@ -860,9 +861,9 @@ first and then run 'git rebase --continue' again."
autosquash=
;;
--onto)
+ test 2 -le "$#" || usage
+ onto="$2"
shift
- onto=$(parse_onto "$1") ||
- die "Does not point to a valid commit: $1"
;;
--)
shift
@@ -872,6 +873,11 @@ first and then run 'git rebase --continue' again."
shift
done
+if test -n "$onto"
+then
+ onto=$(parse_onto "$onto") || die "Does not point to a valid commit: $1"
+fi
+
test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
test ! -z "$rebase_root" -a $# -le 1 || usage
test -d "$DOTEST" &&
diff --git a/git-rebase.sh b/git-rebase.sh
index dc133e3..21366ba 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,7 +43,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\".
To restore the original branch and stop rebasing run \"git rebase --abort\".
"
unset onto
-strategy=recursive
+strategy=
strategy_opts=
do_merge=
merge_dir="$GIT_DIR"/rebase-merge
@@ -130,6 +130,7 @@ call_merge () {
then
GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
fi
+ test -z "$strategy" && strategy=recursive
eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
rv=$?
case "$rv" in
@@ -267,6 +268,7 @@ do
esac
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
do_merge=t
+ test -z "$strategy" && strategy=recursive
;;
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
--strateg=*|--strategy=*|\
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 08/31] rebase: align variable names
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Use the same names for variables that git-rebase--interactive.sh will
soon inherit from git-rebase.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 138 ++++++++++++++++++++++----------------------
git-rebase.sh | 8 +-
2 files changed, 73 insertions(+), 73 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 8cbdd3f..310d80e 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -77,7 +77,7 @@ FIXUP_MSG="$DOTEST"/message-fixup
# $REWRITTEN is the name of a directory containing files for each
# commit that is reachable by at least one merge base of $HEAD and
-# $UPSTREAM. They are not necessarily rewritten, but their children
+# $upstream. They are not necessarily rewritten, but their children
# might be. This ensures that commits on merged, but otherwise
# unrelated side branches are left alone. (Think "X" in the man page's
# example.)
@@ -105,15 +105,15 @@ AMEND="$DOTEST"/amend
REWRITTEN_LIST="$DOTEST"/rewritten-list
REWRITTEN_PENDING="$DOTEST"/rewritten-pending
-PRESERVE_MERGES=
-STRATEGY=
-ONTO=
-VERBOSE=
+preserve_merges=
+strategy=
+onto=
+verbose=
OK_TO_SKIP_PRE_REBASE=
-REBASE_ROOT=
-AUTOSQUASH=
-test "$(git config --bool rebase.autosquash)" = "true" && AUTOSQUASH=t
-NEVER_FF=
+rebase_root=
+autosquash=
+test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
+force_rebase=
GIT_CHERRY_PICK_HELP="\
hint: after resolving the conflicts, mark the corrected paths
@@ -125,7 +125,7 @@ warn () {
}
output () {
- case "$VERBOSE" in
+ case "$verbose" in
'')
output=$("$@" 2>&1 )
status=$?
@@ -177,7 +177,7 @@ mark_action_done () {
then
last_count=$count
printf "Rebasing (%d/%d)\r" $count $total
- test -z "$VERBOSE" || echo
+ test -z "$verbose" || echo
fi
}
@@ -228,11 +228,11 @@ do_with_author () {
pick_one () {
ff=--ff
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
- case "$NEVER_FF" in '') ;; ?*) ff= ;; esac
+ case "$force_rebase" in '') ;; ?*) ff= ;; esac
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
test -d "$REWRITTEN" &&
pick_one_preserving_merges "$@" && return
- if test -n "$REBASE_ROOT"
+ if test -n "$rebase_root"
then
output git cherry-pick "$@"
return
@@ -339,7 +339,7 @@ pick_one_preserving_merges () {
# No point in merging the first parent, that's HEAD
new_parents=${new_parents# $first_parent}
if ! do_with_author output \
- git merge $STRATEGY -m "$msg" $new_parents
+ git merge $strategy -m "$msg" $new_parents
then
printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
die_with_patch $sha1 "Error redoing merge $sha1"
@@ -618,11 +618,11 @@ skip_unnecessary_picks () {
# fd=3 means we skip the command
case "$fd,$command" in
3,pick|3,p)
- # pick a commit whose parent is current $ONTO -> skip
+ # pick a commit whose parent is current $onto -> skip
sha1=${rest%% *}
case "$(git rev-parse --verify --quiet "$sha1"^)" in
- "$ONTO"*)
- ONTO=$sha1
+ "$onto"*)
+ onto=$sha1
;;
*)
fd=1
@@ -641,7 +641,7 @@ skip_unnecessary_picks () {
mv -f "$TODO".new "$TODO" &&
case "$(peek_next_command)" in
squash|s|fixup|f)
- record_in_rewritten "$ONTO"
+ record_in_rewritten "$onto"
;;
esac ||
die "Could not skip unnecessary pick commands"
@@ -650,17 +650,17 @@ skip_unnecessary_picks () {
# check if no other options are set
is_standalone () {
test $# -eq 2 -a "$2" = '--' &&
- test -z "$ONTO" &&
- test -z "$PRESERVE_MERGES" &&
- test -z "$STRATEGY" &&
- test -z "$VERBOSE"
+ test -z "$onto" &&
+ test -z "$preserve_merges" &&
+ test -z "$strategy" &&
+ test -z "$verbose"
}
get_saved_options () {
- test -d "$REWRITTEN" && PRESERVE_MERGES=t
- test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
- test -f "$DOTEST"/verbose && VERBOSE=t
- test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
+ test -d "$REWRITTEN" && preserve_merges=t
+ test -f "$DOTEST"/strategy && strategy="$(cat "$DOTEST"/strategy)"
+ test -f "$DOTEST"/verbose && verbose=t
+ test -f "$DOTEST"/rebase-root && rebase_root=t
}
# Rearrange the todo list that has both "pick sha1 msg" and
@@ -827,11 +827,11 @@ first and then run 'git rebase --continue' again."
-s)
case "$#,$1" in
*,*=*)
- STRATEGY="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
+ strategy="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
1,*)
usage ;;
*)
- STRATEGY="-s $2"
+ strategy="-s $2"
shift ;;
esac
;;
@@ -839,29 +839,29 @@ first and then run 'git rebase --continue' again."
# we use merge anyway
;;
-v)
- VERBOSE=t
+ verbose=t
;;
-p)
- PRESERVE_MERGES=t
+ preserve_merges=t
;;
-i)
# yeah, we know
;;
--no-ff)
- NEVER_FF=t
+ force_rebase=t
;;
--root)
- REBASE_ROOT=t
+ rebase_root=t
;;
--autosquash)
- AUTOSQUASH=t
+ autosquash=t
;;
--no-autosquash)
- AUTOSQUASH=
+ autosquash=
;;
--onto)
shift
- ONTO=$(parse_onto "$1") ||
+ onto=$(parse_onto "$1") ||
die "Does not point to a valid commit: $1"
;;
--)
@@ -872,27 +872,27 @@ first and then run 'git rebase --continue' again."
shift
done
-test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
-test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
+test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
+test ! -z "$rebase_root" -a $# -le 1 || usage
test -d "$DOTEST" &&
die "Interactive rebase already started"
git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first"
-if test -z "$REBASE_ROOT"
+if test -z "$rebase_root"
then
- UPSTREAM_ARG="$1"
- UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
- test -z "$ONTO" && ONTO=$UPSTREAM
+ upstream_arg="$1"
+ upstream=$(git rev-parse --verify "$1") || die "Invalid base"
+ test -z "$onto" && onto=$upstream
shift
else
- UPSTREAM=
- UPSTREAM_ARG=--root
- test -z "$ONTO" &&
- die "You must specify --onto when using --root"
+ upstream=
+ upstream_arg=--root
+ test -z "$onto" &&
+ die "You must specify --onto when using --root"
fi
-run_pre_rebase_hook "$UPSTREAM_ARG" "$@"
+run_pre_rebase_hook "$upstream_arg" "$@"
comment_for_reflog start
@@ -912,49 +912,49 @@ git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
echo "detached HEAD" > "$DOTEST"/head-name
echo $HEAD > "$DOTEST"/head
-case "$REBASE_ROOT" in
+case "$rebase_root" in
'')
rm -f "$DOTEST"/rebase-root ;;
*)
: >"$DOTEST"/rebase-root ;;
esac
-echo $ONTO > "$DOTEST"/onto
-test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
-test t = "$VERBOSE" && : > "$DOTEST"/verbose
-if test t = "$PRESERVE_MERGES"
+echo $onto > "$DOTEST"/onto
+test -z "$strategy" || echo "$strategy" > "$DOTEST"/strategy
+test t = "$verbose" && : > "$DOTEST"/verbose
+if test t = "$preserve_merges"
then
- if test -z "$REBASE_ROOT"
+ if test -z "$rebase_root"
then
mkdir "$REWRITTEN" &&
- for c in $(git merge-base --all $HEAD $UPSTREAM)
+ for c in $(git merge-base --all $HEAD $upstream)
do
- echo $ONTO > "$REWRITTEN"/$c ||
+ echo $onto > "$REWRITTEN"/$c ||
die "Could not init rewritten commits"
done
else
mkdir "$REWRITTEN" &&
- echo $ONTO > "$REWRITTEN"/root ||
+ echo $onto > "$REWRITTEN"/root ||
die "Could not init rewritten commits"
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=
- first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
+ first_after_upstream="$(git rev-list --reverse --first-parent $upstream..$HEAD | head -n 1)"
else
MERGES_OPTION="--no-merges --cherry-pick"
fi
SHORTHEAD=$(git rev-parse --short $HEAD)
-SHORTONTO=$(git rev-parse --short $ONTO)
-if test -z "$REBASE_ROOT"
- # this is now equivalent to ! -z "$UPSTREAM"
+SHORTONTO=$(git rev-parse --short $onto)
+if test -z "$rebase_root"
+ # this is now equivalent to ! -z "$upstream"
then
- SHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)
- REVISIONS=$UPSTREAM...$HEAD
+ SHORTUPSTREAM=$(git rev-parse --short $upstream)
+ REVISIONS=$upstream...$HEAD
SHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD
else
- REVISIONS=$ONTO...$HEAD
+ REVISIONS=$onto...$HEAD
SHORTREVISIONS=$SHORTHEAD
fi
git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
@@ -963,17 +963,17 @@ git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
sed -n "s/^>//p" |
while read -r shortsha1 rest
do
- if test t != "$PRESERVE_MERGES"
+ if test t != "$preserve_merges"
then
printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
else
sha1=$(git rev-parse $shortsha1)
- if test -z "$REBASE_ROOT"
+ if test -z "$rebase_root"
then
preserve=t
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
do
- if test -f "$REWRITTEN"/$p -a \( $p != $ONTO -o $sha1 = $first_after_upstream \)
+ if test -f "$REWRITTEN"/$p -a \( $p != $onto -o $sha1 = $first_after_upstream \)
then
preserve=f
fi
@@ -990,7 +990,7 @@ do
done
# Watch for commits that been dropped by --cherry-pick
-if test t = "$PRESERVE_MERGES"
+if test t = "$preserve_merges"
then
mkdir "$DROPPED"
# Save all non-cherry-picked changes
@@ -1016,7 +1016,7 @@ then
fi
test -s "$TODO" || echo noop >> "$TODO"
-test -n "$AUTOSQUASH" && rearrange_squash "$TODO"
+test -n "$autosquash" && rearrange_squash "$TODO"
cat >> "$TODO" << EOF
# Rebase $SHORTREVISIONS onto $SHORTONTO
@@ -1044,8 +1044,8 @@ git_editor "$TODO" ||
has_action "$TODO" ||
die_abort "Nothing to do"
-test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
+test -d "$REWRITTEN" || test -n "$force_rebase" || skip_unnecessary_picks
-output git checkout $ONTO || die_abort "could not detach HEAD"
+output git checkout $onto || die_abort "could not detach HEAD"
git update-ref ORIG_HEAD $HEAD
do_rest
diff --git a/git-rebase.sh b/git-rebase.sh
index 1cb0564..dc133e3 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -42,7 +42,7 @@ When you have resolved this problem run \"git rebase --continue\".
If you would prefer to skip this patch, instead run \"git rebase --skip\".
To restore the original branch and stop rebasing run \"git rebase --abort\".
"
-unset newbase
+unset onto
strategy=recursive
strategy_opts=
do_merge=
@@ -245,7 +245,7 @@ do
;;
--onto)
test 2 -le "$#" || usage
- newbase="$2"
+ onto="$2"
shift
;;
-M|-m|--m|--me|--mer|--merg|--merge)
@@ -425,7 +425,7 @@ then
unset root_flag
upstream_arg="$upstream_name"
else
- test -z "$newbase" && die "--root must be used with --onto"
+ test -z "$onto" && die "--root must be used with --onto"
unset upstream_name
unset upstream
root_flag="--root"
@@ -433,7 +433,7 @@ else
fi
# Make sure the branch to rebase onto is valid.
-onto_name=${newbase-"$upstream_name"}
+onto_name=${onto-"$upstream_name"}
case "$onto_name" in
*...*)
if left=${onto_name%...*} right=${onto_name#*...} &&
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 11/31] rebase -i: remove now unnecessary directory checks
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Remove directory checks from git-rebase--interactive.sh that are done in
git-rebase.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Squash with previous?
git-rebase--interactive.sh | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4d3dc63..21a9774 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -706,8 +706,6 @@ continue)
get_saved_options
comment_for_reflog continue
- test -d "$DOTEST" || die "No interactive rebase running"
-
# Sanity check
git rev-parse --verify HEAD >/dev/null ||
die "Cannot read HEAD"
@@ -749,7 +747,6 @@ abort)
comment_for_reflog abort
git rerere clear
- test -d "$DOTEST" || die "No interactive rebase running"
HEADNAME=$(cat "$DOTEST"/head-name)
HEAD=$(cat "$DOTEST"/head)
@@ -767,7 +764,6 @@ skip)
comment_for_reflog skip
git rerere clear
- test -d "$DOTEST" || die "No interactive rebase running"
output git reset --hard && do_rest
;;
@@ -780,8 +776,6 @@ fi
test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
test ! -z "$rebase_root" -a $# -le 1 || usage
-test -d "$DOTEST" &&
- die "Interactive rebase already started"
git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 12/31] rebase: reorder validation steps
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Reorder validation steps in preparation for the validation to be factored
out from git-rebase--interactive.sh into git-rebase.sh.
The main functional difference is that the pre-rebase hook will no longer
be run if the work tree is dirty.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 4 ++--
git-rebase.sh | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 21a9774..5a8f582 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -792,12 +792,12 @@ else
test -z "$onto" &&
die "You must specify --onto when using --root"
fi
+require_clean_work_tree "rebase" "Please commit or stash them."
+
run_pre_rebase_hook "$upstream_arg" "$@"
comment_for_reflog start
-require_clean_work_tree "rebase" "Please commit or stash them."
-
if test ! -z "$1"
then
output git checkout "$1" ||
diff --git a/git-rebase.sh b/git-rebase.sh
index e646b8f..26e4218 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -435,8 +435,6 @@ fi
test "$type" = interactive && run_interactive_rebase "$@"
-require_clean_work_tree "rebase" "Please commit or stash them."
-
if test -z "$rebase_root"
then
# The upstream head must be given. Make sure it is valid.
@@ -478,9 +476,6 @@ case "$onto_name" in
;;
esac
-# If a hook exists, give it a chance to interrupt
-run_pre_rebase_hook "$upstream_arg" "$@"
-
# If the branch to rebase is given, that is the branch we will rebase
# $branch_name -- branch being rebased, or HEAD (already detached)
# $orig_head -- commit object name of tip of the branch before rebasing
@@ -518,6 +513,8 @@ case "$#" in
esac
orig_head=$branch
+require_clean_work_tree "rebase" "Please commit or stash them."
+
# Now we are rebasing commits $upstream..$branch (or with --root,
# everything leading up to $branch) on top of $onto
@@ -539,6 +536,9 @@ then
fi
fi
+# If a hook exists, give it a chance to interrupt
+run_pre_rebase_hook "$upstream_arg" "$@"
+
# Detach HEAD and reset the tree
say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 10/31] rebase: factor out command line option processing
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Factor out the command line processing in git-rebase--interactive.sh
to git-rebase.sh. Store the options in variables in git-rebase.sh and
export them before calling git-rebase--interactive.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Since this removes the command line processing from
git-rebase--interactive.sh, it completely changes its command line
interface. Since it is not listed as even a plumbing command, I hope
this is fine.
git-rebase--interactive.sh | 224 ++++++++++++--------------------------------
git-rebase.sh | 60 ++++++++----
2 files changed, 102 insertions(+), 182 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 1af739a..4d3dc63 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -10,31 +10,7 @@
# The original idea comes from Eric W. Biederman, in
# http://article.gmane.org/gmane.comp.version-control.git/22407
-OPTIONS_KEEPDASHDASH=
-OPTIONS_SPEC="\
-git-rebase [-i] [options] [--] <upstream> [<branch>]
-git-rebase [-i] (--continue | --abort | --skip)
---
- Available options are
-v,verbose display a diffstat of what changed upstream
-onto= rebase onto given branch instead of upstream
-p,preserve-merges try to recreate merges instead of ignoring them
-s,strategy= use the given merge strategy
-no-ff cherry-pick all commits, even if unchanged
-m,merge always used (no-op)
-i,interactive always used (no-op)
- Actions:
-continue continue rebasing process
-abort abort rebasing process and restore original branch
-skip skip current patch and continue rebasing process
-no-verify override pre-rebase hook from stopping the operation
-verify allow pre-rebase hook to run
-root rebase all reachable commmits up to the root(s)
-autosquash move commits that begin with squash!/fixup! under -i
-"
-
. git-sh-setup
-require_work_tree
DOTEST="$GIT_DIR/rebase-merge"
@@ -105,16 +81,6 @@ AMEND="$DOTEST"/amend
REWRITTEN_LIST="$DOTEST"/rewritten-list
REWRITTEN_PENDING="$DOTEST"/rewritten-pending
-preserve_merges=
-strategy=
-onto=
-verbose=
-OK_TO_SKIP_PRE_REBASE=
-rebase_root=
-autosquash=
-test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
-force_rebase=
-
GIT_CHERRY_PICK_HELP="\
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' and run 'git rebase --continue'"
@@ -648,15 +614,6 @@ skip_unnecessary_picks () {
die "Could not skip unnecessary pick commands"
}
-# check if no other options are set
-is_standalone () {
- test $# -eq 2 -a "$2" = '--' &&
- test -z "$onto" &&
- test -z "$preserve_merges" &&
- test -z "$strategy" &&
- test -z "$verbose"
-}
-
get_saved_options () {
test -d "$REWRITTEN" && preserve_merges=t
test -f "$DOTEST"/strategy && strategy="$(cat "$DOTEST"/strategy)"
@@ -744,134 +701,77 @@ parse_onto () {
git rev-parse --verify "$1^0"
}
-while test $# != 0
-do
- case "$1" in
- --no-verify)
- OK_TO_SKIP_PRE_REBASE=yes
- ;;
- --verify)
- OK_TO_SKIP_PRE_REBASE=
- ;;
- --continue)
- is_standalone "$@" || usage
- get_saved_options
- comment_for_reflog continue
-
- test -d "$DOTEST" || die "No interactive rebase running"
-
- # Sanity check
- git rev-parse --verify HEAD >/dev/null ||
- die "Cannot read HEAD"
- git update-index --ignore-submodules --refresh &&
- git diff-files --quiet --ignore-submodules ||
- die "Working tree is dirty"
-
- # do we have anything to commit?
- if git diff-index --cached --quiet --ignore-submodules HEAD --
+case "$action" in
+continue)
+ get_saved_options
+ comment_for_reflog continue
+
+ test -d "$DOTEST" || die "No interactive rebase running"
+
+ # Sanity check
+ git rev-parse --verify HEAD >/dev/null ||
+ die "Cannot read HEAD"
+ git update-index --ignore-submodules --refresh &&
+ git diff-files --quiet --ignore-submodules ||
+ die "Working tree is dirty"
+
+ # do we have anything to commit?
+ if git diff-index --cached --quiet --ignore-submodules HEAD --
+ then
+ : Nothing to commit -- skip this
+ else
+ . "$AUTHOR_SCRIPT" ||
+ die "Cannot find the author identity"
+ amend=
+ if test -f "$AMEND"
then
- : Nothing to commit -- skip this
- else
- . "$AUTHOR_SCRIPT" ||
- die "Cannot find the author identity"
- amend=
- if test -f "$AMEND"
- then
- amend=$(git rev-parse --verify HEAD)
- test "$amend" = $(cat "$AMEND") ||
- die "\
+ amend=$(git rev-parse --verify HEAD)
+ test "$amend" = $(cat "$AMEND") ||
+ die "\
You have uncommitted changes in your working tree. Please, commit them
first and then run 'git rebase --continue' again."
- git reset --soft HEAD^ ||
- die "Cannot rewind the HEAD"
- fi
- do_with_author git commit --no-verify -F "$MSG" -e || {
- test -n "$amend" && git reset --soft $amend
- die "Could not commit staged changes."
- }
+ git reset --soft HEAD^ ||
+ die "Cannot rewind the HEAD"
fi
+ do_with_author git commit --no-verify -F "$MSG" -e || {
+ test -n "$amend" && git reset --soft $amend
+ die "Could not commit staged changes."
+ }
+ fi
- record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
+ record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
- require_clean_work_tree "rebase"
- do_rest
- ;;
- --abort)
- is_standalone "$@" || usage
- get_saved_options
- comment_for_reflog abort
-
- git rerere clear
- test -d "$DOTEST" || die "No interactive rebase running"
-
- HEADNAME=$(cat "$DOTEST"/head-name)
- HEAD=$(cat "$DOTEST"/head)
- case $HEADNAME in
- refs/*)
- git symbolic-ref HEAD $HEADNAME
- ;;
- esac &&
- output git reset --hard $HEAD &&
- rm -rf "$DOTEST"
- exit
- ;;
- --skip)
- is_standalone "$@" || usage
- get_saved_options
- comment_for_reflog skip
+ require_clean_work_tree "rebase"
+ do_rest
+ ;;
+abort)
+ get_saved_options
+ comment_for_reflog abort
- git rerere clear
- test -d "$DOTEST" || die "No interactive rebase running"
+ git rerere clear
+ test -d "$DOTEST" || die "No interactive rebase running"
- output git reset --hard && do_rest
- ;;
- -s)
- case "$#,$1" in
- *,*=*)
- strategy=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
- 1,*)
- usage ;;
- *)
- strategy="$2"
- shift ;;
- esac
- ;;
- -m)
- # we use merge anyway
- ;;
- -v)
- verbose=t
- ;;
- -p)
- preserve_merges=t
- ;;
- -i)
- # yeah, we know
- ;;
- --no-ff)
- force_rebase=t
- ;;
- --root)
- rebase_root=t
- ;;
- --autosquash)
- autosquash=t
- ;;
- --no-autosquash)
- autosquash=
- ;;
- --onto)
- test 2 -le "$#" || usage
- onto="$2"
- shift
- ;;
- --)
- shift
- break
+ HEADNAME=$(cat "$DOTEST"/head-name)
+ HEAD=$(cat "$DOTEST"/head)
+ case $HEADNAME in
+ refs/*)
+ git symbolic-ref HEAD $HEADNAME
;;
- esac
- shift
-done
+ esac &&
+ output git reset --hard $HEAD &&
+ rm -rf "$DOTEST"
+ exit
+ ;;
+skip)
+ get_saved_options
+ comment_for_reflog skip
+
+ git rerere clear
+ test -d "$DOTEST" || die "No interactive rebase running"
+
+ output git reset --hard && do_rest
+ ;;
+esac
if test -n "$onto"
then
diff --git a/git-rebase.sh b/git-rebase.sh
index 21366ba..e646b8f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -64,6 +64,9 @@ type=
state_dir=
# One of {'', continue, skip, abort}, as parsed from command line
action=
+preserve_merges=
+autosquash=
+test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
read_state () {
if test "$type" = merge
@@ -176,27 +179,14 @@ finish_rb_merge () {
say All done.
}
-is_interactive () {
- while test $# != 0
- do
- case "$1" in
- -i|--interactive)
- interactive_rebase=explicit
- break
- ;;
- -p|--preserve-merges)
- interactive_rebase=implied
- ;;
- esac
- shift
- done
-
+run_interactive_rebase () {
if [ "$interactive_rebase" = implied ]; then
GIT_EDITOR=:
export GIT_EDITOR
fi
-
- test -n "$interactive_rebase" || test -f "$merge_dir"/interactive
+ export onto autosquash strategy strategy_opts verbose rebase_root \
+ force_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE
+ exec git-rebase--interactive "$@"
}
run_pre_rebase_hook () {
@@ -211,8 +201,6 @@ run_pre_rebase_hook () {
test -f "$apply_dir"/applying &&
die 'It looks like git-am is in progress. Cannot rebase.'
-is_interactive "$@" && exec git-rebase--interactive "$@"
-
if test -d "$apply_dir"
then
type=am
@@ -249,6 +237,19 @@ do
onto="$2"
shift
;;
+ -i|--interactive)
+ interactive_rebase=explicit
+ ;;
+ -p|--preserve-merges)
+ preserve_merges=t
+ test -z "$interactive_rebase" && interactive_rebase=implied
+ ;;
+ --autosquash)
+ autosquash=t
+ ;;
+ --no-autosquash)
+ autosquash=
+ ;;
-M|-m|--m|--me|--mer|--merg|--merge)
do_merge=t
;;
@@ -339,7 +340,11 @@ do
done
test $# -gt 2 && usage
-test -n "$action" && test -z "$in_progress" && die "No rebase in progress?"
+if test -n "$action"
+then
+ test -z "$in_progress" && die "No rebase in progress?"
+ test "$type" = interactive && run_interactive_rebase
+fi
case "$action" in
continue)
@@ -415,6 +420,21 @@ fi
test $# -eq 0 && test -z "$rebase_root" && usage
+if test -n "$interactive_rebase"
+then
+ type=interactive
+ state_dir="$merge_dir"
+elif test -n "$do_merge"
+then
+ type=merge
+ state_dir="$merge_dir"
+else
+ type=am
+ state_dir="$apply_dir"
+fi
+
+test "$type" = interactive && run_interactive_rebase "$@"
+
require_clean_work_tree "rebase" "Please commit or stash them."
if test -z "$rebase_root"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 15/31] rebase: factor out call to pre-rebase hook
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Remove the call to the pre-rebase hook from
git-rebase--interactive.sh and rely on the call in
git-rebase.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 14 --------------
git-rebase.sh | 15 ++++++++-------
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index edde1e5..0beeb8b 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -109,18 +109,6 @@ commit_message () {
git cat-file commit "$1" | sed "1,/^$/d"
}
-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
-}
-
-
ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
comment_for_reflog () {
@@ -753,8 +741,6 @@ esac
git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first"
-run_pre_rebase_hook "$upstream_arg" "$@"
-
comment_for_reflog start
if test ! -z "$switch_to"
diff --git a/git-rebase.sh b/git-rebase.sh
index e1e5263..229e8d2 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -185,9 +185,8 @@ run_interactive_rebase () {
export GIT_EDITOR
fi
export onto autosquash strategy strategy_opts verbose rebase_root \
- force_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE upstream \
- upstream_arg switch_to head_name
- exec git-rebase--interactive "$@"
+ force_rebase action preserve_merges upstream switch_to head_name
+ exec git-rebase--interactive
}
run_pre_rebase_hook () {
@@ -515,15 +514,15 @@ orig_head=$branch
require_clean_work_tree "rebase" "Please commit or stash them."
-test "$type" = interactive && run_interactive_rebase "$@"
-
# Now we are rebasing commits $upstream..$branch (or with --root,
# everything leading up to $branch) on top of $onto
# Check if we are already based on $onto with linear history,
-# but this should be done only when upstream and onto are the same.
+# but this should be done only when upstream and onto are the same
+# and if this is not an interactive rebase.
mb=$(git merge-base "$onto" "$branch")
-if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
+if test "$type" != interactive && test "$upstream" = "$onto" &&
+ test "$mb" = "$onto" &&
# linear history?
! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
then
@@ -541,6 +540,8 @@ fi
# If a hook exists, give it a chance to interrupt
run_pre_rebase_hook "$upstream_arg" "$@"
+test "$type" = interactive && run_interactive_rebase
+
# Detach HEAD and reset the tree
say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 14/31] rebase: factor out clean work tree check
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Remove the check for clean work tree from git-rebase--interactive.sh and
rely on the check in git-rebase.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 2 --
git-rebase.sh | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c055fc4..edde1e5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -753,8 +753,6 @@ esac
git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first"
-require_clean_work_tree "rebase" "Please commit or stash them."
-
run_pre_rebase_hook "$upstream_arg" "$@"
comment_for_reflog start
diff --git a/git-rebase.sh b/git-rebase.sh
index d8c7c8d..e1e5263 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -513,10 +513,10 @@ case "$#" in
esac
orig_head=$branch
-test "$type" = interactive && run_interactive_rebase "$@"
-
require_clean_work_tree "rebase" "Please commit or stash them."
+test "$type" = interactive && run_interactive_rebase "$@"
+
# Now we are rebasing commits $upstream..$branch (or with --root,
# everything leading up to $branch) on top of $onto
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 16/31] rebase -i: support --stat
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Move up the code that displays the diffstat if '--stat' is passed, so
that it will be executed before calling git-rebase--interactive.sh.
A side effect is that the diffstat is now displayed before "First,
rewinding head to replay your work on top of it...".
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 229e8d2..0fc580a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -540,13 +540,6 @@ fi
# If a hook exists, give it a chance to interrupt
run_pre_rebase_hook "$upstream_arg" "$@"
-test "$type" = interactive && run_interactive_rebase
-
-# Detach HEAD and reset the tree
-say "First, rewinding head to replay your work on top of it..."
-git checkout -q "$onto^0" || die "could not detach HEAD"
-git update-ref ORIG_HEAD $branch
-
if test -n "$diffstat"
then
if test -n "$verbose"
@@ -557,6 +550,13 @@ then
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
fi
+test "$type" = interactive && run_interactive_rebase
+
+# Detach HEAD and reset the tree
+say "First, rewinding head to replay your work on top of it..."
+git checkout -q "$onto^0" || die "could not detach HEAD"
+git update-ref ORIG_HEAD $branch
+
# If the $onto is a proper descendant of the tip of the branch, then
# we just fast-forwarded.
if test "$mb" = "$branch"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 19/31] rebase: extract am code to new source file
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Extract the code for am-based rebase to git-rebase--am.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
.gitignore | 1 +
Makefile | 1 +
git-rebase--am.sh | 34 ++++++++++++++++++++++++++++++++++
git-rebase.sh | 33 +++------------------------------
4 files changed, 39 insertions(+), 30 deletions(-)
create mode 100644 git-rebase--am.sh
diff --git a/.gitignore b/.gitignore
index 40506ff..ef04058 100644
--- a/.gitignore
+++ b/.gitignore
@@ -102,6 +102,7 @@
/git-quiltimport
/git-read-tree
/git-rebase
+/git-rebase--am
/git-rebase--interactive
/git-rebase--merge
/git-receive-pack
diff --git a/Makefile b/Makefile
index ffc3a5d..459df3a 100644
--- a/Makefile
+++ b/Makefile
@@ -369,6 +369,7 @@ SCRIPT_SH += git-merge-resolve.sh
SCRIPT_SH += git-mergetool.sh
SCRIPT_SH += git-pull.sh
SCRIPT_SH += git-quiltimport.sh
+SCRIPT_SH += git-rebase--am.sh
SCRIPT_SH += git-rebase--interactive.sh
SCRIPT_SH += git-rebase--merge.sh
SCRIPT_SH += git-rebase.sh
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
new file mode 100644
index 0000000..9316761
--- /dev/null
+++ b/git-rebase--am.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Junio C Hamano.
+#
+
+. git-sh-setup
+
+case "$action" in
+continue)
+ git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
+ move_to_original_branch
+ exit
+ ;;
+skip)
+ git am --skip -3 --resolvemsg="$RESOLVEMSG" &&
+ move_to_original_branch
+ exit
+ ;;
+esac
+
+test -n "$rebase_root" && root_flag=--root
+
+git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+ --src-prefix=a/ --dst-prefix=b/ \
+ --no-renames $root_flag "$revisions" |
+git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
+move_to_original_branch
+ret=$?
+test 0 != $ret -a -d "$state_dir" &&
+ echo $head_name > "$state_dir/head-name" &&
+ echo $onto > "$state_dir/onto" &&
+ echo $orig_head > "$state_dir/orig-head" &&
+ echo "$GIT_QUIET" > "$state_dir/quiet"
+exit $ret
diff --git a/git-rebase.sh b/git-rebase.sh
index ee586e8..615d9dd 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -94,9 +94,9 @@ run_specific_rebase () {
export onto autosquash strategy strategy_opts verbose rebase_root \
force_rebase action preserve_merges upstream switch_to head_name \
state_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \
- allow_rerere_autoupdate
+ allow_rerere_autoupdate git_am_opt
export -f move_to_original_branch
- test "$type" != am && exec git-rebase--$type
+ exec git-rebase--$type
}
run_pre_rebase_hook () {
@@ -266,17 +266,11 @@ continue)
}
read_basic_state
run_specific_rebase
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
- move_to_original_branch
- exit
;;
skip)
git reset --hard HEAD || exit $?
read_basic_state
run_specific_rebase
- git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
- move_to_original_branch
- exit
;;
abort)
git rerere clear
@@ -329,14 +323,12 @@ then
shift
upstream=`git rev-parse --verify "${upstream_name}^0"` ||
die "invalid upstream $upstream_name"
- unset root_flag
upstream_arg="$upstream_name"
else
test -z "$onto" && die "You must specify --onto when using --root"
unset upstream_name
unset upstream
- root_flag="--root"
- upstream_arg="$root_flag"
+ upstream_arg=--root
fi
# Make sure the branch to rebase onto is valid.
@@ -461,23 +453,4 @@ else
revisions="$upstream..$orig_head"
fi
-if test -z "$do_merge"
-then
- git format-patch -k --stdout --full-index --ignore-if-in-upstream \
- --src-prefix=a/ --dst-prefix=b/ \
- --no-renames $root_flag "$revisions" |
- git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
- move_to_original_branch
- ret=$?
- test 0 != $ret -a -d "$apply_dir" &&
- echo $head_name > "$apply_dir/head-name" &&
- echo $onto > "$apply_dir/onto" &&
- echo $orig_head > "$apply_dir/orig-head" &&
- echo "$GIT_QUIET" > "$apply_dir/quiet"
- exit $ret
-fi
-
-# start doing a rebase with git-merge
-# this is rename-aware if the recursive (default) strategy is used
-
run_specific_rebase
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 20/31] rebase: show consistent conflict resolution hint
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
When rebase stops due to conflict, interactive rebase currently
displays a different hint to the user than non-interactive rebase
does. Use the same message for both types of rebase.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Should we include the "mark the corrected paths with 'git add
<paths>'" part?
git-rebase--interactive.sh | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 0beeb8b..e848ea2 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -81,9 +81,7 @@ AMEND="$DOTEST"/amend
REWRITTEN_LIST="$DOTEST"/rewritten-list
REWRITTEN_PENDING="$DOTEST"/rewritten-pending
-GIT_CHERRY_PICK_HELP="\
-hint: after resolving the conflicts, mark the corrected paths
-hint: with 'git add <paths>' and run 'git rebase --continue'"
+GIT_CHERRY_PICK_HELP="$RESOLVEMSG"
export GIT_CHERRY_PICK_HELP
warn () {
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 18/31] rebase: extract merge code to new source file
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Extract the code for merge-based rebase to git-rebase--merge.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
What copyright year? Most of the code is just extracted from
git-rebase.sh, which has copyright year 2005. Does that matter?
Would read_initial_state be a better name than read_basic_state?
.gitignore | 1 +
Makefile | 1 +
git-rebase--merge.sh | 154 ++++++++++++++++++++++++++++++++++++++++++++++
git-rebase.sh | 167 +++++---------------------------------------------
4 files changed, 171 insertions(+), 152 deletions(-)
create mode 100644 git-rebase--merge.sh
diff --git a/.gitignore b/.gitignore
index 87b833c..40506ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,6 +103,7 @@
/git-read-tree
/git-rebase
/git-rebase--interactive
+/git-rebase--merge
/git-receive-pack
/git-reflog
/git-relink
diff --git a/Makefile b/Makefile
index ff35154..ffc3a5d 100644
--- a/Makefile
+++ b/Makefile
@@ -370,6 +370,7 @@ SCRIPT_SH += git-mergetool.sh
SCRIPT_SH += git-pull.sh
SCRIPT_SH += git-quiltimport.sh
SCRIPT_SH += git-rebase--interactive.sh
+SCRIPT_SH += git-rebase--merge.sh
SCRIPT_SH += git-rebase.sh
SCRIPT_SH += git-repack.sh
SCRIPT_SH += git-request-pull.sh
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
new file mode 100644
index 0000000..8cfdcf1
--- /dev/null
+++ b/git-rebase--merge.sh
@@ -0,0 +1,154 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Junio C Hamano.
+#
+
+. git-sh-setup
+
+prec=4
+
+read_state () {
+ onto_name=$(cat "$state_dir"/onto_name) &&
+ end=$(cat "$state_dir"/end) &&
+ msgnum=$(cat "$state_dir"/msgnum)
+}
+
+continue_merge () {
+ test -d "$state_dir" || die "$state_dir directory does not exist"
+
+ unmerged=$(git ls-files -u)
+ if test -n "$unmerged"
+ then
+ echo "You still have unmerged paths in your index"
+ echo "did you forget to use git add?"
+ die "$RESOLVEMSG"
+ fi
+
+ cmt=`cat "$state_dir/current"`
+ if ! git diff-index --quiet --ignore-submodules HEAD --
+ then
+ if ! git commit --no-verify -C "$cmt"
+ then
+ echo "Commit failed, please do not call \"git commit\""
+ echo "directly, but instead do one of the following: "
+ die "$RESOLVEMSG"
+ fi
+ if test -z "$GIT_QUIET"
+ then
+ printf "Committed: %0${prec}d " $msgnum
+ fi
+ echo "$cmt $(git rev-parse HEAD^0)" >> "$state_dir/rewritten"
+ else
+ if test -z "$GIT_QUIET"
+ then
+ printf "Already applied: %0${prec}d " $msgnum
+ fi
+ fi
+ test -z "$GIT_QUIET" &&
+ GIT_PAGER='' git log --format=%s -1 "$cmt"
+
+ # onto the next patch:
+ msgnum=$(($msgnum + 1))
+ echo "$msgnum" >"$state_dir/msgnum"
+}
+
+call_merge () {
+ cmt="$(cat "$state_dir/cmt.$1")"
+ echo "$cmt" > "$state_dir/current"
+ hd=$(git rev-parse --verify HEAD)
+ cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
+ msgnum=$(cat "$state_dir/msgnum")
+ eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
+ eval GITHEAD_$hd='$onto_name'
+ export GITHEAD_$cmt GITHEAD_$hd
+ if test -n "$GIT_QUIET"
+ then
+ GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
+ fi
+ test -z "$strategy" && strategy=recursive
+ eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
+ rv=$?
+ case "$rv" in
+ 0)
+ unset GITHEAD_$cmt GITHEAD_$hd
+ return
+ ;;
+ 1)
+ git rerere $allow_rerere_autoupdate
+ die "$RESOLVEMSG"
+ ;;
+ 2)
+ echo "Strategy: $rv $strategy failed, try another" 1>&2
+ die "$RESOLVEMSG"
+ ;;
+ *)
+ die "Unknown exit code ($rv) from command:" \
+ "git-merge-$strategy $cmt^ -- HEAD $cmt"
+ ;;
+ esac
+}
+
+finish_rb_merge () {
+ move_to_original_branch
+ git notes copy --for-rewrite=rebase < "$state_dir"/rewritten
+ if test -x "$GIT_DIR"/hooks/post-rewrite &&
+ test -s "$state_dir"/rewritten; then
+ "$GIT_DIR"/hooks/post-rewrite rebase < "$state_dir"/rewritten
+ fi
+ rm -r "$state_dir"
+ say All done.
+}
+
+case "$action" in
+continue)
+ read_state
+ continue_merge
+ while test "$msgnum" -le "$end"
+ do
+ call_merge "$msgnum"
+ continue_merge
+ done
+ finish_rb_merge
+ exit
+ ;;
+skip)
+ read_state
+ git rerere clear
+ msgnum=$(($msgnum + 1))
+ while test "$msgnum" -le "$end"
+ do
+ call_merge "$msgnum"
+ continue_merge
+ done
+ finish_rb_merge
+ exit
+ ;;
+esac
+
+mkdir -p "$state_dir"
+echo "$onto_name" > "$state_dir/onto_name"
+echo "$head_name" > "$state_dir/head-name"
+echo "$onto" > "$state_dir/onto"
+echo "$orig_head" > "$state_dir/orig-head"
+echo "$GIT_QUIET" > "$state_dir/quiet"
+
+msgnum=0
+for cmt in `git rev-list --reverse --no-merges "$revisions"`
+do
+ msgnum=$(($msgnum + 1))
+ echo "$cmt" > "$state_dir/cmt.$msgnum"
+done
+
+echo 1 >"$state_dir/msgnum"
+echo $msgnum >"$state_dir/end"
+
+end=$msgnum
+msgnum=1
+
+while test "$msgnum" -le "$end"
+do
+ call_merge "$msgnum"
+ continue_merge
+done
+
+finish_rb_merge
diff --git a/git-rebase.sh b/git-rebase.sh
index eae2f7a..ee586e8 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -48,7 +48,6 @@ strategy_opts=
do_merge=
merge_dir="$GIT_DIR"/rebase-merge
apply_dir="$GIT_DIR"/rebase-apply
-prec=4
verbose=
diffstat=
test "$(git config --bool rebase.stat)" = true && diffstat=t
@@ -68,94 +67,13 @@ preserve_merges=
autosquash=
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
-read_state () {
- if test "$type" = merge
- then
- onto_name=$(cat "$state_dir"/onto_name) &&
- end=$(cat "$state_dir"/end) &&
- msgnum=$(cat "$state_dir"/msgnum)
- fi &&
+read_basic_state () {
head_name=$(cat "$state_dir"/head-name) &&
onto=$(cat "$state_dir"/onto) &&
orig_head=$(cat "$state_dir"/orig-head) &&
GIT_QUIET=$(cat "$state_dir"/quiet)
}
-continue_merge () {
- test -d "$merge_dir" || die "$merge_dir directory does not exist"
-
- unmerged=$(git ls-files -u)
- if test -n "$unmerged"
- then
- echo "You still have unmerged paths in your index"
- echo "did you forget to use git add?"
- die "$RESOLVEMSG"
- fi
-
- cmt=`cat "$merge_dir/current"`
- if ! git diff-index --quiet --ignore-submodules HEAD --
- then
- if ! git commit --no-verify -C "$cmt"
- then
- echo "Commit failed, please do not call \"git commit\""
- echo "directly, but instead do one of the following: "
- die "$RESOLVEMSG"
- fi
- if test -z "$GIT_QUIET"
- then
- printf "Committed: %0${prec}d " $msgnum
- fi
- echo "$cmt $(git rev-parse HEAD^0)" >> "$merge_dir/rewritten"
- else
- if test -z "$GIT_QUIET"
- then
- printf "Already applied: %0${prec}d " $msgnum
- fi
- fi
- test -z "$GIT_QUIET" &&
- GIT_PAGER='' git log --format=%s -1 "$cmt"
-
- # onto the next patch:
- msgnum=$(($msgnum + 1))
- echo "$msgnum" >"$merge_dir/msgnum"
-}
-
-call_merge () {
- cmt="$(cat "$merge_dir/cmt.$1")"
- echo "$cmt" > "$merge_dir/current"
- hd=$(git rev-parse --verify HEAD)
- cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
- msgnum=$(cat "$merge_dir/msgnum")
- eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
- eval GITHEAD_$hd='$onto_name'
- export GITHEAD_$cmt GITHEAD_$hd
- if test -n "$GIT_QUIET"
- then
- GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
- fi
- test -z "$strategy" && strategy=recursive
- eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
- rv=$?
- case "$rv" in
- 0)
- unset GITHEAD_$cmt GITHEAD_$hd
- return
- ;;
- 1)
- git rerere $allow_rerere_autoupdate
- die "$RESOLVEMSG"
- ;;
- 2)
- echo "Strategy: $rv $strategy failed, try another" 1>&2
- die "$RESOLVEMSG"
- ;;
- *)
- die "Unknown exit code ($rv) from command:" \
- "git-merge-$strategy $cmt^ -- HEAD $cmt"
- ;;
- esac
-}
-
move_to_original_branch () {
case "$head_name" in
refs/*)
@@ -168,25 +86,17 @@ move_to_original_branch () {
esac
}
-finish_rb_merge () {
- move_to_original_branch
- git notes copy --for-rewrite=rebase < "$merge_dir"/rewritten
- if test -x "$GIT_DIR"/hooks/post-rewrite &&
- test -s "$merge_dir"/rewritten; then
- "$GIT_DIR"/hooks/post-rewrite rebase < "$merge_dir"/rewritten
- fi
- rm -r "$merge_dir"
- say All done.
-}
-
-run_interactive_rebase () {
+run_specific_rebase () {
if [ "$interactive_rebase" = implied ]; then
GIT_EDITOR=:
export GIT_EDITOR
fi
export onto autosquash strategy strategy_opts verbose rebase_root \
- force_rebase action preserve_merges upstream switch_to head_name
- exec git-rebase--interactive
+ force_rebase action preserve_merges upstream switch_to head_name \
+ state_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \
+ allow_rerere_autoupdate
+ export -f move_to_original_branch
+ test "$type" != am && exec git-rebase--$type
}
run_pre_rebase_hook () {
@@ -343,7 +253,7 @@ test $# -gt 2 && usage
if test -n "$action"
then
test -z "$in_progress" && die "No rebase in progress?"
- test "$type" = interactive && run_interactive_rebase
+ test "$type" = interactive && run_specific_rebase
fi
case "$action" in
@@ -354,44 +264,23 @@ continue)
echo "mark them as resolved using git add"
exit 1
}
- read_state
- if test -d "$merge_dir"
- then
- continue_merge
- while test "$msgnum" -le "$end"
- do
- call_merge "$msgnum"
- continue_merge
- done
- finish_rb_merge
- exit
- fi
+ read_basic_state
+ run_specific_rebase
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
skip)
git reset --hard HEAD || exit $?
- read_state
- if test -d "$merge_dir"
- then
- git rerere clear
- msgnum=$(($msgnum + 1))
- while test "$msgnum" -le "$end"
- do
- call_merge "$msgnum"
- continue_merge
- done
- finish_rb_merge
- exit
- fi
+ read_basic_state
+ run_specific_rebase
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
abort)
git rerere clear
- read_state
+ read_basic_state
case "$head_name" in
refs/*)
git symbolic-ref HEAD $head_name ||
@@ -549,7 +438,7 @@ then
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
fi
-test "$type" = interactive && run_interactive_rebase
+test "$type" = interactive && run_specific_rebase
# Detach HEAD and reset the tree
say "First, rewinding head to replay your work on top of it..."
@@ -591,30 +480,4 @@ fi
# start doing a rebase with git-merge
# this is rename-aware if the recursive (default) strategy is used
-mkdir -p "$merge_dir"
-echo "$onto_name" > "$merge_dir/onto_name"
-echo "$head_name" > "$merge_dir/head-name"
-echo "$onto" > "$merge_dir/onto"
-echo "$orig_head" > "$merge_dir/orig-head"
-echo "$GIT_QUIET" > "$merge_dir/quiet"
-
-msgnum=0
-for cmt in `git rev-list --reverse --no-merges "$revisions"`
-do
- msgnum=$(($msgnum + 1))
- echo "$cmt" > "$merge_dir/cmt.$msgnum"
-done
-
-echo 1 >"$merge_dir/msgnum"
-echo $msgnum >"$merge_dir/end"
-
-end=$msgnum
-msgnum=1
-
-while test "$msgnum" -le "$end"
-do
- call_merge "$msgnum"
- continue_merge
-done
-
-finish_rb_merge
+run_specific_rebase
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 23/31] rebase: factor out sub command handling
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Factor out the common parts of the handling of the sub commands
'--continue', '--skip' and '--abort'. The '--abort' handling can
handled completely in git-rebase.sh.
After this refactoring, the calls to git-rebase--am.sh,
git-rebase--merge.sh and git-rebase--interactive.sh will be better
aligned. There will only be one call to interactive rebase that will
shortcut the very last part of git-rebase.sh.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 34 +++-------------------------------
git-rebase.sh | 17 +++++++++++++++--
2 files changed, 18 insertions(+), 33 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index acd0258..1079994 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -509,9 +509,7 @@ do_next () {
test -s "$TODO" && return
comment_for_reflog finish &&
- head_name=$(cat "$state_dir"/head-name) &&
- orig_head=$(cat "$state_dir"/head) &&
- SHORTONTO=$(git rev-parse --short $(cat "$state_dir"/onto)) &&
+ SHORTONTO=$(git rev-parse --short $onto) &&
NEWHEAD=$(git rev-parse HEAD) &&
case $head_name in
refs/*)
@@ -521,7 +519,7 @@ do_next () {
;;
esac && {
test ! -f "$state_dir"/verbose ||
- git diff-tree --stat $(cat "$state_dir"/head)..HEAD
+ git diff-tree --stat $orig_head..HEAD
} &&
{
test -s "$REWRITTEN_LIST" &&
@@ -655,14 +653,6 @@ rearrange_squash () {
case "$action" in
continue)
get_saved_options
- comment_for_reflog continue
-
- # Sanity check
- git rev-parse --verify HEAD >/dev/null ||
- die "Cannot read HEAD"
- git update-index --ignore-submodules --refresh &&
- git diff-files --quiet --ignore-submodules ||
- die "Working tree is dirty"
# do we have anything to commit?
if git diff-index --cached --quiet --ignore-submodules HEAD --
@@ -693,30 +683,12 @@ first and then run 'git rebase --continue' again."
require_clean_work_tree "rebase"
do_rest
;;
-abort)
- get_saved_options
- comment_for_reflog abort
-
- git rerere clear
-
- head_name=$(cat "$state_dir"/head-name)
- orig_head=$(cat "$state_dir"/head)
- case $head_name in
- refs/*)
- git symbolic-ref HEAD $head_name
- ;;
- esac &&
- output git reset --hard $orig_head &&
- rm -rf "$state_dir"
- exit
- ;;
skip)
get_saved_options
- comment_for_reflog skip
git rerere clear
- output git reset --hard && do_rest
+ do_rest
;;
esac
diff --git a/git-rebase.sh b/git-rebase.sh
index 0322f27..7e2e978 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -70,7 +70,12 @@ test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
read_basic_state () {
head_name=$(cat "$state_dir"/head-name) &&
onto=$(cat "$state_dir"/onto) &&
- orig_head=$(cat "$state_dir"/orig-head) &&
+ if test "$type" = interactive
+ then
+ orig_head=$(cat "$state_dir"/head)
+ else
+ orig_head=$(cat "$state_dir"/orig-head)
+ fi &&
GIT_QUIET=$(cat "$state_dir"/quiet)
}
@@ -267,11 +272,19 @@ test $# -gt 2 && usage
if test -n "$action"
then
test -z "$in_progress" && die "No rebase in progress?"
- test "$type" = interactive && run_specific_rebase
+ # Only interactive rebase uses detailed reflog messages
+ if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
+ then
+ GIT_REFLOG_ACTION="rebase -i ($action)"
+ export GIT_REFLOG_ACTION
+ fi
fi
case "$action" in
continue)
+ # Sanity check
+ git rev-parse --verify HEAD >/dev/null ||
+ die "Cannot read HEAD"
git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules || {
echo "You must edit all merge conflicts and then"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 22/31] rebase: make -v a tiny bit more verbose
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
To make it possible to later remove the handling of --abort from
git-rebase--interactive.sh, align the implementation in git-rebase.sh
with the former by making it a bit more verbose.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
What do we really want to print when -v is passed? Interactive rebase
is currently quite a bit more verbose than non-interactive rebase.
git-rebase--interactive.sh | 14 --------------
git-rebase.sh | 20 +++++++++++++++++---
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index eace4e5..acd0258 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -86,20 +86,6 @@ warn () {
printf '%s\n' "$*" >&2
}
-output () {
- case "$verbose" in
- '')
- output=$("$@" 2>&1 )
- status=$?
- test $status != 0 && printf "%s\n" "$output"
- return $status
- ;;
- *)
- "$@"
- ;;
- esac
-}
-
# Output the commit message for the specified commit.
commit_message () {
git cat-file commit "$1" | sed "1,/^$/d"
diff --git a/git-rebase.sh b/git-rebase.sh
index 615d9dd..0322f27 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -74,6 +74,20 @@ read_basic_state () {
GIT_QUIET=$(cat "$state_dir"/quiet)
}
+output () {
+ case "$verbose" in
+ '')
+ output=$("$@" 2>&1 )
+ status=$?
+ test $status != 0 && printf "%s\n" "$output"
+ return $status
+ ;;
+ *)
+ "$@"
+ ;;
+ esac
+}
+
move_to_original_branch () {
case "$head_name" in
refs/*)
@@ -95,7 +109,7 @@ run_specific_rebase () {
force_rebase action preserve_merges upstream switch_to head_name \
state_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \
allow_rerere_autoupdate git_am_opt
- export -f move_to_original_branch
+ export -f move_to_original_branch output
exec git-rebase--$type
}
@@ -268,7 +282,7 @@ continue)
run_specific_rebase
;;
skip)
- git reset --hard HEAD || exit $?
+ output git reset --hard HEAD || exit $?
read_basic_state
run_specific_rebase
;;
@@ -281,7 +295,7 @@ abort)
die "Could not move back to $head_name"
;;
esac
- git reset --hard $orig_head
+ output git reset --hard $orig_head
rm -r "$state_dir"
exit
;;
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 17/31] rebase: remove $branch as synonym for $orig_head
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
The variables $branch and $orig_head were used as synonyms. To avoid
confusion, remove $branch. The name 'orig_head' seems more suitable,
since that is the name used when the variable is persisted.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 0fc580a..eae2f7a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -487,10 +487,10 @@ case "$#" in
switch_to="$1"
if git show-ref --verify --quiet -- "refs/heads/$1" &&
- branch=$(git rev-parse -q --verify "refs/heads/$1")
+ orig_head=$(git rev-parse -q --verify "refs/heads/$1")
then
head_name="refs/heads/$1"
- elif branch=$(git rev-parse -q --verify "$1")
+ elif orig_head=$(git rev-parse -q --verify "$1")
then
head_name="detached HEAD"
else
@@ -507,24 +507,23 @@ case "$#" in
head_name="detached HEAD"
branch_name=HEAD ;# detached
fi
- branch=$(git rev-parse --verify "${branch_name}^0") || exit
+ orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
;;
esac
-orig_head=$branch
require_clean_work_tree "rebase" "Please commit or stash them."
-# Now we are rebasing commits $upstream..$branch (or with --root,
-# everything leading up to $branch) on top of $onto
+# Now we are rebasing commits $upstream..$orig_head (or with --root,
+# everything leading up to $orig_head) on top of $onto
# Check if we are already based on $onto with linear history,
# but this should be done only when upstream and onto are the same
# and if this is not an interactive rebase.
-mb=$(git merge-base "$onto" "$branch")
+mb=$(git merge-base "$onto" "$orig_head")
if test "$type" != interactive && test "$upstream" = "$onto" &&
test "$mb" = "$onto" &&
# linear history?
- ! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
+ ! (git rev-list --parents "$onto".."$orig_head" | sane_grep " .* ") > /dev/null
then
if test -z "$force_rebase"
then
@@ -555,11 +554,11 @@ test "$type" = interactive && run_interactive_rebase
# Detach HEAD and reset the tree
say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
-git update-ref ORIG_HEAD $branch
+git update-ref ORIG_HEAD $orig_head
# If the $onto is a proper descendant of the tip of the branch, then
# we just fast-forwarded.
-if test "$mb" = "$branch"
+if test "$mb" = "$orig_head"
then
say "Fast-forwarded $branch_name to $onto_name."
move_to_original_branch
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 21/31] rebase -i: align variable names
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Rename variables HEAD and OLDHEAD to orig_head and HEADNAME to
head_name, which are the names used in git-rebase.sh. This prepares
for factoring out of the code that persists these variables during the
entire rebase process. Using the same variable names to mean the same
thing in both files also makes the code easier to read.
While at it, also remove the DOTEST variable and use the state_dir
variable that was inherited from git-rebase.sh instead.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Squash this commit with earlier commit that also renamed variables in
git-rebase--interactive.sh?
git-rebase--interactive.sh | 120 +++++++++++++++++++++----------------------
1 files changed, 59 insertions(+), 61 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e848ea2..eace4e5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -12,22 +12,20 @@
. git-sh-setup
-DOTEST="$GIT_DIR/rebase-merge"
-
# The file containing rebase commands, comments, and empty lines.
# This file is created by "git rebase -i" then edited by the user. As
# the lines are processed, they are removed from the front of this
# file and written to the tail of $DONE.
-TODO="$DOTEST"/git-rebase-todo
+TODO="$state_dir"/git-rebase-todo
# The rebase command lines that have already been processed. A line
# is moved here when it is first handled, before any associated user
# actions.
-DONE="$DOTEST"/done
+DONE="$state_dir"/done
# The commit message that is planned to be used for any changes that
# need to be committed following a user interaction.
-MSG="$DOTEST"/message
+MSG="$state_dir"/message
# The file into which is accumulated the suggested commit message for
# squash/fixup commands. When the first of a series of squash/fixups
@@ -42,14 +40,14 @@ MSG="$DOTEST"/message
# written to the file so far (including the initial "pick" commit).
# Each time that a commit message is processed, this line is read and
# updated. It is deleted just before the combined commit is made.
-SQUASH_MSG="$DOTEST"/message-squash
+SQUASH_MSG="$state_dir"/message-squash
# If the current series of squash/fixups has not yet included a squash
# command, then this file exists and holds the commit message of the
# original "pick" commit. (If the series ends without a "squash"
# command, then this can be used as the commit message of the combined
# commit without opening the editor.)
-FIXUP_MSG="$DOTEST"/message-fixup
+FIXUP_MSG="$state_dir"/message-fixup
# $REWRITTEN is the name of a directory containing files for each
# commit that is reachable by at least one merge base of $HEAD and
@@ -57,14 +55,14 @@ FIXUP_MSG="$DOTEST"/message-fixup
# might be. This ensures that commits on merged, but otherwise
# unrelated side branches are left alone. (Think "X" in the man page's
# example.)
-REWRITTEN="$DOTEST"/rewritten
+REWRITTEN="$state_dir"/rewritten
-DROPPED="$DOTEST"/dropped
+DROPPED="$state_dir"/dropped
# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
# GIT_AUTHOR_DATE that will be used for the commit that is currently
# being rebased.
-AUTHOR_SCRIPT="$DOTEST"/author-script
+AUTHOR_SCRIPT="$state_dir"/author-script
# When an "edit" rebase command is being processed, the SHA1 of the
# commit to be edited is recorded in this file. When "git rebase
@@ -72,14 +70,14 @@ AUTHOR_SCRIPT="$DOTEST"/author-script
# will be amended to the HEAD commit, but only provided the HEAD
# commit is still the commit to be edited. When any other rebase
# command is processed, this file is deleted.
-AMEND="$DOTEST"/amend
+AMEND="$state_dir"/amend
# For the post-rewrite hook, we make a list of rewritten commits and
# their new sha1s. The rewritten-pending list keeps the sha1s of
# commits that have been processed, but not committed yet,
# e.g. because they are waiting for a 'squash' command.
-REWRITTEN_LIST="$DOTEST"/rewritten-list
-REWRITTEN_PENDING="$DOTEST"/rewritten-pending
+REWRITTEN_LIST="$state_dir"/rewritten-list
+REWRITTEN_PENDING="$state_dir"/rewritten-pending
GIT_CHERRY_PICK_HELP="$RESOLVEMSG"
export GIT_CHERRY_PICK_HELP
@@ -145,7 +143,7 @@ make_patch () {
*)
echo "Root commit"
;;
- esac > "$DOTEST"/patch
+ esac > "$state_dir"/patch
test -f "$MSG" ||
commit_message "$1" > "$MSG"
test -f "$AUTHOR_SCRIPT" ||
@@ -153,14 +151,14 @@ make_patch () {
}
die_with_patch () {
- echo "$1" > "$DOTEST"/stopped-sha
+ echo "$1" > "$state_dir"/stopped-sha
make_patch "$1"
git rerere
die "$2"
}
die_abort () {
- rm -rf "$DOTEST"
+ rm -rf "$state_dir"
die "$1"
}
@@ -205,20 +203,20 @@ pick_one_preserving_merges () {
esac
sha1=$(git rev-parse $sha1)
- if test -f "$DOTEST"/current-commit
+ if test -f "$state_dir"/current-commit
then
if test "$fast_forward" = t
then
while read current_commit
do
git rev-parse HEAD > "$REWRITTEN"/$current_commit
- done <"$DOTEST"/current-commit
- rm "$DOTEST"/current-commit ||
+ done <"$state_dir"/current-commit
+ rm "$state_dir"/current-commit ||
die "Cannot write current commit's replacement sha1"
fi
fi
- echo $sha1 >> "$DOTEST"/current-commit
+ echo $sha1 >> "$state_dir"/current-commit
# rewrite parents; if none were rewritten, we can fast-forward.
new_parents=
@@ -425,7 +423,7 @@ do_next () {
mark_action_done
pick_one $sha1 ||
die_with_patch $sha1 "Could not apply $sha1... $rest"
- echo "$sha1" > "$DOTEST"/stopped-sha
+ echo "$sha1" > "$state_dir"/stopped-sha
make_patch $sha1
git rev-parse --verify HEAD > "$AMEND"
warn "Stopped at $sha1... $rest"
@@ -490,7 +488,7 @@ do_next () {
printf 'Executing: %s\n' "$rest"
# "exec" command doesn't take a sha1 in the todo-list.
# => can't just use $sha1 here.
- git rev-parse --verify HEAD > "$DOTEST"/stopped-sha
+ git rev-parse --verify HEAD > "$state_dir"/stopped-sha
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
status=$?
if test "$status" -ne 0
@@ -525,19 +523,19 @@ do_next () {
test -s "$TODO" && return
comment_for_reflog finish &&
- HEADNAME=$(cat "$DOTEST"/head-name) &&
- OLDHEAD=$(cat "$DOTEST"/head) &&
- SHORTONTO=$(git rev-parse --short $(cat "$DOTEST"/onto)) &&
+ head_name=$(cat "$state_dir"/head-name) &&
+ orig_head=$(cat "$state_dir"/head) &&
+ SHORTONTO=$(git rev-parse --short $(cat "$state_dir"/onto)) &&
NEWHEAD=$(git rev-parse HEAD) &&
- case $HEADNAME in
+ case $head_name in
refs/*)
- message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO" &&
- git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
- git symbolic-ref HEAD $HEADNAME
+ message="$GIT_REFLOG_ACTION: $head_name onto $SHORTONTO" &&
+ git update-ref -m "$message" $head_name $NEWHEAD $orig_head &&
+ git symbolic-ref HEAD $head_name
;;
esac && {
- test ! -f "$DOTEST"/verbose ||
- git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
+ test ! -f "$state_dir"/verbose ||
+ git diff-tree --stat $(cat "$state_dir"/head)..HEAD
} &&
{
test -s "$REWRITTEN_LIST" &&
@@ -549,9 +547,9 @@ do_next () {
"$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"
true # we don't care if this hook failed
fi &&
- rm -rf "$DOTEST" &&
+ rm -rf "$state_dir" &&
git gc --auto &&
- warn "Successfully rebased and updated $HEADNAME."
+ warn "Successfully rebased and updated $head_name."
exit
}
@@ -602,9 +600,9 @@ skip_unnecessary_picks () {
get_saved_options () {
test -d "$REWRITTEN" && preserve_merges=t
- test -f "$DOTEST"/strategy && strategy="$(cat "$DOTEST"/strategy)"
- test -f "$DOTEST"/verbose && verbose=t
- test -f "$DOTEST"/rebase-root && rebase_root=t
+ test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
+ test -f "$state_dir"/verbose && verbose=t
+ test -f "$state_dir"/rebase-root && rebase_root=t
}
# Rearrange the todo list that has both "pick sha1 msg" and
@@ -704,7 +702,7 @@ first and then run 'git rebase --continue' again."
}
fi
- record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
+ record_in_rewritten "$(cat "$state_dir"/stopped-sha)"
require_clean_work_tree "rebase"
do_rest
@@ -715,15 +713,15 @@ abort)
git rerere clear
- HEADNAME=$(cat "$DOTEST"/head-name)
- HEAD=$(cat "$DOTEST"/head)
- case $HEADNAME in
+ head_name=$(cat "$state_dir"/head-name)
+ orig_head=$(cat "$state_dir"/head)
+ case $head_name in
refs/*)
- git symbolic-ref HEAD $HEADNAME
+ git symbolic-ref HEAD $head_name
;;
esac &&
- output git reset --hard $HEAD &&
- rm -rf "$DOTEST"
+ output git reset --hard $orig_head &&
+ rm -rf "$state_dir"
exit
;;
skip)
@@ -747,28 +745,28 @@ then
die "Could not checkout $switch_to"
fi
-HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
-mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
+orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
+mkdir "$state_dir" || die "Could not create temporary $state_dir"
-: > "$DOTEST"/interactive || die "Could not mark as interactive"
-echo "$head_name" > "$DOTEST"/head-name
+: > "$state_dir"/interactive || die "Could not mark as interactive"
+echo "$head_name" > "$state_dir"/head-name
-echo $HEAD > "$DOTEST"/head
+echo $orig_head > "$state_dir"/head
case "$rebase_root" in
'')
- rm -f "$DOTEST"/rebase-root ;;
+ rm -f "$state_dir"/rebase-root ;;
*)
- : >"$DOTEST"/rebase-root ;;
+ : >"$state_dir"/rebase-root ;;
esac
-echo $onto > "$DOTEST"/onto
-test -z "$strategy" || echo "$strategy" > "$DOTEST"/strategy
-test t = "$verbose" && : > "$DOTEST"/verbose
+echo $onto > "$state_dir"/onto
+test -z "$strategy" || echo "$strategy" > "$state_dir"/strategy
+test t = "$verbose" && : > "$state_dir"/verbose
if test t = "$preserve_merges"
then
if test -z "$rebase_root"
then
mkdir "$REWRITTEN" &&
- for c in $(git merge-base --all $HEAD $upstream)
+ for c in $(git merge-base --all $orig_head $upstream)
do
echo $onto > "$REWRITTEN"/$c ||
die "Could not init rewritten commits"
@@ -782,21 +780,21 @@ then
# parents to rewrite and skipping dropped commits would
# prematurely end our probe
MERGES_OPTION=
- first_after_upstream="$(git rev-list --reverse --first-parent $upstream..$HEAD | head -n 1)"
+ first_after_upstream="$(git rev-list --reverse --first-parent $upstream..$orig_head | head -n 1)"
else
MERGES_OPTION="--no-merges --cherry-pick"
fi
-SHORTHEAD=$(git rev-parse --short $HEAD)
+SHORTHEAD=$(git rev-parse --short $orig_head)
SHORTONTO=$(git rev-parse --short $onto)
if test -z "$rebase_root"
# this is now equivalent to ! -z "$upstream"
then
SHORTUPSTREAM=$(git rev-parse --short $upstream)
- REVISIONS=$upstream...$HEAD
+ REVISIONS=$upstream...$orig_head
SHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD
else
- REVISIONS=$onto...$HEAD
+ REVISIONS=$onto...$orig_head
SHORTREVISIONS=$SHORTHEAD
fi
git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
@@ -837,13 +835,13 @@ then
mkdir "$DROPPED"
# Save all non-cherry-picked changes
git rev-list $REVISIONS --left-right --cherry-pick | \
- sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
+ sed -n "s/^>//p" > "$state_dir"/not-cherry-picks
# Now all commits and note which ones are missing in
# not-cherry-picks and hence being dropped
git rev-list $REVISIONS |
while read rev
do
- if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
+ if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$state_dir"/not-cherry-picks)" = ""
then
# Use -f2 because if rev-list is telling us this commit is
# not worthwhile, we don't want to track its multiple heads,
@@ -889,5 +887,5 @@ has_action "$TODO" ||
test -d "$REWRITTEN" || test -n "$force_rebase" || skip_unnecessary_picks
output git checkout $onto || die_abort "could not detach HEAD"
-git update-ref ORIG_HEAD $HEAD
+git update-ref ORIG_HEAD $orig_head
do_rest
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 30/31] rebase -i: don't read unused variable preserve_merges
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Since 8e4a91b (rebase -i: remember the settings of -v, -s and -p when
interrupted, 2007-07-08), the variable preserve_merges (then called
PRESERVE_MERGES) was detected from the state saved in
$GIT_DIR/rebase-merge in order to be used when the rebase resumed, but
its value was never actually used. The variable's value was only used
when the rebase was initated.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 0763ef5..d20a9b2 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -583,7 +583,6 @@ skip_unnecessary_picks () {
}
get_saved_options () {
- test -d "$REWRITTEN" && preserve_merges=t
test -f "$state_dir"/rebase-root && rebase_root=t
}
@@ -650,8 +649,6 @@ rearrange_squash () {
case "$action" in
continue)
- get_saved_options
-
# do we have anything to commit?
if git diff-index --cached --quiet --ignore-submodules HEAD --
then
@@ -682,8 +679,6 @@ first and then run 'git rebase --continue' again."
do_rest
;;
skip)
- get_saved_options
-
git rerere clear
do_rest
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 26/31] rebase: remember strategy and strategy options
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
When a rebase is resumed, interactive rebase remembers any merge
strategy passed when the rebase was initated. Make non-interactive
rebase remember any merge strategy as well. Also make non-interactive
rebase remember any merge strategy options.
To be able to resume a rebase that was initiated with an older version
of git (older than this commit), make sure not to expect the saved
option files to exist.
Test case idea taken from Junio's 71fc224 (t3402: test "rebase
-s<strategy> -X<opt>", 2010-11-11).
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
How to add support for strategy options to interactive rebase?
git-rebase--interactive.sh | 2 --
git-rebase.sh | 6 ++++++
t/t3418-rebase-continue.sh | 29 +++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 7809932..0763ef5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -584,7 +584,6 @@ skip_unnecessary_picks () {
get_saved_options () {
test -d "$REWRITTEN" && preserve_merges=t
- test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
test -f "$state_dir"/rebase-root && rebase_root=t
}
@@ -713,7 +712,6 @@ case "$rebase_root" in
*)
: >"$state_dir"/rebase-root ;;
esac
-test -z "$strategy" || echo "$strategy" > "$state_dir"/strategy
if test t = "$preserve_merges"
then
if test -z "$rebase_root"
diff --git a/git-rebase.sh b/git-rebase.sh
index e5be7e5..d192038 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -78,6 +78,9 @@ read_basic_state () {
fi &&
GIT_QUIET=$(cat "$state_dir"/quiet) &&
test -f "$state_dir"/verbose && verbose=t
+ test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
+ test -f "$state_dir"/strategy_opts &&
+ strategy_opts="$(cat "$state_dir"/strategy_opts)"
}
write_basic_state () {
@@ -91,6 +94,9 @@ write_basic_state () {
fi &&
echo "$GIT_QUIET" > "$state_dir"/quiet &&
test t = "$verbose" && : > "$state_dir"/verbose
+ test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
+ test -n "$strategy_opts" && echo "$strategy_opts" > \
+ "$state_dir"/strategy_opts
}
output () {
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index 1d90191..5469546 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -45,4 +45,33 @@ test_expect_success 'rebase --continue can not be used with other options' '
test_must_fail git rebase --continue -v
'
+test_expect_success 'rebase --continue remembers merge strategy and options' '
+ rm -fr .git/rebase-* &&
+ git reset --hard commit-new-file-F2-on-topic-branch &&
+ test_commit "commit-new-file-F3-on-topic-branch" F3 32 &&
+ test_when_finished "rm -fr test-bin funny.was.run" &&
+ mkdir test-bin &&
+ cat >test-bin/git-merge-funny <<-EOF
+ #!$SHELL_PATH
+ case "\$1" in --opt) ;; *) exit 2 ;; esac
+ shift &&
+ >funny.was.run &&
+ exec git merge-recursive "\$@"
+ EOF
+ chmod +x test-bin/git-merge-funny &&
+ (
+ PATH=./test-bin:$PATH
+ test_must_fail git rebase -s funny -Xopt master topic
+ ) &&
+ test -f funny.was.run &&
+ rm funny.was.run &&
+ echo "Resolved" >F2 &&
+ git add F2 &&
+ (
+ PATH=./test-bin:$PATH
+ git rebase --continue
+ ) &&
+ test -f funny.was.run
+'
+
test_done
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 31/31] rebase -i: remove unnecessary state rebase-root
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk, Thomas Rast
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Before calling 'git cherry-pick', interactive rebase currently checks
if we are rebasing from root (if --root was passed). If we are, the
'--ff' flag to 'git cherry-pick' is omitted. However, according to the
documentation for 'git cherry-pick --ff', "If the current HEAD is the
same as the parent of the cherry-picked commit, then a fast forward to
this commit will be performed.". This should never be the case when
rebasing from root, so it should not matter whether --ff is passed, so
simplify the code by removing the condition.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
While factoring out the state writing code a few patches back, I went
through each of the pieces of state that was written. I was a bit
hesitant to include this patch since I'm not quite sure why the code
was introduced, but I thought I would include it anyway to hear what
you have to say.
There used to be bug when using --ff when rebasing a root commit. This
was fixed in 6355e50 (builtin/revert.c: don't dereference a NULL
pointer, 2010-09-27). Could this have been the reason for the check?
Thomas, do you remember?
git-rebase--interactive.sh | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d20a9b2..a9f44d8 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -168,11 +168,6 @@ pick_one () {
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
test -d "$REWRITTEN" &&
pick_one_preserving_merges "$@" && return
- if test -n "$rebase_root"
- then
- output git cherry-pick "$@"
- return
- fi
output git cherry-pick $ff "$@"
}
@@ -582,10 +577,6 @@ skip_unnecessary_picks () {
die "Could not skip unnecessary pick commands"
}
-get_saved_options () {
- test -f "$state_dir"/rebase-root && rebase_root=t
-}
-
# Rearrange the todo list that has both "pick sha1 msg" and
# "pick sha1 fixup!/squash! msg" appears in it so that the latter
# comes immediately after the former, and change "pick" to
@@ -701,12 +692,6 @@ mkdir "$state_dir" || die "Could not create temporary $state_dir"
: > "$state_dir"/interactive || die "Could not mark as interactive"
write_basic_state
-case "$rebase_root" in
-'')
- rm -f "$state_dir"/rebase-root ;;
-*)
- : >"$state_dir"/rebase-root ;;
-esac
if test t = "$preserve_merges"
then
if test -z "$rebase_root"
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 29/31] git-rebase--am: remove unnecessary --3way option
From: Martin von Zweigbergk @ 2010-12-28 9:30 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder, Martin von Zweigbergk
In-Reply-To: <1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com>
Since 22db240 (git-am: propagate --3way options as well, 2008-12-04),
the --3way has been propageted across failure, so it is since
pointless to pass it to git-am when resuming.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--am.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 5acfa00..95608c6 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -7,12 +7,12 @@
case "$action" in
continue)
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
+ git am --resolved --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
skip)
- git am --skip -3 --resolvemsg="$RESOLVEMSG" &&
+ git am --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox