Difference between revisions of "2023 Consistent Whitespace"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
SL-18509 makes whitespace in C++ files consistent across the entire SL codebase. It does this by updating whitespace in a line-independent manner, thereby allowing git to merge changes with minimal fuss.
{{Jira|DRTVWR-576}} makes whitespace in C++ files consistent across the entire SL codebase. It does this by updating whitespace in a line-independent manner, thereby allowing git to merge changes with minimal fuss.


{{KBcaution|At this point in time the SL-18509 branch is provided for merge testing, and is '''not ready''' for integration into development trunks!}}
{{KBcaution|At this point in time the DRTVWR-576 is provided for merge testing, and is '''not ready''' for integration into development trunks!}}
 
 
__TOC__


===Purpose===
===Purpose===
Line 13: Line 16:
'''Prerequisites:'''
'''Prerequisites:'''


In order to smoothly merge SL-18509 changes into your branch it should already be up to date with LL's 2022/10/26 master, [https://bitbucket.org/lindenlab/viewer/commits/a022452ff56c31cb028d5a17d827c82f1a74e624 a022452]
In order to smoothly merge DRTVWR-576 changes into your branch it should already be up to date with LL's 2022/12/12 [https://github.com/secondlife/viewer/commit/a0c3d69c620a92d73a1008f218680fb4d0ef9255 a0c3d69].


'''Instructions:'''
'''Instructions:'''


Set up your repository
Set up your repository
<source lang="bash">
<syntaxhighlight lang="bash">
# Add the LL upstream remote
# Add the LL upstream remote
git remote add upstream https://bitbucket.org/lindenlab/viewer.git
git remote add upstream https://bitbucket.org/lindenlab/viewer.git
Line 26: Line 29:


# Verify that you have all changes. This merge command should respond: "Already up to date."
# Verify that you have all changes. This merge command should respond: "Already up to date."
git merge upstream/master
git merge a0c3d69
</source>
</syntaxhighlight>


Now, merge the changes
Now, merge the changes
<source lang="bash">
<syntaxhighlight lang="bash">
# Merge whitespace changes from SL-18509 branch
# Merge whitespace changes from DRTVWR-576 branch
git merge --no-commit -Xignore-all-space upstream/SL-18509
git merge --no-commit -Xignore-all-space upstream/DRTVWR-576


# If your viewer deleted files which are still present in upstream,
# If your viewer deleted files which are still present in upstream,
Line 49: Line 52:
git add .
git add .
git commit
git commit
</source>
</syntaxhighlight>


Note the use of the -Xignore-all-space merge strategy. This, in addition to the changes in the upstream repo, is what makes the merge simpler than it otherwise would be.
Note the use of the {{mono|-Xignore-all-space}} merge strategy. This, in addition to the changes in the upstream repo, is what makes the merge simpler than it otherwise would be.


====Fixing additional branches====
====Fixing additional branches====
Line 57: Line 60:
You can now use your merged branch to update other branches. This should mean any modify/delete conflicts resolved in the first pass will not need to be addressed again.
You can now use your merged branch to update other branches. This should mean any modify/delete conflicts resolved in the first pass will not need to be addressed again.


<source>
<syntaxhighlight lang="bash">
git checkout my-feature-branch
git checkout my-feature-branch
git merge --no-commit -Xignore-all-space whitespace-demo
git merge --no-commit -Xignore-all-space whitespace-demo
Line 63: Line 66:
git add .
git add .
git commit
git commit
</source>
</syntaxhighlight>
 
===Example merges===
 
* [https://github.com/bennettgoble/firestorm-phoenix github.com/bennettgoble/firestorm-phoenix@whitespace-demo] - Merge of Firestorm master
* [https://github.com/bennettgoble/kokua github.com/bennettgoble/kokua@whitespace-demo-Kokua-MKRLV] - Merge of Kokua MKRLV
 
===Notes===
 
* {{mono|fix-whitespace.sh}} works best when it has fast disk i/o. On Windows, running it on WSL's own drive takes seconds, whereas running it on a Windows drive mount can take minutes. {{mono|Mingw}} and {{mono|Cygwin}} are similarly impacted.

Latest revision as of 10:06, 23 February 2023

DRTVWR-576 makes whitespace in C++ files consistent across the entire SL codebase. It does this by updating whitespace in a line-independent manner, thereby allowing git to merge changes with minimal fuss.

KBcaution.png Important: At this point in time the DRTVWR-576 is provided for merge testing, and is not ready for integration into development trunks!


Purpose

The goal of making whitespace consistent across all files is to reduce merge conflicts when pulling changes from LL's canonical upstream into forks. It also makes developers' lives easier as they do not have to deal with files with mixed whitespace. By doing a small amount of work now, future merges will be made simpler. It will also result in a codebase that is less embarrassing.

Integration

Fear not! Rather than being an unholy nightmare to merge, whitespace changes can be incorporated by following a relatively simple set of instructions that take advantage of features built into git.

Prerequisites:

In order to smoothly merge DRTVWR-576 changes into your branch it should already be up to date with LL's 2022/12/12 a0c3d69.

Instructions:

Set up your repository

# Add the LL upstream remote
git remote add upstream https://bitbucket.org/lindenlab/viewer.git

# Fetch the upstream refs
git fetch upstream

# Verify that you have all changes. This merge command should respond: "Already up to date."
git merge a0c3d69

Now, merge the changes

# Merge whitespace changes from DRTVWR-576 branch
git merge --no-commit -Xignore-all-space upstream/DRTVWR-576

# If your viewer deleted files which are still present in upstream,
# Resolve modify/delete conflicts by removing them. The following is an
# example from Firestorm's delta. Your codebase's changes may vary.
git rm indra/newview/llimpanel.h
git rm indra/newview/llcallbacklist.cpp
git rm indra/newview/llappviewerlinux_api_dbus.cpp
git rm indra/newview/llappviewerlinux_api.h 
git rm indra/linux_crash_logger/llcrashloggerlinux.cpp

# Fixup whitespace in any files not in upstream
./fix-whitespace.sh

# Add and commit merge
git add .
git commit

Note the use of the -Xignore-all-space merge strategy. This, in addition to the changes in the upstream repo, is what makes the merge simpler than it otherwise would be.

Fixing additional branches

You can now use your merged branch to update other branches. This should mean any modify/delete conflicts resolved in the first pass will not need to be addressed again.

git checkout my-feature-branch
git merge --no-commit -Xignore-all-space whitespace-demo
./fix-whitespace.sh
git add .
git commit

Example merges

Notes

  • fix-whitespace.sh works best when it has fast disk i/o. On Windows, running it on WSL's own drive takes seconds, whereas running it on a Windows drive mount can take minutes. Mingw and Cygwin are similarly impacted.