Talk:Gerrit/Tutorial

Latest comment: 12 days ago by Tacsipacsi in topic Amending one of your own existing changes

Amending one of your own existing changes

edit

Under § Amending a change (your own or someone else's), the Gerrit tutorial says to use git review -d to download/checkout the change you want to amend before then making any changes to it. However, for amending your own patches, I'm wondering why the tutorial doesn't just say to make any changes in the branch you originally pushed to Gerrit from (if you still have access to it), before then running git review as you did when originally pushing the patch to Gerrit?

This appeared to work when I tested it in the Gerrit sandbox (at gerrit:1141150), and - when you already have a local branch that you've been working in - it strikes me as being simpler than first using git review -d to download & checkout a new (pseudo-identical?) branch. Please tell me if I'm missing something here, though! Best, ‍—‍a smart kitten[meow] 12:11, 4 May 2025 (UTC)Reply

I’ve used this method many times. I think the only reason for not documenting it is that the author didn’t want to describe two ways to achieve the same thing ­– but maybe they should have. —Tacsipacsi (talk) 20:05, 4 May 2025 (UTC)Reply
@A smart kitten @Tacsipacsi I just got to this situation myself today :) I rewrote a lot of the section, what do you think? Gerrit/Tutorial#Amending_changes Douginamug (talk) 08:16, 7 May 2025 (UTC)Reply
I tend to always re-pull the change from upstream specifically so that if there have been any new change sets pushed by a reviewer I have them to start my work from. Generally treating gerrit's view of the change set as canonical once you do your first git review submission will make your life easier in my experience. -- BDavis (WMF) (talk) 23:41, 7 May 2025 (UTC)Reply
Amendments by others is a good point, and one should indeed be aware of them (I didn’t consider them when writing the above answer, even though I’ve experienced quite a few accidents arising from ignoring this possibility); however, I don’t think always re-pulling is the solution for that:
  • on the one side, most patches are never amended by others (maybe amending others’ changes is more common within WMF/WMDE teams than among volunteers, but my experience is that even WMF employees’ patches are rarely amended by others), so it just wastes time to check out the patch again;
  • and on the other side, there’s still a race condition: what if someone amends the change after you re-pulled it?
So I’d keep the mention of re-using local branches, but add a warning to watch out for conflicts. —Tacsipacsi (talk) 17:06, 10 May 2025 (UTC)Reply
Return to "Gerrit/Tutorial" page.