* Re: [RFC/PATCH] cherry-pick/revert: add support for -X/--strategy-option
From: Jonathan Nieder @ 2010-12-28 19:37 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Christian Couder, Justin Frankel, Bert Wesarg,
Eyvind Bernhardsen, Kevin Ballard
In-Reply-To: <7v7hetyeom.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Pong, if you are pinging me. I thought you wanted to only discuss it
> first with RFC and meant to follow up on a real-for-inclusion patch.
You thought correctly. In this case I can't think of any change this
needs on top to make this real for inclusion so I just bumped the
thread.
There were two hints at improvements in this thread (separate topic):
the "git merge" manual could use some discussion of the distinction
between --renormalize and --ignore-whitespace-at-eol, and am, rebase,
stash, and "checkout -m <tree>" ought to have -X plumbed, too.
^ permalink raw reply
* Re: [PATCH 16/31] rebase -i: support --stat
From: Martin von Zweigbergk @ 2010-12-28 13:24 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Martin von Zweigbergk, git, Junio C Hamano, Johannes Sixt,
Christian Couder
In-Reply-To: <alpine.DEB.1.00.1012281858300.1794@bonsai2>
On Tue, 28 Dec 2010, Johannes Schindelin wrote:
> Hi,
>
> On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:
>
> > diff --git a/git-rebase.sh b/git-rebase.sh
> > index 229e8d2..0fc580a 100755
>
> Hmpf... After a rebasing merge to junio/next:
>
> -- snip --
> [...]
> Applying: rebase -i: support --stat
> fatal: sha1 information is lacking or useless (git-rebase.sh).
> Repository lacks necessary blobs to fall back on 3-way merge.
> Cannot fall back to three-way merge.
> [...]
> -- snap --
>
> Is this supposed to apply on top of junio/master, junio/next, junio/maint?
It is supposed to apply on top of junio/master. I tried exporting the
recevied emails using Alpine. This is the first time I do this, but I
managed to export them to one big file. I then applied it using 'git
am' onto a new branch created from junio/master and it was
successful. I'm very surprised that patch 16 failed for you if the
first 15 patches applied correctly.
I'm not sure what to use the hashes in the beginning of your mail for,
but I have verified that they match the hashes of git-rebase.sh before
and after patch 16 (in both my original branch and in the temporary
branch where I ran 'git am' on my own emails).
Regards,
Martin
^ permalink raw reply
* Re: cherry-pick / pre-commit hook?
From: Junio C Hamano @ 2010-12-28 18:16 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Dave Abrahams, git
In-Reply-To: <20101227093729.GB1201@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Dave Abrahams wrote:
>
>> if you're going to have a "pre-commit hook" concept,
>> but not run that hook for some kinds of commits, then that fact needs
>> to be documented.
>
> True, and thanks for a reminder. Suggested wording?
>
> The current githooks(5) says
>
> pre-commit
> This hook is invoked by git commit, and can be bypassed with
> --no-verify option.
>
> and leaves the question of whether it is invoked by git cherry-pick
> unanswered.
Yeah, but do we want to answer it in this section, or in git-cherry-pick's
manual page?
After all "pre-commit" was _not_ about "before doing anything that creates
a commit", but was about "before git-commit creates a commit". Changing
that definition is fine as long as we have a good way to explain it to the
users and more importantly a simple rule that the users can understand,
and that rule _could_ be "anything that creates a new commit".
In reality "anything that creates a new commit" cannot be that simple
rule, however. For example, "git pull" does attempt to create a new merge
commit, but failing it because the work done by the other person you are
pulling from does not conform _your_ standard defined by your hook is not
a sane default.
I think the basic direction could be (I haven't thought things through,
just a strawman):
- Allow --verify/--no-verify to all commands that possibly create a new
commit, and run pre-commit hook where an updated index is about to be
made into a commit (for some commands this may not be very easy);
- The guideline of picking the default would probably look like this:
(1) for existing commands, keep the current behaviour;
(2) for a new command, --verify should be the default if the command is
primarily about letting the user do what s/he would/could/should
have done as "git commit" in the first place (e.g. cherry-picking
one's own commit from a separate branch or rebasing one's own
unpublished branch on top of updated upstream), and --no-verify
otherwise (i.e. taking other's work and using it in a context
different from the original).
^ permalink raw reply
* Re: [PATCH 13/14] t4135-*.sh: Skip the "backslash" tests on cygwin
From: Ramsay Jones @ 2010-12-28 18:10 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy
Cc: Johannes Sixt, Junio C Hamano, GIT Mailing-list, jrnieder
In-Reply-To: <AANLkTi=-7ihdW_cMiAqnyjbUE_d35OFrSSnQQw4mi64G@mail.gmail.com>
Nguyen Thai Ngoc Duy wrote:
> On Wed, Dec 22, 2010 at 2:31 AM, Ramsay Jones
> <ramsay@ramsay1.demon.co.uk> wrote:
>> The problem boils down to the call to strncmp_icase() suppressing the call to
>> fnmatch() when the pattern contains glob chars, but the (remaining) string is
>> equal to the name; thus returning an exact match (MATCHED_EXACTLY) rather than
>> calling fnmatch (and returning either no-match or MATCHED_FNMATCH).
>
> I think that's expected behavior. Wildcard pathspecs are fixed
> pathspecs will additional wildcard matching support and can match both
> ways. See 186d604 (glossary: define pathspec)
Really? Hmm, that seems ... odd! (To be clear: you are saying that an exact
match, *even if the pattern contains glob chars*, takes precedence over the
glob match! - again *odd*)
Well, if you are happy with that ...
ATB,
Ramsay Jones
^ permalink raw reply
* Re: [PATCH] t0050: fix printf format strings for portability
From: Ramsay Jones @ 2010-12-28 18:05 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: prohaska, Junio C Hamano, GIT Mailing-list, trast
In-Reply-To: <20101221202755.GA27214@burratino>
Jonathan Nieder wrote:
> diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
> index 057c97c..1542cf6 100755
> --- a/t/t0050-filesystem.sh
> +++ b/t/t0050-filesystem.sh
> @@ -4,8 +4,8 @@ test_description='Various filesystem issues'
>
> . ./test-lib.sh
>
> -auml=`printf '\xc3\xa4'`
> -aumlcdiar=`printf '\x61\xcc\x88'`
> +auml=$(printf '\303\244')
> +aumlcdiar=$(printf '\141\314\210')
>
> case_insensitive=
> unibad=
Thanks everyone (Jonathan, Junio and Thomas) for the quick reply and fix!
[I should have figured it out myself, but I just couldn't imagine printf
not supporting hex escapes! :-P ]
ATB,
Ramsay Jones
^ permalink raw reply
* Re: [PATCH 16/31] rebase -i: support --stat
From: Johannes Schindelin @ 2010-12-28 17:59 UTC (permalink / raw)
To: Martin von Zweigbergk
Cc: git, Junio C Hamano, Johannes Sixt, Christian Couder
In-Reply-To: <1293528648-21873-17-git-send-email-martin.von.zweigbergk@gmail.com>
Hi,
On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 229e8d2..0fc580a 100755
Hmpf... After a rebasing merge to junio/next:
-- snip --
[...]
Applying: rebase -i: support --stat
fatal: sha1 information is lacking or useless (git-rebase.sh).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
[...]
-- snap --
Is this supposed to apply on top of junio/master, junio/next, junio/maint?
Ciao,
Dscho
^ permalink raw reply
* Re: Unable to delete remote branch with a strange name
From: Tomas Carnecky @ 2010-12-28 17:59 UTC (permalink / raw)
To: Jingzhao Ou; +Cc: git
In-Reply-To: <loom.20101228T170808-756@post.gmane.org>
On 12/28/10 5:10 PM, Jingzhao Ou wrote:
> Yes, using the absolute path works like a champ!
>
> git push origin :refs/heads/remotes/origin/dev/main
Do not use the term 'path' in this context. The fact that a ref looks
like a path, and can be stored on the filesystem under the same
directory structure is just an implementation detail. Note the *can*,
because in the case of packed refs (see man git-pack-refs) the term
'path' is not even remotely accurate.
We use the term 'fully qualified ref' (see the similarity with 'fully
qualified domain name') if we want to stress out that the full name of
the ref is used (refs/heads/foo) instead of an abbreviation (foo).
tom
^ permalink raw reply
* Re: "git show" does not use diff.external like "git diff" does
From: Bruce Momjian @ 2010-12-28 17:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v39phyec2.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Bruce Momjian <bruce@momjian.us> writes:
>
> > 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?
>
> "git show --ext-diff"?
>
> We end the Description section of the manual with "This manual page
> describes only the most frequently used options." without explicitly
> saying "Options from the underlying this and that commands can be given as
> well", which is rather suboptimal.
>
> The only existing hint there is one sentence before, "The command takes
> options applicable to the git diff-tree command...", but the reader needs
> to be both careful and vaguely familiar with the way the git command set
> is structured to take advantage of that hint.
Yes, someone on IRC eventually suggested --ext-diff, and it does work.
I was hoping for something that caused 'show' to always use --ext-diff,
like git diff does. A git alias was the only suggested workaround.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply
* Re: "git show" does not use diff.external like "git diff" does
From: Junio C Hamano @ 2010-12-28 17:52 UTC (permalink / raw)
To: Bruce Momjian; +Cc: git
In-Reply-To: <201012281510.oBSFAMm14943@momjian.us>
Bruce Momjian <bruce@momjian.us> writes:
> 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?
"git show --ext-diff"?
We end the Description section of the manual with "This manual page
describes only the most frequently used options." without explicitly
saying "Options from the underlying this and that commands can be given as
well", which is rather suboptimal.
The only existing hint there is one sentence before, "The command takes
options applicable to the git diff-tree command...", but the reader needs
to be both careful and vaguely familiar with the way the git command set
is structured to take advantage of that hint.
^ permalink raw reply
* Re: [RFC/PATCH] cherry-pick/revert: add support for -X/--strategy-option
From: Junio C Hamano @ 2010-12-28 17:45 UTC (permalink / raw)
To: Jonathan Nieder
Cc: git, Christian Couder, Justin Frankel, Bert Wesarg,
Eyvind Bernhardsen, Kevin Ballard
In-Reply-To: <20101227212515.GA32352@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Jonathan Nieder wrote:
>
>> For example, this would allow cherry-picking or reverting patches from
>> a piece of history with a different end-of-line style, like so:
>>
>> $ git revert -Xrenormalize old-problematic-commit
>>
>> Currently that is possible with manual use of merge-recursive but the
>> cherry-pick/revert porcelain does not expose the functionality.
>>
>> While at it, document the existing support for --strategy.
>>
>> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
>> ---
>> Thoughts?
>
> Ping? I use this with -Xpatience fairly often. Am I the only one who
> has wanted such a thing?
Pong, if you are pinging me. I thought you wanted to only discuss it
first with RFC and meant to follow up on a real-for-inclusion patch.
The goal stated in the proposed commit log is a good thing to have, and
exactly the kind of thing -X<strategy option> interface was invented for
in the first place, I think.
I didn't look at the code though.
^ permalink raw reply
* Re: Git Architecture Question
From: Manuel Doninger @ 2010-12-28 17:23 UTC (permalink / raw)
To: Anuj Gakhar; +Cc: git
In-Reply-To: <20FFFEFA-5808-4673-B876-C5F76B52D12E@gmail.com>
Hi Anuj,
i'm facing a similar problem at the moment.
In my company we want to switch from CVS to Git and Ant to
Maven/Hudson. We have a similar environment like you, Development,
Testing and Production, and my plan at the moment is to have a
development, testing and master branch. Every of these branches should
represent the appropriate environment. Then I configure Hudson with 3
jobs, every job to build one of these branches and to deploy to a
separete folder on our server.
If the developers then create a new change in a feature branch, we
would merge that feature branch into branch development for our
internal tests, then later merge that into testing for our QA
department if they say they want to test that change, and if they say
it's ok, merge that change into master to deploy it in production
environment.
This workflow is though not in production use, we evaluate this and
other workflows at the moment, so I don't have any experiences from
daily work.
Cheers,
Manuel
^ permalink raw reply
* Git Architecture Question
From: Anuj Gakhar @ 2010-12-28 16:54 UTC (permalink / raw)
To: git
Hi all,
I am new to Git and learning this powerful tool these days.
I have a simple question :-
I work on a project that has 3 different environments. dev, staging
and production. dev is obviously the local git repo that all dev's
work on. staging is where most of the development takes places on a
daily basis. and production is where least development happens but we
still do it because sometimes we have to fix things quickly directly
on the production server.
So how should I set this up ?
2 branches staging and master (default) ?
How can I make it so that the staging branch gets deployed to a
different folder on the server and the master branch gets deployed on
a different folder ?
Once a week, we would merge all the staging work into production and
make a release.
Any ideas ?
Anuj Gakhar
www.anujgakhar.com
www.anshconsulting.co.uk
^ permalink raw reply
* Re: [PATCH 31/31] rebase -i: remove unnecessary state rebase-root
From: Thomas Rast @ 2010-12-28 16:40 UTC (permalink / raw)
To: Martin von Zweigbergk
Cc: git, Junio C Hamano, Johannes Schindelin, Johannes Sixt,
Christian Couder
In-Reply-To: <1293528648-21873-32-git-send-email-martin.von.zweigbergk@gmail.com>
Martin von Zweigbergk wrote:
> @@ -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 "$@"
> }
[...]
> 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?
I think this just ended up being such a strange test because of the
following hunk in 8e75abf (rebase -i: use new --ff cherry-pick option,
2010-03-06):
@@ -232,16 +232,7 @@ pick_one () {
output git cherry-pick "$@"
return
fi
- parent_sha1=$(git rev-parse --verify $sha1^) ||
- die "Could not get the parent of $sha1"
- current_sha1=$(git rev-parse --verify HEAD)
- if test -z "$no_ff" && test "$current_sha1" = "$parent_sha1"
- then
- output git reset --hard $sha1
- output warn Fast-forward to $(git rev-parse --short $sha1)
- else
- output git cherry-pick "$@"
- fi
+ output git cherry-pick $ff "$@"
}
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: Unable to delete remote branch with a strange name
From: Jingzhao Ou @ 2010-12-28 16:10 UTC (permalink / raw)
To: git
In-Reply-To: <m2hbdy9top.fsf@whitebox.home>
Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
> Jingzhao Ou <jingzhao.ou <at> gmail.com> writes:
>
> > I guess somehow, git is confused by "origin/dev/main" and
> > "origin/remotes/origin/dev/main". Especially, it cannot identify the latter
> > properly.
>
> Try fully qualifying the remote branch (beginning with refs/heads/).
>
> Andreas.
>
Hi, Andreas,
Yes, using the absolute path works like a champ!
git push origin :refs/heads/remotes/origin/dev/main
Thanks a lot for your help!
Jingzhao
^ permalink raw reply
* [PATCH 01/31] rebase: clearer names for directory variables
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>
Instead of using the old variable name 'dotest' for
"$GIT_DIR"/rebase-merge and no variable for "$GIT_DIR"/rebase-apply,
introduce two variables 'merge_dir' and 'apply_dir' for these paths.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 141 +++++++++++++++++++++++++++++----------------------------
1 files changed, 71 insertions(+), 70 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index d8e1903..79f8008 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -46,7 +46,8 @@ unset newbase
strategy=recursive
strategy_opts=
do_merge=
-dotest="$GIT_DIR"/rebase-merge
+merge_dir="$GIT_DIR"/rebase-merge
+apply_dir="$GIT_DIR"/rebase-apply
prec=4
verbose=
diffstat=
@@ -58,7 +59,7 @@ allow_rerere_autoupdate=
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
- test -d "$dotest" || die "$dotest directory does not exist"
+ test -d "$merge_dir" || die "$merge_dir directory does not exist"
unmerged=$(git ls-files -u)
if test -n "$unmerged"
@@ -68,7 +69,7 @@ continue_merge () {
die "$RESOLVEMSG"
fi
- cmt=`cat "$dotest/current"`
+ cmt=`cat "$merge_dir/current"`
if ! git diff-index --quiet --ignore-submodules HEAD --
then
if ! git commit --no-verify -C "$cmt"
@@ -81,7 +82,7 @@ continue_merge () {
then
printf "Committed: %0${prec}d " $msgnum
fi
- echo "$cmt $(git rev-parse HEAD^0)" >> "$dotest/rewritten"
+ echo "$cmt $(git rev-parse HEAD^0)" >> "$merge_dir/rewritten"
else
if test -z "$GIT_QUIET"
then
@@ -93,22 +94,22 @@ continue_merge () {
prev_head=`git rev-parse HEAD^0`
# save the resulting commit so we can read-tree on it later
- echo "$prev_head" > "$dotest/prev_head"
+ echo "$prev_head" > "$merge_dir/prev_head"
# onto the next patch:
msgnum=$(($msgnum + 1))
- echo "$msgnum" >"$dotest/msgnum"
+ echo "$msgnum" >"$merge_dir/msgnum"
}
call_merge () {
- cmt="$(cat "$dotest/cmt.$1")"
- echo "$cmt" > "$dotest/current"
+ 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 "$dotest/msgnum")
- end=$(cat "$dotest/end")
+ msgnum=$(cat "$merge_dir/msgnum")
+ end=$(cat "$merge_dir/end")
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
- eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
+ eval GITHEAD_$hd='$(cat "$merge_dir/onto_name")'
export GITHEAD_$cmt GITHEAD_$hd
if test -n "$GIT_QUIET"
then
@@ -138,9 +139,9 @@ call_merge () {
move_to_original_branch () {
test -z "$head_name" &&
- head_name="$(cat "$dotest"/head-name)" &&
- onto="$(cat "$dotest"/onto)" &&
- orig_head="$(cat "$dotest"/orig-head)"
+ head_name="$(cat "$merge_dir"/head-name)" &&
+ onto="$(cat "$merge_dir"/onto)" &&
+ orig_head="$(cat "$merge_dir"/orig-head)"
case "$head_name" in
refs/*)
message="rebase finished: $head_name onto $onto"
@@ -154,12 +155,12 @@ move_to_original_branch () {
finish_rb_merge () {
move_to_original_branch
- git notes copy --for-rewrite=rebase < "$dotest"/rewritten
+ git notes copy --for-rewrite=rebase < "$merge_dir"/rewritten
if test -x "$GIT_DIR"/hooks/post-rewrite &&
- test -s "$dotest"/rewritten; then
- "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+ test -s "$merge_dir"/rewritten; then
+ "$GIT_DIR"/hooks/post-rewrite rebase < "$merge_dir"/rewritten
fi
- rm -r "$dotest"
+ rm -r "$merge_dir"
say All done.
}
@@ -183,7 +184,7 @@ is_interactive () {
export GIT_EDITOR
fi
- test -n "$interactive_rebase" || test -f "$dotest"/interactive
+ test -n "$interactive_rebase" || test -f "$merge_dir"/interactive
}
run_pre_rebase_hook () {
@@ -195,7 +196,7 @@ run_pre_rebase_hook () {
fi
}
-test -f "$GIT_DIR"/rebase-apply/applying &&
+test -f "$apply_dir"/applying &&
die 'It looks like git-am is in progress. Cannot rebase.'
is_interactive "$@" && exec git-rebase--interactive "$@"
@@ -210,7 +211,7 @@ do
OK_TO_SKIP_PRE_REBASE=
;;
--continue)
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ test -d "$merge_dir" -o -d "$apply_dir" ||
die "No rebase in progress?"
git update-index --ignore-submodules --refresh &&
@@ -219,13 +220,13 @@ do
echo "mark them as resolved using git add"
exit 1
}
- if test -d "$dotest"
+ if test -d "$merge_dir"
then
- prev_head=$(cat "$dotest/prev_head")
- end=$(cat "$dotest/end")
- msgnum=$(cat "$dotest/msgnum")
- onto=$(cat "$dotest/onto")
- GIT_QUIET=$(cat "$dotest/quiet")
+ prev_head=$(cat "$merge_dir/prev_head")
+ end=$(cat "$merge_dir/end")
+ msgnum=$(cat "$merge_dir/msgnum")
+ onto=$(cat "$merge_dir/onto")
+ GIT_QUIET=$(cat "$merge_dir/quiet")
continue_merge
while test "$msgnum" -le "$end"
do
@@ -235,28 +236,28 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
- onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
- orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
+ head_name=$(cat "$apply_dir"/head-name) &&
+ onto=$(cat "$apply_dir"/onto) &&
+ orig_head=$(cat "$apply_dir"/orig-head) &&
+ GIT_QUIET=$(cat "$apply_dir"/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
--skip)
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ test -d "$merge_dir" -o -d "$apply_dir" ||
die "No rebase in progress?"
git reset --hard HEAD || exit $?
- if test -d "$dotest"
+ if test -d "$merge_dir"
then
git rerere clear
- prev_head=$(cat "$dotest/prev_head")
- end=$(cat "$dotest/end")
- msgnum=$(cat "$dotest/msgnum")
+ prev_head=$(cat "$merge_dir/prev_head")
+ end=$(cat "$merge_dir/end")
+ msgnum=$(cat "$merge_dir/msgnum")
msgnum=$(($msgnum + 1))
- onto=$(cat "$dotest/onto")
- GIT_QUIET=$(cat "$dotest/quiet")
+ onto=$(cat "$merge_dir/onto")
+ GIT_QUIET=$(cat "$merge_dir/quiet")
while test "$msgnum" -le "$end"
do
call_merge "$msgnum"
@@ -265,31 +266,31 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
- onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
- orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
+ head_name=$(cat "$apply_dir"/head-name) &&
+ onto=$(cat "$apply_dir"/onto) &&
+ orig_head=$(cat "$apply_dir"/orig-head) &&
+ GIT_QUIET=$(cat "$apply_dir"/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
--abort)
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ test -d "$merge_dir" -o -d "$apply_dir" ||
die "No rebase in progress?"
git rerere clear
- test -d "$dotest" || dotest="$GIT_DIR"/rebase-apply
+ test -d "$merge_dir" || merge_dir="$apply_dir"
- head_name="$(cat "$dotest"/head-name)" &&
+ head_name="$(cat "$merge_dir"/head-name)" &&
case "$head_name" in
refs/*)
git symbolic-ref HEAD $head_name ||
die "Could not move back to $head_name"
;;
esac
- git reset --hard $(cat "$dotest/orig-head")
- rm -r "$dotest"
+ git reset --hard $(cat "$merge_dir/orig-head")
+ rm -r "$merge_dir"
exit
;;
--onto)
@@ -388,31 +389,31 @@ test $# -gt 2 && usage
if test $# -eq 0 && test -z "$rebase_root"
then
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
- test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
+ 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 $GIT_DIR/rebase-apply
+# Make sure we do not have $apply_dir or $merge_dir
if test -z "$do_merge"
then
- if mkdir "$GIT_DIR"/rebase-apply 2>/dev/null
+ if mkdir "$apply_dir" 2>/dev/null
then
- rmdir "$GIT_DIR"/rebase-apply
+ 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 '"$GIT_DIR"'/rebase-apply
+ rm -fr '"$apply_dir"'
and run me again. I am stopping in case you still have something
valuable there.'
exit 1
fi
else
- if test -d "$dotest"
+ if test -d "$merge_dir"
then
- die "previous rebase directory $dotest still exists." \
+ die "previous rebase directory $merge_dir still exists." \
'Try git rebase (--continue | --abort | --skip)'
fi
fi
@@ -560,35 +561,35 @@ then
git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
ret=$?
- test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
- echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
- echo $onto > "$GIT_DIR"/rebase-apply/onto &&
- echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head &&
- echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet
+ 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
-mkdir -p "$dotest"
-echo "$onto" > "$dotest/onto"
-echo "$onto_name" > "$dotest/onto_name"
+mkdir -p "$merge_dir"
+echo "$onto" > "$merge_dir/onto"
+echo "$onto_name" > "$merge_dir/onto_name"
prev_head=$orig_head
-echo "$prev_head" > "$dotest/prev_head"
-echo "$orig_head" > "$dotest/orig-head"
-echo "$head_name" > "$dotest/head-name"
-echo "$GIT_QUIET" > "$dotest/quiet"
+echo "$prev_head" > "$merge_dir/prev_head"
+echo "$orig_head" > "$merge_dir/orig-head"
+echo "$head_name" > "$merge_dir/head-name"
+echo "$GIT_QUIET" > "$merge_dir/quiet"
msgnum=0
for cmt in `git rev-list --reverse --no-merges "$revisions"`
do
msgnum=$(($msgnum + 1))
- echo "$cmt" > "$dotest/cmt.$msgnum"
+ echo "$cmt" > "$merge_dir/cmt.$msgnum"
done
-echo 1 >"$dotest/msgnum"
-echo $msgnum >"$dotest/end"
+echo 1 >"$merge_dir/msgnum"
+echo $msgnum >"$merge_dir/end"
end=$msgnum
msgnum=1
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 02/31] rebase: refactor reading of state
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 code reading the state saved in $merge_dir or $rebase_dir is
currently spread out in many places, making it harder to read and to
introduce additional state. Extract this code into one method that reads
the state.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 53 +++++++++++++++++++++++------------------------------
1 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 79f8008..bf144dc 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -57,6 +57,22 @@ rebase_root=
force_rebase=
allow_rerere_autoupdate=
+read_state () {
+ if test -d "$merge_dir"
+ then
+ state_dir="$merge_dir"
+ prev_head=$(cat "$merge_dir"/prev_head) &&
+ end=$(cat "$merge_dir"/end) &&
+ msgnum=$(cat "$merge_dir"/msgnum)
+ else
+ state_dir="$apply_dir"
+ fi &&
+ 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 -n "$prev_head" || die "prev_head must be defined"
test -d "$merge_dir" || die "$merge_dir directory does not exist"
@@ -138,10 +154,6 @@ call_merge () {
}
move_to_original_branch () {
- test -z "$head_name" &&
- head_name="$(cat "$merge_dir"/head-name)" &&
- onto="$(cat "$merge_dir"/onto)" &&
- orig_head="$(cat "$merge_dir"/orig-head)"
case "$head_name" in
refs/*)
message="rebase finished: $head_name onto $onto"
@@ -220,13 +232,9 @@ do
echo "mark them as resolved using git add"
exit 1
}
+ read_state
if test -d "$merge_dir"
then
- prev_head=$(cat "$merge_dir/prev_head")
- end=$(cat "$merge_dir/end")
- msgnum=$(cat "$merge_dir/msgnum")
- onto=$(cat "$merge_dir/onto")
- GIT_QUIET=$(cat "$merge_dir/quiet")
continue_merge
while test "$msgnum" -le "$end"
do
@@ -236,10 +244,6 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat "$apply_dir"/head-name) &&
- onto=$(cat "$apply_dir"/onto) &&
- orig_head=$(cat "$apply_dir"/orig-head) &&
- GIT_QUIET=$(cat "$apply_dir"/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
@@ -249,15 +253,11 @@ do
die "No rebase in progress?"
git reset --hard HEAD || exit $?
+ read_state
if test -d "$merge_dir"
then
git rerere clear
- prev_head=$(cat "$merge_dir/prev_head")
- end=$(cat "$merge_dir/end")
- msgnum=$(cat "$merge_dir/msgnum")
msgnum=$(($msgnum + 1))
- onto=$(cat "$merge_dir/onto")
- GIT_QUIET=$(cat "$merge_dir/quiet")
while test "$msgnum" -le "$end"
do
call_merge "$msgnum"
@@ -266,10 +266,6 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat "$apply_dir"/head-name) &&
- onto=$(cat "$apply_dir"/onto) &&
- orig_head=$(cat "$apply_dir"/orig-head) &&
- GIT_QUIET=$(cat "$apply_dir"/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
@@ -279,18 +275,15 @@ do
die "No rebase in progress?"
git rerere clear
-
- test -d "$merge_dir" || merge_dir="$apply_dir"
-
- head_name="$(cat "$merge_dir"/head-name)" &&
+ 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 $(cat "$merge_dir/orig-head")
- rm -r "$merge_dir"
+ git reset --hard $orig_head
+ rm -r "$state_dir"
exit
;;
--onto)
@@ -573,12 +566,12 @@ fi
# this is rename-aware if the recursive (default) strategy is used
mkdir -p "$merge_dir"
-echo "$onto" > "$merge_dir/onto"
echo "$onto_name" > "$merge_dir/onto_name"
prev_head=$orig_head
echo "$prev_head" > "$merge_dir/prev_head"
-echo "$orig_head" > "$merge_dir/orig-head"
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
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 13/31] rebase: factor out reference parsing
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 parsing and validation of references (onto, upstream, branch)
from git-rebase--interactive.sh and rely on the information exported from
git-rebase.sh.
By using the parsing of the --onto parameter in git-rebase.sh, this
improves the error message when the parameter is invalid.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Should the check for set GIT_COMMITTER_IDENT be done for
non-interactive rebase as well or does it only make sense for
interactive rebase?
git-rebase--interactive.sh | 48 +++----------------------------------------
git-rebase.sh | 12 ++++++----
2 files changed, 11 insertions(+), 49 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 5a8f582..c055fc4 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -682,25 +682,6 @@ rearrange_squash () {
rm -f "$1.sq" "$1.rearranged"
}
-LF='
-'
-parse_onto () {
- case "$1" in
- *...*)
- if left=${1%...*} right=${1#*...} &&
- onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
- then
- case "$onto" in
- ?*"$LF"?* | '')
- exit 1 ;;
- esac
- echo "$onto"
- exit 0
- fi
- esac
- git rev-parse --verify "$1^0"
-}
-
case "$action" in
continue)
get_saved_options
@@ -769,47 +750,26 @@ skip)
;;
esac
-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
-
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
require_clean_work_tree "rebase" "Please commit or stash them."
run_pre_rebase_hook "$upstream_arg" "$@"
comment_for_reflog start
-if test ! -z "$1"
+if test ! -z "$switch_to"
then
- output git checkout "$1" ||
- die "Could not checkout $1"
+ output git checkout "$switch_to" ||
+ die "Could not checkout $switch_to"
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_name" > "$DOTEST"/head-name
echo $HEAD > "$DOTEST"/head
case "$rebase_root" in
diff --git a/git-rebase.sh b/git-rebase.sh
index 26e4218..d8c7c8d 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -185,7 +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
+ force_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE upstream \
+ upstream_arg switch_to head_name
exec git-rebase--interactive "$@"
}
@@ -433,8 +434,6 @@ else
state_dir="$apply_dir"
fi
-test "$type" = interactive && run_interactive_rebase "$@"
-
if test -z "$rebase_root"
then
# The upstream head must be given. Make sure it is valid.
@@ -445,7 +444,7 @@ then
unset root_flag
upstream_arg="$upstream_name"
else
- test -z "$onto" && die "--root must be used with --onto"
+ test -z "$onto" && die "You must specify --onto when using --root"
unset upstream_name
unset upstream
root_flag="--root"
@@ -472,7 +471,8 @@ case "$onto_name" in
fi
;;
*)
- onto=$(git rev-parse --verify "${onto_name}^0") || exit
+ onto=$(git rev-parse --verify "${onto_name}^0") ||
+ die "Does not point to a valid commit: $1"
;;
esac
@@ -513,6 +513,8 @@ case "$#" in
esac
orig_head=$branch
+test "$type" = interactive && run_interactive_rebase "$@"
+
require_clean_work_tree "rebase" "Please commit or stash them."
# Now we are rebasing commits $upstream..$branch (or with --root,
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 07/31] rebase: stricter check of standalone sub command
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 sub commands '--continue', '--skip' or '--abort' may only be used
standalone according to the documentation. Other options following the
sub command are currently not accepted, but options preceeding them
are. For example, 'git rebase --continue -v' is not accepted, while
'git rebase -v --continue' is. Tighten up the check and allow no other
options when one of these sub commands are used.
Only check that it is standalone for non-interactive rebase for
now. Once the command line processing for interactive rebase has been
replaced by the command line processing in git-rebase.sh, this check
will also apply to interactive rebase.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
Is this too simplistic? Do we forsee that we want to support passing
options when resuming a rebase? Is it better to check for each other
option that it is not passed (i.e. no '-v', no '-s' etc.)?
Might some users be depending on the current behavior, even though it
is undocumented?
git-rebase.sh | 4 ++--
t/t3403-rebase-skip.sh | 5 +++++
t/t3407-rebase-abort.sh | 10 ++++++++++
t/t3418-rebase-continue.sh | 5 +++++
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 29f1214..1cb0564 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -229,6 +229,7 @@ then
fi
test -n "$type" && in_progress=t
+total_argc=$#
while test $# != 0
do
case "$1" in
@@ -239,9 +240,8 @@ do
OK_TO_SKIP_PRE_REBASE=
;;
--continue|--skip|--abort)
+ test $total_argc -eq 1 || usage
action=${1##--}
- shift
- break
;;
--onto)
test 2 -le "$#" || usage
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
index 64446e3..826500b 100755
--- a/t/t3403-rebase-skip.sh
+++ b/t/t3403-rebase-skip.sh
@@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '
test_must_fail git rebase master
'
+test_expect_success 'rebase --skip can not be used with other options' '
+ test_must_fail git rebase -v --skip &&
+ test_must_fail git rebase --skip -v
+'
+
test_expect_success 'rebase --skip with am -3' '
git rebase --skip
'
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index e573dc8..a6a6c40 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -84,6 +84,16 @@ testrebase() {
test_cmp reflog_before reflog_after &&
rm reflog_before reflog_after
'
+
+ test_expect_success 'rebase --abort can not be used with other options' '
+ cd "$work_dir" &&
+ # Clean up the state from the previous one
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test_must_fail git rebase -v --abort &&
+ test_must_fail git rebase --abort -v &&
+ git rebase --abort
+ '
}
testrebase "" .git/rebase-apply
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index 3b0d273..1d90191 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
git rebase --continue
'
+test_expect_success 'rebase --continue can not be used with other options' '
+ test_must_fail git rebase -v --continue &&
+ test_must_fail git rebase --continue -v
+'
+
test_done
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 03/31] rebase: read state outside 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>
The 'onto_name' state used in 'git rebase --merge' is currently read
once for each commit that need to be applied. It doesn't change
between each iteration, however, so it should be moved out of the
loop. This also makes the code more readable. Also remove the unused
variable 'end'.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index bf144dc..9be831e 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -62,6 +62,7 @@ read_state () {
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)
else
@@ -123,9 +124,8 @@ call_merge () {
hd=$(git rev-parse --verify HEAD)
cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
msgnum=$(cat "$merge_dir/msgnum")
- end=$(cat "$merge_dir/end")
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
- eval GITHEAD_$hd='$(cat "$merge_dir/onto_name")'
+ eval GITHEAD_$hd='$onto_name'
export GITHEAD_$cmt GITHEAD_$hd
if test -n "$GIT_QUIET"
then
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 25/31] rebase: remember verbose 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>
Currently, only interactive rebase remembers the value of the '-v'
flag from the initial invocation. Make non-interactive rebase also
remember it.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--interactive.sh | 2 --
git-rebase.sh | 6 ++++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a33b246..7809932 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -585,7 +585,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"/verbose && verbose=t
test -f "$state_dir"/rebase-root && rebase_root=t
}
@@ -715,7 +714,6 @@ case "$rebase_root" in
: >"$state_dir"/rebase-root ;;
esac
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"
diff --git a/git-rebase.sh b/git-rebase.sh
index 95c0d05..e5be7e5 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -76,7 +76,8 @@ read_basic_state () {
else
orig_head=$(cat "$state_dir"/orig-head)
fi &&
- GIT_QUIET=$(cat "$state_dir"/quiet)
+ GIT_QUIET=$(cat "$state_dir"/quiet) &&
+ test -f "$state_dir"/verbose && verbose=t
}
write_basic_state () {
@@ -88,7 +89,8 @@ write_basic_state () {
else
echo "$orig_head" > "$state_dir"/orig-head
fi &&
- echo "$GIT_QUIET" > "$state_dir"/quiet
+ echo "$GIT_QUIET" > "$state_dir"/quiet &&
+ test t = "$verbose" && : > "$state_dir"/verbose
}
output () {
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 24/31] rebase: extract code for writing basic state
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>
Extrace the code for writing the state to rebase-apply/ or
rebase-merge/ when a rebase is initiated. This will make it easier to
later make both interactive and non-interactive rebase remember the
options used.
Note that non-interactive rebase stores the sha1 of the original head
in a file called orig-head, while interactive rebase stores it in a
file called head.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--am.sh | 6 +-----
git-rebase--interactive.sh | 5 +----
git-rebase--merge.sh | 5 +----
git-rebase.sh | 16 ++++++++++++++--
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 9316761..5acfa00 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -26,9 +26,5 @@ git format-patch -k --stdout --full-index --ignore-if-in-upstream \
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"
+test 0 != $ret -a -d "$state_dir" && write_basic_state
exit $ret
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 1079994..a33b246 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -707,16 +707,13 @@ orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
mkdir "$state_dir" || die "Could not create temporary $state_dir"
: > "$state_dir"/interactive || die "Could not mark as interactive"
-echo "$head_name" > "$state_dir"/head-name
-
-echo $orig_head > "$state_dir"/head
+write_basic_state
case "$rebase_root" in
'')
rm -f "$state_dir"/rebase-root ;;
*)
: >"$state_dir"/rebase-root ;;
esac
-echo $onto > "$state_dir"/onto
test -z "$strategy" || echo "$strategy" > "$state_dir"/strategy
test t = "$verbose" && : > "$state_dir"/verbose
if test t = "$preserve_merges"
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
index 8cfdcf1..705d2f5 100644
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -127,10 +127,7 @@ 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"
+write_basic_state
msgnum=0
for cmt in `git rev-list --reverse --no-merges "$revisions"`
diff --git a/git-rebase.sh b/git-rebase.sh
index 7e2e978..95c0d05 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -79,6 +79,18 @@ read_basic_state () {
GIT_QUIET=$(cat "$state_dir"/quiet)
}
+write_basic_state () {
+ echo "$head_name" > "$state_dir"/head-name &&
+ echo "$onto" > "$state_dir"/onto &&
+ if test "$type" = interactive
+ then
+ echo "$orig_head" > "$state_dir"/head
+ else
+ echo "$orig_head" > "$state_dir"/orig-head
+ fi &&
+ echo "$GIT_QUIET" > "$state_dir"/quiet
+}
+
output () {
case "$verbose" in
'')
@@ -113,8 +125,8 @@ 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 git_am_opt
- export -f move_to_original_branch output
+ allow_rerere_autoupdate git_am_opt type
+ export -f move_to_original_branch output write_basic_state
exec git-rebase--$type
}
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 27/31] rebase -m: remember allow_rerere_autoupdate 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>
If '--[no-]allow_rerere_autoupdate' is passed when 'git rebase -m' is
called and a merge conflict occurs, the flag will be forgotten for the
rest of the rebase process. Make rebase remember it by saving the
value.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
allow_rerere_autoupdate is only used by git-rebase--merge. Still ok to
write and read it here?
Should allow_rerere_autoupdate also be added to git_am_opt?
git-rebase.sh | 4 ++++
t/t3418-rebase-continue.sh | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index d192038..05b4fe1 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -81,6 +81,8 @@ read_basic_state () {
test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
test -f "$state_dir"/strategy_opts &&
strategy_opts="$(cat "$state_dir"/strategy_opts)"
+ test -f "$state_dir"/allow_rerere_autoupdate &&
+ allow_rerere_autoupdate="$(cat "$state_dir"/allow_rerere_autoupdate)"
}
write_basic_state () {
@@ -97,6 +99,8 @@ write_basic_state () {
test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
test -n "$strategy_opts" && echo "$strategy_opts" > \
"$state_dir"/strategy_opts
+ test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \
+ "$state_dir"/allow_rerere_autoupdate
}
output () {
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index 5469546..1e855cd 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -74,4 +74,25 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
test -f funny.was.run
'
+test_expect_success 'rebase --continue remembers --rerere-autoupdate' '
+ rm -fr .git/rebase-* &&
+ git reset --hard commit-new-file-F3-on-topic-branch &&
+ git checkout master
+ test_commit "commit-new-file-F3" F3 3 &&
+ git config rerere.enabled true &&
+ test_must_fail git rebase -m master topic &&
+ echo "Resolved" >F2 &&
+ git add F2 &&
+ test_must_fail git rebase --continue &&
+ echo "Resolved" >F3 &&
+ git add F3 &&
+ git rebase --continue &&
+ git reset --hard topic@{1} &&
+ test_must_fail git rebase -m --rerere-autoupdate master &&
+ test "$(cat F2)" = "Resolved" &&
+ test_must_fail git rebase --continue &&
+ test "$(cat F3)" = "Resolved" &&
+ git rebase --continue
+'
+
test_done
--
1.7.3.2.864.gbbb96
^ permalink raw reply related
* [PATCH 28/31] rebase -m: don't print exit code 2 when merge fails
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 the merge strategy fails, a message suggesting the user to try
another strategy is displayed. Remove the "$rv" (which is always equal
to "2" in this case) from that message.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
git-rebase--merge.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
index 705d2f5..4ea3ca7 100644
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -78,7 +78,7 @@ call_merge () {
die "$RESOLVEMSG"
;;
2)
- echo "Strategy: $rv $strategy failed, try another" 1>&2
+ echo "Strategy: $strategy failed, try another" 1>&2
die "$RESOLVEMSG"
;;
*)
--
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
* [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
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