@matheusbsbs / matheus-bagliano / commits / a7342913e2
Fork 0

git-commit: don't add multiple Signed-off-by: from the same identity

If requested to signoff a commit, don't add another Signed-off-by: line to the commit message if the exact same line is already there. This was noticed and requested by Josh Triplett through http://bugs.debian.org/430851 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Gerrit Pape committed Jul 6, 2007 at 14:42 UTC a7342913e21a96597f38ce0b48e3093c9739df1f
1 file changed +11 -9
git-commit.sh
+11 -9
@@ -458,16 +458,18 @@ fi | git stripspace >"$GIT_DIR"/COMMIT_EDITMSG
458
459 case "$signoff" in
460 t)
461 - need_blank_before_signoff=
461 + sign=$(git-var GIT_COMMITTER_IDENT | sed -e '
462 + s/>.*/>/
463 + s/^/Signed-off-by: /
464 + ')
465 + blank_before_signoff=
466 tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
463 - grep 'Signed-off-by:' >/dev/null || need_blank_before_signoff=yes
464 - {
465 - test -z "$need_blank_before_signoff" || echo
466 - git-var GIT_COMMITTER_IDENT | sed -e '
467 - s/>.*/>/
468 - s/^/Signed-off-by: /
469 - '
470 - } >>"$GIT_DIR"/COMMIT_EDITMSG
467 + grep 'Signed-off-by:' >/dev/null || blank_before_signoff='
468 +'
469 + tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
470 + grep "$sign"$ >/dev/null ||
471 + printf '%s%s\n' "$blank_before_signoff" "$sign" \
472 + >>"$GIT_DIR"/COMMIT_EDITMSG
473 ;;
474 esac
475