From patchwork Thu Oct 29 13:58:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 7519251 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5938A9F37F for ; Thu, 29 Oct 2015 13:54:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9058F208E3 for ; Thu, 29 Oct 2015 13:54:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 92BA02088E for ; Thu, 29 Oct 2015 13:54:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D6D7E6EC11; Thu, 29 Oct 2015 06:54:42 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 38E676EC11 for ; Thu, 29 Oct 2015 06:54:41 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 29 Oct 2015 06:54:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,214,1444719600"; d="scan'208";a="838437114" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 29 Oct 2015 06:54:40 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Thu, 29 Oct 2015 15:58:34 +0200 Message-Id: <1446127114-4178-1-git-send-email-jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [maintainer-tools PATCH] dim: append commit message tags in git, not in files X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Email is hard. Let that sink in. The message piped to dim may have, among other things, base64 encoding, and using sed to modify the commit message directly on the input falls apart. This is also true for messages sent using git-send-email. Let 'git am' handle the hard part, and modify the commit message after the patch has been applied. The same holds for running checkpatch on the email message; it's doomed. We'll leave that for later. Signed-off-by: Jani Nikula --- dim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dim b/dim index cdb48b9f8976..db92c57d82aa 100755 --- a/dim +++ b/dim @@ -172,11 +172,15 @@ if message_id is not None: EOF } -# inject a new tag to a patch file -# $1 = file, $2 = tag, $3 = value -message_add_tag () +# append a new tag at the end of the commit message of HEAD +# $1 = tag, $2 = value +commit_add_tag () { - sed -ie "/^---$/ i\\$2: $3" $1 + # the first sed deletes all trailing blank lines at the end + git log -1 --pretty=%B | \ + sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' | \ + sed "\$a$1: $2" | \ + git commit --amend -F- } function update_linux_next @@ -370,13 +374,15 @@ function dim_apply cat > $file local message_id=$(message_get_id $file) - if [ -n $message_id ]; then - message_add_tag $file "Link" "http://patchwork.freedesktop.org/patch/msgid/$message_id" - fi dim_shell_checkpatch "cat $file" cat $file | git am -3 "$@" + + if [ -n $message_id ]; then + commit_add_tag "Link" "http://patchwork.freedesktop.org/patch/msgid/$message_id" + fi + git commit --amend & }