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 <seanp...@chromium.org>
---
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
+               export -f get_committer_email insert_extracted_tags
+               insert_extracted_tags $file >/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
-- 
2.12.2.715.g7642488e1d-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to