All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction
@ 2012-09-18 11:15 Johannes Sixt
  2012-09-18 11:20 ` Matthieu Moy
  2012-09-18 20:29 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Sixt @ 2012-09-18 11:15 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List

From: Johannes Sixt <j6t@kdbg.org>

When the todo sheet of interactive rebase instructs to run a non-existing
command, the operation stops with the following error:

  Execution failed: no-such
  You can fix the problem, and then run

          git rebase --continue

  fatal: 'rebase' appears to be a git command, but we were not
  able to execute it. Maybe git-rebase is broken?

The reason is that the shell that attempted to run the command exits with
code 127. rebase--interactive just forwards this code to the caller (the
git wrapper). But our smart run-command infrastructure detects this
special exit code and turns it into ENOENT, which in turn is interpreted
by the git wrapper as if the external command that it just executed did
not exist. This is finally translated to the misleading last two lines in
error message cited above.

Fix it by translating the error code before it is forwarded.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 An alternative fix would be to just ignore the shell's status code.
 I decided that it is worth keeping it: better safe than sorry.

 BTW, the problem existed since day 1 of the 'exec' feature.

 git-rebase--interactive.sh    |  4 ++++
 t/t3404-rebase-interactive.sh | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a09e842..56707d7 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -544,6 +544,10 @@ do_next () {
 			warn
 			warn "	git rebase --continue"
 			warn
+			if test $status -eq 127		# command not found
+			then
+				status=1
+			fi
 			exit "$status"
 		elif test "$dirty" = t
 		then
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 7304b66..7a71760 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -118,6 +118,17 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
 	git rebase --continue
 '
 
+test_expect_success 'rebase -i with exec of inexistent command' '
+	git checkout master &&
+	test_when_finished "git rebase --abort" &&
+	(
+	FAKE_LINES="exec_this-command-does-not-exist 1" &&
+	export FAKE_LINES &&
+	test_must_fail git rebase -i HEAD^ >actual 2>&1
+	) &&
+	! grep "Maybe git-rebase is broken" actual
+'
+
 test_expect_success 'no changes are a nop' '
 	git checkout branch2 &&
 	git rebase -i F &&
-- 
1.7.12.1720.gb55457a.dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction
  2012-09-18 11:15 [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction Johannes Sixt
@ 2012-09-18 11:20 ` Matthieu Moy
  2012-09-18 11:29   ` Johannes Sixt
  2012-09-18 20:29 ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2012-09-18 11:20 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List

Johannes Sixt <j.sixt@viscovery.net> writes:

> From: Johannes Sixt <j6t@kdbg.org>
>
> When the todo sheet of interactive rebase instructs to run a non-existing
> command, the operation stops with the following error:
>
>   Execution failed: no-such
>   You can fix the problem, and then run
>
>           git rebase --continue
>
>   fatal: 'rebase' appears to be a git command, but we were not
>   able to execute it. Maybe git-rebase is broken?

While you're there, maybe you want to turn the first line into

Execution failed: no-such (command not found)

In any case, the patch sounds good, thanks.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction
  2012-09-18 11:20 ` Matthieu Moy
@ 2012-09-18 11:29   ` Johannes Sixt
  2012-09-18 11:38     ` Matthieu Moy
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2012-09-18 11:29 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List

Am 9/18/2012 13:20, schrieb Matthieu Moy:
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> From: Johannes Sixt <j6t@kdbg.org>
>>
>> When the todo sheet of interactive rebase instructs to run a non-existing
>> command, the operation stops with the following error:
>>
>>   Execution failed: no-such
>>   You can fix the problem, and then run
>>
>>           git rebase --continue
>>
>>   fatal: 'rebase' appears to be a git command, but we were not
>>   able to execute it. Maybe git-rebase is broken?
> 
> While you're there, maybe you want to turn the first line into
> 
> Execution failed: no-such (command not found)

No, I don't want to: Neither do we have errno here, nor can we be specific
enough because the whole shell script the user gave after 'exec' is
repeated here.

I would rather remove the line so that it does not distract from the more
specific error message that the shell gave. On top of that, the command is
already dumped before it is executed; we don't need to repeat it.

-- Hannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction
  2012-09-18 11:29   ` Johannes Sixt
@ 2012-09-18 11:38     ` Matthieu Moy
  0 siblings, 0 replies; 5+ messages in thread
From: Matthieu Moy @ 2012-09-18 11:38 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List

Johannes Sixt <j.sixt@viscovery.net> writes:

> Am 9/18/2012 13:20, schrieb Matthieu Moy:
>> Johannes Sixt <j.sixt@viscovery.net> writes:
>> 
>>> From: Johannes Sixt <j6t@kdbg.org>
>>>
>>> When the todo sheet of interactive rebase instructs to run a non-existing
>>> command, the operation stops with the following error:
>>>
>>>   Execution failed: no-such
>>>   You can fix the problem, and then run
>>>
>>>           git rebase --continue
>>>
>>>   fatal: 'rebase' appears to be a git command, but we were not
>>>   able to execute it. Maybe git-rebase is broken?
>> 
>> While you're there, maybe you want to turn the first line into
>> 
>> Execution failed: no-such (command not found)
>
> No, I don't want to: Neither do we have errno here, nor can we be specific
> enough because the whole shell script the user gave after 'exec' is
> repeated here.
>
> I would rather remove the line so that it does not distract from the more
> specific error message that the shell gave. On top of that, the command is
> already dumped before it is executed; we don't need to repeat it.

Not sure what you mean: remove the line in case $status = 127, or remove
it anyway.

If you mean only when $status = 127, then that is indeed a good idea, as
the full error message looks like

  Executing: nosuchcommand
  zsh:1: command not found: nosuchcommand
  Execution failed: nosuchcommand
  You can fix the problem, and then run [...]

So, yes, the shell's error message is enough and more precise than we
could do in git rebase.

If you mean remove it in any case, I disagree: repeating the command is
usually not very useful, but may help when the command itself produced a
lot of output (e.g. "exec make test" oftens fills-in your terminal's
buffer). And the information that the command fails can be important if
the command failed silently, e.g. with "exec false":

  Executing: false
  Execution failed: false
  You can fix the problem, and then run [...]

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction
  2012-09-18 11:15 [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction Johannes Sixt
  2012-09-18 11:20 ` Matthieu Moy
@ 2012-09-18 20:29 ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2012-09-18 20:29 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Matthieu Moy, Git Mailing List

Johannes Sixt <j.sixt@viscovery.net> writes:

> From: Johannes Sixt <j6t@kdbg.org>
>
> When the todo sheet of interactive rebase instructs to run a non-existing
> command, the operation stops with the following error:
>
>   Execution failed: no-such
>   You can fix the problem, and then run
>
>           git rebase --continue
>
>   fatal: 'rebase' appears to be a git command, but we were not
>   able to execute it. Maybe git-rebase is broken?
>
> The reason is that the shell that attempted to run the command exits with
> code 127. rebase--interactive just forwards this code to the caller (the
> git wrapper). But our smart run-command infrastructure detects this
> special exit code and turns it into ENOENT, which in turn is interpreted
> by the git wrapper as if the external command that it just executed did
> not exist.

That's a funny one ;-)
Will queue.  Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-18 20:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18 11:15 [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction Johannes Sixt
2012-09-18 11:20 ` Matthieu Moy
2012-09-18 11:29   ` Johannes Sixt
2012-09-18 11:38     ` Matthieu Moy
2012-09-18 20:29 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.