diff options
author | Luke Diamand <luke@diamand.org> | 2011-05-13 20:46:00 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-13 12:59:13 -0700 |
commit | 848de9c3831f7e476ea58e3ee426aa63fb8f6870 (patch) | |
tree | c6d80ef1b5068833d20a1232a5e274d1578bfd34 /t/t9800-git-p4.sh | |
parent | ecdba36da6143bc00ade66b655bcff910f3e93b3 (diff) | |
download | git-848de9c3831f7e476ea58e3ee426aa63fb8f6870.tar.gz |
git-p4: warn if git authorship won't be retained
If the git commits you are submitting contain changes made by
other people, the authorship will not be retained. Change git-p4
to warn of this and to note that --preserve-user can be used
to solve the problem (if you have suitable permissions).
The warning can be disabled.
Add a test case and update documentation.
Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9800-git-p4.sh')
-rwxr-xr-x | t/t9800-git-p4.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index 4fb0e24f8f..33b0127651 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -160,6 +160,13 @@ p4_check_commit_author() { fi } +make_change_by_user() { + file=$1 name=$2 email=$3 && + echo "username: a change by $name" >>"$file" && + git add "$file" && + git commit --author "$name <$email>" -m "a change by $name" +} + # Test username support, submitting as user 'alice' test_expect_success 'preserve users' ' p4_add_user alice Alice && @@ -213,6 +220,40 @@ test_expect_success 'preserve user where author is unknown to p4' ' rm -rf "$git" && mkdir "$git" ' +# If we're *not* using --preserve-user, git-p4 should warn if we're submitting +# changes that are not all ours. +# Test: user in p4 and user unknown to p4. +# Test: warning disabled and user is the same. +test_expect_success 'not preserving user with mixed authorship' ' + "$GITP4" clone --dest="$git" //depot && + ( + cd "$git" && + git config git-p4.skipSubmitEditCheck true && + p4_add_user derek Derek && + + make_change_by_user usernamefile3 Derek derek@localhost && + P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual && + grep "git author derek@localhost does not match" actual && + + make_change_by_user usernamefile3 Charlie charlie@localhost && + P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual && + grep "git author charlie@localhost does not match" actual && + + make_change_by_user usernamefile3 alice alice@localhost && + P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual && + ! grep "git author.*does not match" actual && + + git config git-p4.skipUserNameCheck true && + make_change_by_user usernamefile3 Charlie charlie@localhost && + P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual && + ! grep "git author.*does not match" actual && + + p4_check_commit_author usernamefile3 alice + ) && + rm -rf "$git" && mkdir "$git" +' + + test_expect_success 'shutdown' ' pid=`pgrep -f p4d` && test -n "$pid" && |