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

support rebase and cherry-pick #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thewoolleyman
Copy link

Fixes issue #24

FYI, I was unable to get the bats tests all running locally against master, I'm glad to provide tests if you can help me get the test environment going on my box.

@thewoolleyman thewoolleyman changed the title PR#24 - support rebase and cherry-pick support rebase and cherry-pick Nov 20, 2015

func main() {
err := cmdrunner.Execute(
cmd.New("cherry-pick"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I didn't realize cherry-pick supports --signoff off the bat.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something, but shouldn't this be cmd.NewWithSignoff("cherry-pick")?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right, cherry-pick does support signoff - I'll fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a little more thought, I think the --signoff on cherry-pick was probably meant to sign off on the commits you are cherry picking (that previously only had an author). By setting this here, it would override any committer present on the original commit -- it feels like this might be desirable, but definitely deserves a second thought.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right. Assuming that they were probably using git-duet for the original commit, it should have both an author and a committer.

And, I don't think those should be touched during cherry-picking. You are only moving the commit from one branch/ref to another, the "ownership" of the original commit isn't changing.

And in practice (at least in most workflows I know), this is usually only used to get individual commits onto a production release or hotfix branch (otherwise you'd be doing a merge or rebase of a whole branch to git all commits). And, this often isn't even done by the original committer on large teams - it could be someone responsible for deploying the release or hotfix, not the original coder.

So, I think this is fine the way it is :)

@jszwedko
Copy link
Member

Thanks for getting the ball rolling on this @thewoolleyman! I responded on the issue regarding getting your environment setup.

README.md Outdated
Suggested aliases:

```
dci = duet-commit
drv = duet-revert
dmg = duet-merge
drb = duet-merge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you have a couple copy/pasta errors here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll fix.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see drb = duet-merge - should be drb = duet-rebase?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the github UI is confused, I amended the commit and it's correct in my repo now:

thewoolleyman@master#diff-04c6e90faac2675aa89e2176d2eec7d8R145

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just cloned it down from your repo on master, commit c21558e

It shows:

dmg = duet-merge
drb = duet-merge
dcp = duet-cherry-pick

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, there were two typos! sorry, fixed the other now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Np, looks good now

@glestaris
Copy link

Sorry for spamming but +1. We use rebase quite often and it's always a pain having to fix the authors of each commit.

@iamralch
Copy link
Contributor

When should I expect this pull request to be accepted?

@jszwedko
Copy link
Member

@glestaris no worries -- can you describe your use case a little more? git rebase keeps the author/committer of the existing commit unless I'm missing something. The issue this PR was opened to address was the fact that git complains about the author not being set during a git rebase which I think is better solved by #4.

@glestaris
Copy link

@jszwedko The problem we are seeing is that we lose information about the commiter in all the rebased commits. Just to give an example:

I made a repo with master and wip-docs branches. wip-docs needs rebasing since master is updated after wip-docs was created:

$> g lola --pretty=format:"%h %s
    '%an' (author) and '%cn' (commiter)"
* 0e7578f Add getting started chapter in docs (HEAD, wip-docs)
|     'Alice Brown' (author) and 'John Spith' (commiter)
* a1ce86d Add docs and introduction chapter
|     'Alice Brown' (author) and 'John Spith' (commiter)
| * 32d3458 Add end-to-end tests (master)
|/      'Alice Brown' (author) and 'John Spith' (commiter)
* 636ee15 Update project title
|     'Alice Brown' (author) and 'John Spith' (commiter)
* 024e4e4 Add readme
      'Alice Brown' (author) and 'John Spith' (commiter)

After running git rebase master in wip-docs, I get to this state:

* f5563e5 Add getting started chapter in docs (HEAD, wip-docs)
|     'Alice Brown' (author) and 'George Lestaris' (commiter)
* 2b89e95 Add docs and introduction chapter
|     'Alice Brown' (author) and 'George Lestaris' (commiter)
* 32d3458 Add end-to-end tests (master)
|     'Alice Brown' (author) and 'John Spith' (commiter)
* 636ee15 Update project title
|     'Alice Brown' (author) and 'John Spith' (commiter)
* 024e4e4 Add readme
      'Alice Brown' (author) and 'John Spith' (commiter)

So you are probably right that it has to do with user.email and user.name since this is what it applies to the commiter. However, rebase does not keep the commiter unchanged and now we have to go back to the rebased commits, git duet with the correct author/commiter and then run git duet-commit --amend --no-edit --reset-author.

Is there any better way of doing it?

Thanks and sorry if this is now in the wrong PR. I am happy to create an issue if you prefer so :)

@jszwedko
Copy link
Member

Hi @glestaris, apologies for the delay, you are completely right, I missed that it uses the current user as the committer during rebases for rebased commits (which was noted in the conversation above).

Giving that some additional thought, I do feel that if I am driving, I'd expect any rebased commits without a committer (read: the committer is same as the author with identical timestamps) to have me as the committer and keep the original author. However, if the commit I'm rebasing already has a committer different than the author (as it often will if users are pairing using this tool) I can see the case for wanting to keep the original committer on that commit instead of changing it to me.

This PR in particular simply introduces a git duet-rebase that has the effect of using the author from git solo rather than git config user.* when rebasing, but would suffer from the same issue: rebased commits would have their committer updated to the current author.

Unfortunately, given my quick review of the git porcelain there doesn't seem to be an easy way to achieve what I've described above. I think it might be possible by passing a --exec command to be run after each commit during git rebase, but that is only valid in interactive mode.

That leaves us with the following options:

  • Trying to determine a way to rebase without altering author/committer information at all -- which doesn't seem possible with the normal git porcelain, but feels like it might be with the lower level tools
  • Updating all rebased commits to have the current pair from git duet and erase the original author/committer (not sure if this is easily possible). This is what your workaround currently does, but only for the latest commit in the branch that was rebased.
  • Documenting the deficiency and possible workaround using interactive mode and --exec
  • ?

I'll investigate the first option, but would love any other suggestions or insights.

Thanks!

@jszwedko
Copy link
Member

There is also this language from http://git-scm.com/book/ch2-3.html:

You may be wondering what the difference is between author and committer. The author is the person who originally wrote the work, whereas the committer is the person who last applied the work.

which we might use to inform our approach.

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

Successfully merging this pull request may close these issues.

None yet

5 participants