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).


  git --version
    git version 1.9.0.rc3.21.g475c52b

  mkdir test && cd test && git init

  cat >.git/hooks/applypatch-msg <<EOF
  grep -q "foo" "\$1" && echo "Rejecting patch message" && exit 1
  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
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to