Cyclic dependencies

62 views
Skip to first unread message

Samuel Lucas

unread,
Jun 17, 2009, 6:33:47 PM6/17/09
to Repo and Gerrit Discussion
Hi,

I have just installed gerrit and I'm a bit confused with the
dependency between the changes.

The workflow I'm considering is:

<implement change A>
git commit
git push origin HEAD:refs/for/master

<implement change B>
git commit
git push origin HEAD:refs/for/master

<fix a bug in A>
git commit
git push origin HEAD:refs/change/A

<fix a bug in B>
git commit
git push origin HEAD:refs/change/B

<change A is now fine, submit it>

<change B is now fine, submit it>

After this I get A depends on B, B depends on A, both A and B are
submitted but there is no merge.

Is there any workaround for this or any configuration that would
prevent users to fall in this case?

Thanks,

- Samuel


Shawn Pearce

unread,
Jun 17, 2009, 11:34:54 PM6/17/09
to repo-d...@googlegroups.com
On Wed, Jun 17, 2009 at 15:33, Samuel Lucas <samue...@gmail.com> wrote:

<implement change A>
git commit
git push origin HEAD:refs/for/master

<implement change B>
git commit
git push origin HEAD:refs/for/master

<fix a bug in A>
git commit
git push origin HEAD:refs/change/A

<fix a bug in B>
git commit
git push origin HEAD:refs/change/B

<change A is now fine, submit it>

<change B is now fine, submit it>

After this I get A depends on B, B depends on A,  both A and B are
submitted but there is no merge.

If I you do exactly what you describe above, Gerrit should reject the last 2 pushes, because the patch set 1 commit is an ancestor of what you are trying to make patch set 2.  That would make a change depend upon itself, making it unsubmittable.

The right way to handle this is, once you decide to fix a bug in A:

  git rebase -i HEAD~2
  ... change "pick" to "edit" for first commit (A) ...
  ... fix bug ....
  ... stage files ...
  git commit --amend
  git rebase --continue
  git push origin HEAD~1:refs/changes/A HEAD:refs/changes/B

To fix a bug in B, its easier, because its the most recent commit:

  ... fix bug ...
  ... stage files ...
  git commit --amend
  git push origin HEAD:refs/changes/B

In the next release (.15) I'm hoping to simplify the push command line by automating replacement detection, rather than requiring it to be explicit.  I started working on the code yesterday, but got distracted by trying to fix a deadlock we're seeing in replication between two Gerrit instances over a WAN link.
Reply all
Reply to author
Forward
0 new messages