summaryrefslogtreecommitdiff
path: root/git-commit.sh
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2007-07-06 14:42:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-07-09 01:24:19 (GMT)
commita7342913e21a96597f38ce0b48e3093c9739df1f (patch)
tree8d15c0a1a0d14f6099a0815cab121f86f1c72158 /git-commit.sh
parent4017761fd89060f2b57d7799f6bbda8b3568d3d4 (diff)
downloadgit-a7342913e21a96597f38ce0b48e3093c9739df1f.zip
git-a7342913e21a96597f38ce0b48e3093c9739df1f.tar.gz
git-a7342913e21a96597f38ce0b48e3093c9739df1f.tar.bz2
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>
Diffstat (limited to 'git-commit.sh')
-rwxr-xr-xgit-commit.sh20
1 files changed, 11 insertions, 9 deletions
diff --git a/git-commit.sh b/git-commit.sh
index 9106a74..f3cd8ee 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -458,16 +458,18 @@ fi | git stripspace >"$GIT_DIR"/COMMIT_EDITMSG
case "$signoff" in
t)
- need_blank_before_signoff=
+ sign=$(git-var GIT_COMMITTER_IDENT | sed -e '
+ s/>.*/>/
+ s/^/Signed-off-by: /
+ ')
+ blank_before_signoff=
tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
- grep 'Signed-off-by:' >/dev/null || need_blank_before_signoff=yes
- {
- test -z "$need_blank_before_signoff" || echo
- git-var GIT_COMMITTER_IDENT | sed -e '
- s/>.*/>/
- s/^/Signed-off-by: /
- '
- } >>"$GIT_DIR"/COMMIT_EDITMSG
+ grep 'Signed-off-by:' >/dev/null || blank_before_signoff='
+'
+ tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
+ grep "$sign"$ >/dev/null ||
+ printf '%s%s\n' "$blank_before_signoff" "$sign" \
+ >>"$GIT_DIR"/COMMIT_EDITMSG
;;
esac