Clang-format migration: Investigate branch migration plan & document it #60283

Closed
opened 2019-01-07 17:41:47 +01:00 by Keir Mierle · 5 comments
Member

Before applying the big-bang migration, it's critical to investigate how hard it will be to merge branches that started before the big bang change.

This task:

  • Figure out the best approach for branches-- should they apply make format themselves? Does that work? Or ignore it?
  • Document this approach either in the wiki or the blog post.
Before applying the big-bang migration, it's critical to investigate how hard it will be to merge branches that started before the big bang change. This task: - Figure out the best approach for branches-- should they apply `make format` themselves? Does that work? Or ignore it? - Document this approach either in the wiki or the blog post.
Author
Member
Added subscribers: @Keir, @dr.sybren, @Stefan_Werner, @LazyDodo, @fclem, @Sergey, @dfelinto, @brecht, @ideasman42, @mont29

In #53211#610474, @mont29 wrote:
Also, just tried merging this into asset-engine branch, looks like -Xours is mandatory… Should not be an issue with following process though, I think:

Merge temp-clang-format into asset-engine (about 6 conflicting files, essentially due to recent pre-clang-format edits in master).

Apply clang-format on temp-clang-format and commit.

Apply clang-format on asset-engine and commit.

Merge clang-format into asset-engine using git merge -Xignore-all-space -Xours temp-clang-format command.

For the final merge, regular merge is catastrophic ( ALL edited files in asset-engine are conflicting, over 30). Using only -Xignore-all-space option, it’s a tad better (although I did not check the actual result), but am still getting 23 files conflicting, even the mere addition of a single function in creator.c is enough to create an issue!

After discussion, it would be nice to avoid applying clang-format on whole codebase in every branch. So I tried using -s ours instead of -Xours, following that process:

  • Merge temp-clang-format into asset-engine.
  • Apply clang-format on temp-clang-format and commit.
  • Merge clang-format into asset-engine using git merge -Xignore-all-space -s ours temp-clang-format command.
  • Apply clang-format on asset-engine and commit.

That does not really work well, it basically applies none of clang-format changes, i.e. after step 4 all files get modified, not only the branch-modified ones.

So instead, I reversed the step 3 and 4 of the first attempt, think this gives best results (smooth merge with much smaller commit when applying clang-format on the branch):

  • Merge temp-clang-format into asset-engine (about 6 conflicting files, essentially due to recent pre-clang-format edits in master).
  • Apply clang-format on temp-clang-format and commit.
  • Merge clang-format into asset-engine using git merge -Xignore-all-space -Xours temp-clang-format command.
  • Apply clang-format on asset-engine and commit.
> In #53211#610474, @mont29 wrote: > Also, just tried merging this into asset-engine branch, looks like `-Xours` is mandatory… Should not be an issue with following process though, I think: > > # Merge `temp-clang-format` into `asset-engine` (about 6 conflicting files, essentially due to recent pre-clang-format edits in master). > # Apply clang-format on `temp-clang-format` and commit. > # Apply clang-format on `asset-engine` and commit. > # Merge `clang-format` into `asset-engine` using `git merge -Xignore-all-space -Xours temp-clang-format` command. > > For the final merge, regular merge is catastrophic ( **ALL** edited files in `asset-engine` are conflicting, over 30). Using only `-Xignore-all-space` option, it’s a tad better (although I did not check the actual result), but am still getting 23 files conflicting, even the mere addition of a single function in `creator.c` is enough to create an issue! After discussion, it would be nice to avoid applying clang-format on whole codebase in every branch. So I tried using `-s ours` instead of `-Xours`, following that process: - Merge `temp-clang-format` into `asset-engine`. - Apply clang-format on `temp-clang-format` and commit. - Merge `clang-format` into `asset-engine` using `git merge -Xignore-all-space -s ours temp-clang-format` command. - Apply clang-format on `asset-engine` and commit. That does not really work well, it basically applies none of clang-format changes, i.e. after step 4 all files get modified, not only the branch-modified ones. So instead, I reversed the step 3 and 4 of the first attempt, think this gives best results (smooth merge with much smaller commit when applying clang-format on the branch): - Merge `temp-clang-format` into `asset-engine` (about 6 conflicting files, essentially due to recent pre-clang-format edits in master). - Apply clang-format on `temp-clang-format` and commit. - Merge `clang-format` into `asset-engine` using `git merge -Xignore-all-space -Xours temp-clang-format` command. - Apply clang-format on `asset-engine` and commit.

Yes, I think it can be summarized as this once the formatting is done in master:

git merge <clang-format-commit>^1
... merge any conflicts and commit...

git merge -Xignore-all-space -Xours <clang-format-commit>
make format
git commit

git merge master
... merge any conflicts and commit...
Yes, I think it can be summarized as this once the formatting is done in master: ``` git merge <clang-format-commit>^1 ... merge any conflicts and commit... git merge -Xignore-all-space -Xours <clang-format-commit> make format git commit git merge master ... merge any conflicts and commit... ```

I've added a script to rebase and merge master into branches: blender/blender-dev-tools@a64a4237d8
https://wiki.blender.org/wiki/Tools/ClangFormat#Migrating_Branches_and_Patches

Ended up being more complicated than I hoped, wouldn't mind if someone else can verify the logic is sane.

I've added a script to rebase and merge master into branches: blender/blender-dev-tools@a64a4237d8 https://wiki.blender.org/wiki/Tools/ClangFormat#Migrating_Branches_and_Patches Ended up being more complicated than I hoped, wouldn't mind if someone else can verify the logic is sane.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Brecht Van Lommel self-assigned this 2019-04-18 13:24:24 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#60283
No description provided.