git-gui: Teach sign off to be more intelligent.
authorShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 01:44:03 +0000 (20:44 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 05:16:03 +0000 (00:16 -0500)
When we sign off on a commit we want to add a blank line between
whatever is in the commit buffer and the new Signed-off-by line,
unless there already is a Signed-off-by (or Acked-by) tag at the end
of the buffer already.  This change makes us do the right thing more
often.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui

diff --git a/git-gui b/git-gui
index 9a259c0dcbfa66a5addc71f586a7e7a3978665e7..8a42c97cb186283086b2455e6e199379ef6626b5 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -1510,10 +1510,15 @@ proc do_signoff {} {
                }
        }
 
-       set str "Signed-off-by: $GIT_COMMITTER_IDENT"
-       if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
+       set sob "Signed-off-by: $GIT_COMMITTER_IDENT"
+       set last [$ui_comm get {end -1c linestart} {end -1c}]
+       if {$last != $sob} {
                $ui_comm edit separator
-               $ui_comm insert end "\n$str"
+               if {$last != {}
+                       && ![regexp {^[A-Z][A-Za-z]*-[A-Za-z-]+: *} $last]} {
+                       $ui_comm insert end "\n"
+               }
+               $ui_comm insert end "\n$sob"
                $ui_comm edit separator
                $ui_comm see end
        }