Git: Creating a commit that depends on a few other Gerrit changes?

At my place of work, we use the Gerrit server to verify the code. Often, different people can commit copyrights that are not related to each other. I ran into a problem when I have to write a commit that depends on two other unconnected commits.

Let's say there are two commits on the gerrit server:

  • Commit A: "Added flipImage Function"
  • Commit B: "Added rotateImage function"

These two are independent of each other. My task is to implement Commit C: "Added flipRotateImage function". This requires both fixations A and B.

I have two questions:

  • How can I β€œdraw” both β€œA” and β€œB” and then the author β€œC” in such a way that I do not really change A or B? In other words, I cannot cherry pick A or B because it will change them. My goal is to be able to load C for viewing without the need to update A and B.
  • Let's say author A downloads a new set of patches. I want to update my so that the β€œA” in my chain is the last β€œA”, not the older patch set. It can be done?
+6
source share
3 answers
  • If A or B are not confused to depend on another, you cannot depend on C either on A or B. One way is to check A and merge from B to create a merge commit D that you could put C, but then you’ll have to load this otherwise useless business case for verification, but on schedule this is the only way to make A and B accessible from C without making A reachable from B or vice versa.
  • Yes, select the new A in the workspace with the URL specified in the Gerrit interface, and put C on top of it using, for example, git rebase --onto . The exact procedure will depend a bit on how you decided to solve the problem in the first question, but ignoring this and assuming that you checked the topic branch for C, then git rebase --onto newA oldA will do.
+3
source

Gerrit proposed a change to support this kind of dependency outside of git DAG. This change is intended for cross-project dependencies, but it should also support this type of dependency within the project. Sorry, but that won’t help you.

https://gerrit-review.googlesource.com/#/c/55243

+2
source

1) In fact, you can just start with A and merge B, and then make your change as amendments to the merge commit. If the changes are sufficiently independent, you can even combine more than two. (octopus shift)

2) It is difficult. Rebasing is enough as much as possible - there is a reason why no one is talking about updating octopus, and git-rebase only trying to reinstall on a single parent. But I suppose you can create a merge, reinstall it, and then crush the merge command and your commit.

I have not tried any of this in practice, and it is probably shaky, but I wanted to make sure that someone mentioned it. Technically, this is doable.

0
source

All Articles