* [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure
@ 2024-07-11 13:25 Anthony Loiseau
2024-07-11 13:25 ` Anthony Loiseau
2024-07-11 17:15 ` Eric Sunshine
0 siblings, 2 replies; 4+ messages in thread
From: Anthony Loiseau @ 2024-07-11 13:25 UTC (permalink / raw)
To: git
Cc: Anthony Loiseau, Junio C Hamano, Pat Thoyts, Joshua Williams,
Shawn O . Pearce
Targeted issue
==============
git-gui is currently unusable when prepare-commit-msg hook fails, since
it closes as soon as user dismiss modal error popup shown on start.
Proposal
========
Next mail is a proposal to make this failure non-fatal. Popup is still
shown but not in its fatal variant (which removes the "you must fix this
before commiting" unwanted sentence), and git-gui is not terminated upon
popup dismiss.
With this proposal, user is clearly aware of a prepare-commit-msg hook
failure but is not denied to use git-gui and can even commit.
Pre-filled commit message content is likely empty or not filled in this
case, which is not a big issue.
Other hooks are not affected. commit-msg hook and next ones are still
triggered upon commit action, telling commit can not be performed (fatal
variant of the popup) without terminating git-gui upon dismiss.
How to test
===========
cat > .git/hooks/fake_failing_hook <<EOF
#!/bin/sh
echo 'FAKE FAILING HOOK $0' >&2
exit 1
EOF
for i in .git/hooks/*.sample
do
ln -svf fake_failing_hook "${i%%.sample}"
done
chmod u+x .git/hooks/*
rm .git/GITGUI_MSG
git gui
Anthony Loiseau (1):
git-gui: do not exit upon prepare-commit-msg hook failure
git-gui/git-gui.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure
2024-07-11 13:25 [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure Anthony Loiseau
@ 2024-07-11 13:25 ` Anthony Loiseau
2024-07-13 20:50 ` Johannes Sixt
2024-07-11 17:15 ` Eric Sunshine
1 sibling, 1 reply; 4+ messages in thread
From: Anthony Loiseau @ 2024-07-11 13:25 UTC (permalink / raw)
To: git
Cc: Anthony Loiseau, Junio C Hamano, Pat Thoyts, Joshua Williams,
Shawn O . Pearce
prepare-commit-msg hook is fired as soon git-gui is started
and upon F5 in order to pre-fill commit message area.
Having it fatal, forcibly exiting app when this hook fails
rendered git-gui unusable in this case. Fix this by not
treating this hook as fatal, and not exiting app when failure
popup is dismissed.
This way, user can use git-gui when he/she dismisses failure popup
of a failed prepare-commit-msg hook.
Note that this commit does not deny user from commiting when
prepare-commit-msg failed. Message is simply not pre-filled.
Signed-off-by: Anthony Loiseau <anthony@loiseau.fr>
---
git-gui/git-gui.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 8fe7538e72..ab6caaf2ae 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1643,9 +1643,8 @@ proc prepare_commit_msg_hook_wait {fd_ph} {
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
ui_status [mc "Commit declined by prepare-commit-msg hook."]
- hook_failed_popup prepare-commit-msg $pch_error
+ hook_failed_popup prepare-commit-msg $pch_error 0
catch {file delete [gitdir PREPARE_COMMIT_MSG]}
- exit 1
} else {
load_message PREPARE_COMMIT_MSG
}
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure
2024-07-11 13:25 [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure Anthony Loiseau
2024-07-11 13:25 ` Anthony Loiseau
@ 2024-07-11 17:15 ` Eric Sunshine
1 sibling, 0 replies; 4+ messages in thread
From: Eric Sunshine @ 2024-07-11 17:15 UTC (permalink / raw)
To: Anthony Loiseau
Cc: git, Junio C Hamano, Pat Thoyts, Joshua Williams, Johannes Sixt
Adding the current git-gui maintainer[*] to Cc: list...
[*] https://lore.kernel.org/git/0241021e-0b17-4031-ad9f-8abe8e0c0097@kdbg.org/
On Thu, Jul 11, 2024 at 10:04 AM Anthony Loiseau <anthony@loiseau.fr> wrote:
>
> Targeted issue
> ==============
>
> git-gui is currently unusable when prepare-commit-msg hook fails, since
> it closes as soon as user dismiss modal error popup shown on start.
>
> Proposal
> ========
>
> Next mail is a proposal to make this failure non-fatal. Popup is still
> shown but not in its fatal variant (which removes the "you must fix this
> before commiting" unwanted sentence), and git-gui is not terminated upon
> popup dismiss.
>
> With this proposal, user is clearly aware of a prepare-commit-msg hook
> failure but is not denied to use git-gui and can even commit.
> Pre-filled commit message content is likely empty or not filled in this
> case, which is not a big issue.
>
> Other hooks are not affected. commit-msg hook and next ones are still
> triggered upon commit action, telling commit can not be performed (fatal
> variant of the popup) without terminating git-gui upon dismiss.
>
> How to test
> ===========
>
> cat > .git/hooks/fake_failing_hook <<EOF
> #!/bin/sh
> echo 'FAKE FAILING HOOK $0' >&2
> exit 1
> EOF
>
> for i in .git/hooks/*.sample
> do
> ln -svf fake_failing_hook "${i%%.sample}"
> done
>
> chmod u+x .git/hooks/*
> rm .git/GITGUI_MSG
> git gui
>
>
> Anthony Loiseau (1):
> git-gui: do not exit upon prepare-commit-msg hook failure
>
> git-gui/git-gui.sh | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure
2024-07-11 13:25 ` Anthony Loiseau
@ 2024-07-13 20:50 ` Johannes Sixt
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Sixt @ 2024-07-13 20:50 UTC (permalink / raw)
To: Anthony Loiseau; +Cc: Junio C Hamano, Pat Thoyts, Joshua Williams, git
[j6t: removed Shawn from the Cc list]
Am 11.07.24 um 15:25 schrieb Anthony Loiseau:
> prepare-commit-msg hook is fired as soon git-gui is started
> and upon F5 in order to pre-fill commit message area.
>
> Having it fatal, forcibly exiting app when this hook fails
> rendered git-gui unusable in this case. Fix this by not
> treating this hook as fatal, and not exiting app when failure
> popup is dismissed.
It is understandable that a Git GUI that cannot be started looks like a
problem that needs solving. However, I am not happy with the proposed
solution.
The first reason is that even if Git GUI can now run, the error message
still reappears every time when Rescan (F5) is used and must be
dismissed each time. (The version of Git GUI that I use does a rescan on
window activation and now runs into rescan loop after the dismission; I
can't even exit Git GUI anymore.)
> This way, user can use git-gui when he/she dismisses failure popup
> of a failed prepare-commit-msg hook.
>
> Note that this commit does not deny user from commiting when
> prepare-commit-msg failed. Message is simply not pre-filled.
This is the second reason. As a first step, an attempt should be made to
fill the edit box with the unprocessed commit message.
I am unsure what next steps should be, though.
- Should we not allow to make a commit?
- Should we allow to edit the message and then permit a commit?
I can't tell, because I do not know for what purposes people use the
prepare-commit-msg hook.
Without these two points addressed, I consider it better that Git GUI
does not even start or exits.
>
> Signed-off-by: Anthony Loiseau <anthony@loiseau.fr>
> ---
> git-gui/git-gui.sh | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 8fe7538e72..ab6caaf2ae 100755
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -1643,9 +1643,8 @@ proc prepare_commit_msg_hook_wait {fd_ph} {
> if {[eof $fd_ph]} {
> if {[catch {close $fd_ph}]} {
> ui_status [mc "Commit declined by prepare-commit-msg hook."]
> - hook_failed_popup prepare-commit-msg $pch_error
> + hook_failed_popup prepare-commit-msg $pch_error 0
> catch {file delete [gitdir PREPARE_COMMIT_MSG]}
> - exit 1
> } else {
> load_message PREPARE_COMMIT_MSG
> }
Below this context is the same catch {file delete ...}. Since it is now
reached, the instance in the if-branch should be removed.
-- Hannes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-13 20:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-11 13:25 [PATCH] git-gui: do not exit upon prepare-commit-msg hook failure Anthony Loiseau
2024-07-11 13:25 ` Anthony Loiseau
2024-07-13 20:50 ` Johannes Sixt
2024-07-11 17:15 ` Eric Sunshine
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).