* [PATCH] rebase: do not fail silently when the HEAD could not be detached
[not found] <cover.1234027102u.git.johannes.schindelin@gmx.de>
@ 2009-02-07 17:20 ` Johannes Schindelin
2009-02-07 21:45 ` Junio C Hamano
2009-02-07 23:35 ` Björn Steinbrink
0 siblings, 2 replies; 5+ messages in thread
From: Johannes Schindelin @ 2009-02-07 17:20 UTC (permalink / raw)
To: git, gitster
Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a
detached HEAD. However, it used "checkout -q" to detach the HEAD, which
hid an error message when, say, an untracked file would have to be
overwritten to detach the HEAD.
Instead of hiding the output of the checkout in all cases, only hide it
when no error occurred.
While at it, add a test that "rebase" actually operated on a detached
HEAD.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
git-rebase.sh | 2 +-
t/t3400-rebase.sh | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 6d3eddb..1526fcb 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -434,7 +434,7 @@ fi
# Detach HEAD and reset the tree
echo "First, rewinding head to replay your work on top of it..."
-git checkout -q "$onto^0" || die "could not detach HEAD"
+error=$(git checkout "$onto" 2>&1) || die "${error}could not detach HEAD"
git update-ref ORIG_HEAD $branch
# If the $onto is a proper descendant of the tip of the branch, then
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index b7a670e..8c0c5f5 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -14,7 +14,8 @@ export GIT_AUTHOR_EMAIL
test_expect_success \
'prepare repository with topic branches' \
- 'echo First > A &&
+ 'git config core.logAllRefUpdates true &&
+ echo First > A &&
git update-index --add A &&
git commit -m "Add A." &&
git checkout -b my-topic-branch &&
@@ -84,4 +85,14 @@ test_expect_success 'rebase a single mode change' '
GIT_TRACE=1 git rebase master
'
+test_expect_success 'HEAD was detached during rebase' '
+ test $(git rev-parse HEAD@{1}) != $(git rev-parse modechange@{1})
+'
+
+test_expect_success 'Show verbose error when HEAD could not be detached' '
+ : > B &&
+ test_must_fail git rebase topic 2> output.err > output.out &&
+ grep "Untracked working tree file .B. would be overwritten" output.err
+'
+
test_done
--
1.6.1.2.655.g3f285
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached
2009-02-07 17:20 ` [PATCH] rebase: do not fail silently when the HEAD could not be detached Johannes Schindelin
@ 2009-02-07 21:45 ` Junio C Hamano
2009-02-07 23:35 ` Björn Steinbrink
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2009-02-07 21:45 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Sounds sensible to be in 1.6.2.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached
2009-02-07 17:20 ` [PATCH] rebase: do not fail silently when the HEAD could not be detached Johannes Schindelin
2009-02-07 21:45 ` Junio C Hamano
@ 2009-02-07 23:35 ` Björn Steinbrink
2009-02-08 2:26 ` Junio C Hamano
1 sibling, 1 reply; 5+ messages in thread
From: Björn Steinbrink @ 2009-02-07 23:35 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster
On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:
> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a
> detached HEAD. However, it used "checkout -q" to detach the HEAD, which
> hid an error message when, say, an untracked file would have to be
> overwritten to detach the HEAD.
Hm, in 324c2c317 "git-rebase: report checkout failure", that was
switched from a stdout/stderr redirect to -q, so that those error
messages are shown. And with a quick test, rebase/checkout complains
just fine:
doener@atjola:g (master) $ git checkout -q bar
error: Untracked working tree file 'file' would be overwritten by merge.
doener@atjola:g (master) $ git rebase bar
First, rewinding head to replay your work on top of it...
error: Untracked working tree file 'file' would be overwritten by merge.
could not detach HEAD
doener@atjola:g (master) $ git --version
git version 1.6.2.rc0
Same with next and pu.
Björn
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached
2009-02-07 23:35 ` Björn Steinbrink
@ 2009-02-08 2:26 ` Junio C Hamano
2009-02-08 10:27 ` Johannes Schindelin
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2009-02-08 2:26 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Johannes Schindelin, git
Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:
>> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a
>> detached HEAD. However, it used "checkout -q" to detach the HEAD, which
>> hid an error message when, say, an untracked file would have to be
>> overwritten to detach the HEAD.
>
> Hm, in 324c2c317 "git-rebase: report checkout failure", that was
> switched from a stdout/stderr redirect to -q, so that those error
> messages are shown. And with a quick test, rebase/checkout complains
> just fine:
Very interesting.
Dscho, how did you get the "important part of error information is hidden"
failure that led to this patch? Did it come from code inspection and
speculation alone, or was there an actual failure case?
If I apply the patch t/t3400-rebase.sh from your message alone to
'master', it does seem to pass.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached
2009-02-08 2:26 ` Junio C Hamano
@ 2009-02-08 10:27 ` Johannes Schindelin
0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2009-02-08 10:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Steinbrink, git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1271 bytes --]
Hi,
On Sat, 7 Feb 2009, Junio C Hamano wrote:
> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
>
> > On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:
> >> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a
> >> detached HEAD. However, it used "checkout -q" to detach the HEAD, which
> >> hid an error message when, say, an untracked file would have to be
> >> overwritten to detach the HEAD.
> >
> > Hm, in 324c2c317 "git-rebase: report checkout failure", that was
> > switched from a stdout/stderr redirect to -q, so that those error
> > messages are shown. And with a quick test, rebase/checkout complains
> > just fine:
>
> Very interesting.
>
> Dscho, how did you get the "important part of error information is hidden"
> failure that led to this patch? Did it come from code inspection and
> speculation alone, or was there an actual failure case?
Hmm, sorry, I thought I got this with "my" Git, but it appears that due to
some strange reason I do not understand completely, I was not actually
using the Git binary from $HOME/bin/, but /usr/bin/.
> If I apply the patch t/t3400-rebase.sh from your message alone to
> 'master', it does seem to pass.
Well, please ignore the patch, then. Or take the test alone.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-08 10:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1234027102u.git.johannes.schindelin@gmx.de>
2009-02-07 17:20 ` [PATCH] rebase: do not fail silently when the HEAD could not be detached Johannes Schindelin
2009-02-07 21:45 ` Junio C Hamano
2009-02-07 23:35 ` Björn Steinbrink
2009-02-08 2:26 ` Junio C Hamano
2009-02-08 10:27 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).