diff options
author | Josh Triplett <josh@joshtriplett.org> | 2013-10-27 01:34:02 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-10-30 11:32:10 -0700 |
commit | 517fcac36fdc59cd9fa1e67212cd9b49d5fda475 (patch) | |
tree | 4cc4e48b586c489ab3910a4e4e2bd4ae7a565a38 /t | |
parent | 0d6cf2471f426dd2b742e2285aad78381738be96 (diff) | |
download | git-jt/commit-fixes-footer.tar.gz |
commit: Add -f, --fixes <commit> option to add Fixes: linejt/commit-fixes-footer
Linux Kernel Summit 2013 decided on a commit message convention to
identify commits containing bugs fixed by a commit: a "Fixes:" line,
included in the standard commit footer (along with "Signed-off-by:" if
present), containing an abbreviated commit hash (at least 12 characters
to keep it valid for a long time) and the subject of the commit (for
human readers). This helps people (or automated tools) determine how
far to backport a commit.
Add a command line option for git commit to automatically construct the
"Fixes:" line for a commit. This avoids the need to manually construct
that line by copy-pasting the commit hash and subject.
Also works with --amend to modify an existing commit's message. To add
a Fixes line to an earlier commit in a series, use rebase -i and add the
following line after the existing commit:
x git commit --amend --no-edit --fixes $commit_containing_bug
Generalize append_signoff to support appending arbitrary extra lines to
a commit in the signoff block; this avoids duplicating the logic to find
or construct that block.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7502-commit.sh | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 6313da2cdd..d00f2f1cb1 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -137,13 +137,48 @@ test_expect_success 'partial removal' ' ' +signoff_ident () { + git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/" +} + test_expect_success 'sign off' ' >positive && git add positive && git commit -s -m "thank you" && actual=$(git cat-file commit HEAD | sed -ne "s/Signed-off-by: //p") && - expected=$(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") && + expected=$(signoff_ident) && + test "z$actual" = "z$expected" + +' + +fixes_for_commits () { + git -c core.abbrev=12 show -s --format="Fixes: %h (%s)" "$@" +} + +test_expect_success '--fixes' ' + + echo >>positive && + git add positive && + git commit --fixes HEAD -m "fix bug" && + actual=$(git cat-file commit HEAD | sed -e "1,/^\$/d") && + expected=$(echo fix bug; echo; fixes_for_commits HEAD^) && + test "z$actual" = "z$expected" + +' + +test_expect_success 'multiple --fixes with signoff' ' + + echo >>positive && + git add positive && + git commit --fixes HEAD^ --fixes HEAD -s -m "signed bugfix" && + actual=$(git cat-file commit HEAD | sed -e "1,/^\$/d") && + expected=$( + echo signed bugfix + echo + echo "Signed-off-by: $(signoff_ident)" + fixes_for_commits HEAD^^ HEAD^ + ) && test "z$actual" = "z$expected" ' |