From patchwork Mon Apr 3 21:10:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9660609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FE816032D for ; Mon, 3 Apr 2017 21:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62383205A4 for ; Mon, 3 Apr 2017 21:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 559D12847B; Mon, 3 Apr 2017 21:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7559205A4 for ; Mon, 3 Apr 2017 21:10:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E6B66E43F; Mon, 3 Apr 2017 21:10:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qt0-x22b.google.com (mail-qt0-x22b.google.com [IPv6:2607:f8b0:400d:c0d::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73AB26E43F for ; Mon, 3 Apr 2017 21:10:19 +0000 (UTC) Received: by mail-qt0-x22b.google.com with SMTP id x35so123590172qtc.2 for ; Mon, 03 Apr 2017 14:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f+jupB4NXQV/Art1knUYVrCzEXwF3ThXOtMN+KC2M9w=; b=mUdhxK3KijCZSbKWgxmBZNnRZwVTMhZPed74667qR12UGS8/+k3hhKyCsidDmEkEPO ZNlVrItmujoel8LfCzPIKAbNaQqsXeCqw8jvBmYXibRyyTnZSBj5Hxf30wc03ZYc5IpV JjT0LrvbY1Owr7IldbF98KzMPaC6nXkhqhaQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f+jupB4NXQV/Art1knUYVrCzEXwF3ThXOtMN+KC2M9w=; b=Wjrz4ayu45hesVs5GZa6PBwRppwlJ5kgf3Jdn3cZrJ74A9r+Q0GCbOYAhdAEcmQes6 Bwz9zBNN/p/JWOiBnfJRbO3qy70tURoWvKDMT8GIC33FPjFha+pAivaUB6zGcCpTfhF/ A/YeH0bc92j7y3zcr7IRzOoKQSvQwPpA5DJgkGcNwNUERDDEBEw8DaPmRSwtadhkxOk/ fPoNqYU67w0UogSfoweWyJtCMPmGIKAXIA/8c6KU8bxuiX2bC1zFMP1z0O/jL9d23x8f 4V0v9RG9FdoKTYnSlWWHzP3RMLhoynCGdYAr784YZIFeuBZpD3eCt0pTGtejGu2E2zhl aIzg== X-Gm-Message-State: AFeK/H0/uiv5UgwzaWdAYp+q2pPWrcmBhWYP+vSUSDHr4LD8cuSHlWSvssfnvi0seDInZ8Fj X-Received: by 10.200.56.97 with SMTP id r30mr19106703qtb.229.1491253818546; Mon, 03 Apr 2017 14:10:18 -0700 (PDT) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id d23sm10403423qta.32.2017.04.03.14.10.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 14:10:17 -0700 (PDT) From: Sean Paul To: intel-gfx@lists.freedesktop.org, ville.syrjala@linux.intel.com, jani.nikula@linux.intel.com Date: Mon, 3 Apr 2017 17:10:11 -0400 Message-Id: <20170403211016.35047-1-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog In-Reply-To: <87shm3kt3s.fsf@intel.com> References: <87shm3kt3s.fsf@intel.com> Subject: [Intel-gfx] [maintainer-tools PATCH v2 2/2] dim: Curate and insert tags into patch(es) 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-Virus-Scanned: ClamAV using ClamSMTP Launch $EDITOR when extracting tags to curate the tags immediately. Once the tags are proper, automatically add them before the first Signed-off-by line to all patches in the range. Signed-off-by: Sean Paul --- Changes in v2: - Append the tags before the committer's SoB (Ville) - Make launching $EDITOR contingent on -i flag (Ville/Jani) - Fix tty issues when launching editor dim | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/dim b/dim index 334882b..8b9a876 100755 --- a/dim +++ b/dim @@ -670,13 +670,23 @@ function dim_push_fixes dim_push_branch drm-intel-fixes "$@" } +function get_committer_email +{ + local committer_email + + if ! committer_email=$(git config --get user.email) ; then + committer_email=$EMAIL + fi + echo -n $committer_email +} + # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. dim_alias_ab=apply-branch dim_alias_sob=apply-branch function dim_apply_branch { - local branch file message_id commiter_email patch_from sob rv + local branch file message_id committer_email patch_from sob rv branch=${1:?$usage} shift @@ -688,13 +698,10 @@ function dim_apply_branch cat > $file message_id=$(message_get_id $file) - - if ! commiter_email=$(git config --get user.email) ; then - commiter_email=$EMAIL - fi + committer_email=$(get_committer_email) patch_from=$(grep "From:" "$file" | head -1) - if [[ "$patch_from" != *"$commiter_email"* ]] ; then + if [[ "$patch_from" != *"$committer_email"* ]] ; then sob=-s fi @@ -1156,6 +1163,15 @@ function rangeish() fi } +function insert_extracted_tags +{ + local committer_email new_tags sob + committer_email=$(get_committer_email) + new_tags=$(awk '{ORS="\\\\n"} {print $0}' $1 | head -c-3) + sob="Signed-off-by: .*<$committer_email>" + awk "/$sob/{p++} p==1{print \"$new_tags\"; p++} p!=1{print}" +} + function dim_extract_tags { local branch range file tags @@ -1177,9 +1193,19 @@ function dim_extract_tags return 0 fi - tags=$(printf -- "# *** extracted tags ***\n%s" "$tags") - - git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range + # If interactive is selected, launch an editor to allow tag editing + # If it's not, just append the tags at the bottom of the commit + if [ "$INTERACTIVE" ]; then + echo "$tags" > $file + ${EDITOR:-vi} $file >/dev/tty/dev/tty + cmd="insert_extracted_tags $file" + else + tags=$(printf -- "# *** extracted tags ***\n%s" "$tags") + cmd="cat ; echo \"$tags\"" + fi + git filter-branch -f --msg-filter "$cmd" $range } function dim_extract_queued