Skip to content

Using matrix‐react‐sdk as a subtree ‐ LEGACY

Marc edited this page Nov 27, 2024 · 1 revision

We maintain this fork using matrix-react-sdk as a subtree. The sdk was historically maintain using patches. Now only the matrix-js-sdk is maintain is patches (since there are rarely any modification on this repo).

When we want to upgrade to a newer version of element, we need to also update the subtree. To do that there are multiple solutions.

The direct update

This solution is the one described in the wiki page. We just pull the existing subtree with

git subtree pull --prefix linked-dependencies/matrix-react-sdk [email protected]:tchapgouv/matrix-react-sdk-tchap.git develop_tchap

and push with

git subtree push --prefix linked-dependencies/matrix-react-sdk [email protected]:tchapgouv/matrix-react-sdk-tchap.git develop_tchap

It is possible to add a new remote so you dont need to pass all the location everytime

git remote add subtree [email protected]:tchapgouv/matrix-react-sdk-tchap.git

The advantages of this method is that it is very simple and easy to do. However, the push command will take a really long time (~25min) to finish since he has to reindex all the history. If you want to avoid that, you can try the other method below.

Using subtree split and a new branch

  • In order to avoid this long waiting time, we can use the split command :
# The first time you run the split command you need to run this : 
git subtree split --prefix linked-dependencies/matrix-react-sdk --branch=matrix-react-sdk_subtree --rejoin

# If it is not the first time, it means you can start from previous last commit of the subtree history
git log --oneline matrix-react-sdk_subtree # -> get the list last commit hash of the subtree branch history
git subtree split --prefix linked-dependencies/matrix-react-sdk --branch=matrix-react-sdk_subtree --onto=<LAST_COMMT_HASH> --rejoin

# It can happen that it will create a subtree commit in the branch, which is useless, so you can reset to the origin/develop_branch to remove it 

It will create/update a local branch matrix-react-sdk_subtree in which he will create a history only containing commit changes in the subtree. The first time will also takes time, but after it will be fast. The --rejoin property tells git to reuse the previous split history so that he won't have to run against the entire history again, but wonly add the new commits.

  • Once its done, you can push this branch to the remote fork
git push subree matrix-react-sdk_subtree
  • And finally, you need to merge this new branch in matrix-react-sdk-tchap into develop_tchap in order to get the latest changed.

  • using this process add a step with a new branch

Troubleshoot

It can happen that the split command create a split commit into the current branch. Which is not normal and this commit is useless. The split command should only apply changes to the mention branch (with the option --branch). You can simply remove it using :

git reset --hard HEAD~1