* [BUGLET] resuming git am when using applypatch-msg hook
@ 2014-03-02 22:30 Chris Packham
0 siblings, 0 replies; only message in thread
From: Chris Packham @ 2014-03-02 22:30 UTC (permalink / raw
To: GIT
Hi,
I don't know if this really counts as a bug but it is a little
annoying from a user experience point of view.
We're using an applypatch-msg hook to check that certain things
(reviewer, bug entry etc) are recorded correctly in commit messages.
My expectation is that if our applypatch-msg hook rejects a patch then
we should be able to invoke 'git am -i --continue' edit the message to
fixup the content and resume applying. However it seems even though I
can invoke 'git am -i --continue' to edit the message, the actual
patch contents are lost.
I'm guessing the problem is that the applypatch-msg hook is invoked
after the message part is saved but before the patch part is saved.
Alternatively the "problem" could be that I'm using a hook that is not
intended for this purpose, however the man page does say
"[applypatch-msg] can also be used to refuse the commit after
inspecting the message file".
Below is an example of this (if anyone has an idea on how to automate
the 'git am -i' part I'll be able to turn this into a proper test).
Thanks,
Chris
--
git --version
git version 1.9.0.rc3.21.g475c52b
mkdir test && cd test && git init
cat >.git/hooks/applypatch-msg <<EOF
#!/bin/sh
grep -q "foo" "\$1" && echo "Rejecting patch message" && exit 1
EOF
chmod +x .git/hooks/applypatch-msg
echo "hello world" > a.txt && git add a.txt && git commit -m "Initial commit"
git checkout -b temp
echo "Hello world!" > a.txt && git add a.txt && git commit -m "foo:
update text"
git checkout master
git format-patch temp -1 --stdout | git am
Rejecting patch message
GIT_EDITOR="sed -i 's/foo: //'" git am -i --continue
Commit Body is:
--------------------------
foo: update text
--------------------------
Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all e
Commit Body is:
--------------------------
update text
--------------------------
Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all y
git status
On branch master
You are in the middle of an am session.
The current patch is empty.
(use "git am --skip" to skip this patch)
(use "git am --abort" to restore the original branch)
stat -c"%s" .git/rebase-apply/patch
0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-03-02 22:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-02 22:30 [BUGLET] resuming git am when using applypatch-msg hook Chris Packham
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).