Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git duet-commit --amend with ROTATE_AUTHORS sets author and committer to the same person #28

Open
voelzmo opened this issue Jan 28, 2016 · 2 comments

Comments

@voelzmo
Copy link
Contributor

voelzmo commented Jan 28, 2016

Steps to reproduce:

$ export GIT_DUET_ROTATE_AUTHOR=1 #set author/committer rotation after each commit
$ git duet ab cd # set 'ab' as author and 'cd' as committer

# make some changes and add them
$ git duet-commit
$ git show --pretty=full
commit fc8284ee621a678573d1ede04ba7ce65c1358ef9
Author: A B <a.b@email.com>
Commit: C D <c.d@email.com>

Test commit

    Signed-off-by: C D <c.d@email.com>

# make some more changes and add them
$ git duet-commit --amend

Expected:

Author and committer rotation either works, or the current author/committers are left as-is

Actual

Person A B is now the committer and author of that change.

$ git show --pretty=full
commit fc8284ee621a678573d1ede04ba7ce65c1358ef9
Author: A B <a.b@email.com>
Commit: A B <a.b@email.com>

Test commit

    Signed-off-by: C D <c.d@email.com>
    Signed-off-by: A B <a.b@email.com>
@jszwedko
Copy link
Member

jszwedko commented Feb 6, 2016

Interesting, thanks for the report @voelzmo!

This behavior appears to be because git commit --amend (which git duet-commit --amend proxies to) automatically sets the committer of the commit to the current author.

I'm still looking, but there doesn't appear to be an easy way to suppress this behavior. If you also use --reset-author you can at least get the behavior of the author and committer both being set such that, in your example, you would end up with:

$ git duet-commit --amend --reset-author
$ git show --pretty=full
commit fc8284ee621a678573d1ede04ba7ce65c1358ef9
Author: C D <a.b@email.com>
Commit: A B <a.b@email.com>

Test commit

    Signed-off-by: C D <c.d@email.com>
    Signed-off-by: A B <a.b@email.com>

@iplay88keys
Copy link

This workaround has been how I've been resolving this issue for the past few years of using git-duet. However, running it once does not result in the same message, committer, and author as was there before the initial amend.

In order to get back to the "same" original commit, git duet-commit --amend --reset-author must be run twice in a row and the extra Signed-off-by lines need to be manually deleted. This workflow becomes tedious when trying to maintain a list of swapped authors and committers for a track of work.

Example:

Initial setup: ab author, cd committer

$ export GIT_DUET_ROTATE_AUTHOR=1
$ git duet ab cd
$ git duet-commit -m "Test commit"
$ git cat-file -p @
tree cccccccccccccccccccccccccccccccccccccccc
parent bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
author A B <a.b@example.com> 1578691007 -0700
committer C D <c.d@example.com> 1578691007 -0700

Test commit

Signed-off-by: C D <c.d@email.com>

The resulting log contains the expected swapping of author/committer

$ git log -3 --pretty=format:"%h - Author: %an, Committer: %cn"
ccccccc - Author: A B, Committer: C D
bbbbbbb - Author: C D, Committer: A B
aaaaaaa - Author: A B, Committer: C D

The first amend swaps the author/committer

$ git duet-commit --amend --reset-author --no-edit
$ git cat-file -p @
tree cccccccccccccccccccccccccccccccccccccccc
parent bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
author C D <c.d@example.com> 1578691007 -0700
committer A B <a.b@example.com> 1578691007 -0700

Test commit

Signed-off-by: C D <c.d@example.com>
Signed-off-by: A B <a.b@example.com>

The resulting log contains the incorrect swapping of author/committer

$ git log -3 --pretty=format:"%h - Author: %an, Committer: %cn"
ccccccc - Author: C D, Committer: A B
bbbbbbb - Author: C D, Committer: A B
aaaaaaa - Author: A B, Committer: C D

The second amend swaps the author/committer back, but requires deleting of the extra Signed-off-by lines

$ git duet-commit --amend --reset-author
tree cccccccccccccccccccccccccccccccccccccccc
parent bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
author A B <a.b@example.com> 1578691007 -0700
committer C D <c.d@example.com> 1578691007 -0700

Test commit

Signed-off-by: C D <c.d@example.com>
Signed-off-by: A B <a.b@example.com>  <- Delete
Signed-off-by: C D <c.d@example.com>  <- Delete

The final log output contains the correct swapping of the author/committer

$ git log -3 --pretty=format:"%h - Author: %an, Committer: %cn"
ccccccc - Author: A B, Committer: C D
bbbbbbb - Author: C D, Committer: A B
aaaaaaa - Author: A B, Committer: C D

I realize this was brought up initially a few years ago and although the workaround still works, I was hoping that there might be a way to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants