diff options
author | Shawn O. Pearce <sop@google.com> | 2009-08-22 19:08:10 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-08-22 19:08:10 -0700 |
commit | e92b2a7ef6ddfe59625dc689bb62ca69bda0c337 (patch) | |
tree | ae8ca31a87e3da798ce7de48e128080653ff2c0a | |
parent | 32b13fb15a4bd8378a4640210e041ef7668459fb (diff) |
Fix commit-msg hook to handle first lines like "foo: fix the bar"
Because we allowed the file to be split on the very first line, we
became confused on subject lines like "foo: fix the bar", thinking
that the subject line itself was the start of the footers. Instead
we start our search on the 2nd line, making it much less likely we
will run into problems splitting the message.
Change-Id: I99d9852bb2260ff018762c65a6585a5dd339b75d
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | src/main/java/com/google/gerrit/server/ssh/scproot/hooks/commit-msg | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/google/gerrit/server/ssh/scproot/hooks/commit-msg b/src/main/java/com/google/gerrit/server/ssh/scproot/hooks/commit-msg index ecd6a20b21..1ff228cc10 100644 --- a/src/main/java/com/google/gerrit/server/ssh/scproot/hooks/commit-msg +++ b/src/main/java/com/google/gerrit/server/ssh/scproot/hooks/commit-msg @@ -13,8 +13,12 @@ add_ChangeId() { id=$(_gen_ChangeId) out="$MSG.new" ftt="$MSG.footers" - sed -e '/^[A-Za-z][A-Za-z0-9-]*: /,$d' <"$MSG" >"$out" - sed -ne '/^[A-Za-z][A-Za-z0-9-]*: /,$p' <"$MSG" >"$ftt" + sed -e '2,${ + /^[A-Za-z][A-Za-z0-9-]*: /,$d + }' <"$MSG" >"$out" + sed -ne '2,${ + /^[A-Za-z][A-Za-z0-9-]*: /,$p + }' <"$MSG" >"$ftt" if ! [ -s "$ftt" ] then echo >>"$out" |