Skip to content

Commit 4c147ab

Browse files
authored
Merge pull request #13926 from nextcloud/backport/13924/stable32
[stable32] feat(applying-patch): improve documentation to also mention git apply as alternative and additional improvements
2 parents f8540ec + ee229f5 commit 4c147ab

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

admin_manual/issues/applying_patch.rst

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,60 @@
22
Patching Nextcloud
33
==================
44

5+
Obtaining a patch
6+
-----------------
7+
8+
If you found a related pull request on GitHub that solves your issue, or you want to help developers and verify a fix works, you can get a patch for the pull request.
9+
10+
1. Using https://github.com/nextcloud/server/pull/26396 as an example.
11+
2. Append ``.diff`` to the URL: https://github.com/nextcloud/server/pull/26396.diff
12+
3. Download the patch to your server e.g. via ``wget https://github.com/nextcloud/server/pull/26396.diff`` (this will place ``26396.diff`` in the local directory)
13+
4. Follow the `Applying a patch`_ steps.
14+
5. If you are on an older Nextcloud version, you might first need to go to the correct backported patch for your version.
15+
16+
.. image:: images/getting-a-patch-from-github.png
17+
:alt: backportbot-nextcloud linking to the pull request for an older version.
18+
19+
6. You can find the appropriate version by looking for a link posted by ``backportbot-nextcloud`` to the backport pull request for your release, or by checking for a developer comment with a manual backport link. Use the ``.diff`` URL of that backport PR.
20+
521
Applying a patch
622
----------------
723

824
Patching server
925
^^^^^^^^^^^^^^^
1026

11-
1. Navigate into your Nextcloud server's root directory (contains the ``status.php`` file)
12-
2. Now apply the patch with the following command::
27+
1. Navigate to your Nextcloud server's root directory (the one that contains the ``status.php`` file).
28+
2. Download the patch to your server e.g. via ``wget https://github.com/nextcloud/server/pull/26396.diff`` (this will place ``26396.diff`` in the local directory)
29+
3. Apply the patch with the following command::
1330

14-
patch -p 1 < /path/to/the/file.patch
31+
patch -p 1 < ./26396.diff
1532

16-
.. note::
33+
4. Alternatively, if the patch command is not available, use::
1734

18-
There can be errors about not found files, especially when you take a patch from GitHub there might be development or test files included in the patch. when the files are in build/ or a tests/ subdirectory it is mostly being
35+
git apply --check ./26396.diff
36+
git apply ./26396.diff
1937

2038
Patching apps
2139
^^^^^^^^^^^^^
2240

23-
1. Navigate to the root of this app (mostly ``apps/[APPID]/``), if you can not find the app there use the ``sudo -E -u www-data php occ app:getpath APPID`` command to find the path.
24-
2. Now apply the patch with the same command as in `Patching server`_
41+
1. Navigate to the root of the app (usually ``apps/[APPID]/``). If you cannot find the app there, use the ``sudo -E -u www-data php occ app:getpath APPID`` command to find the path.
42+
2. Download the patch to your server e.g. via ``wget https://github.com/nextcloud/<app>/pull/26396.diff`` (this will place ``26396.diff`` in the local directory)
43+
3. Apply the patch with the same command as in `Patching server`_.
2544

2645
Reverting a patch
2746
-----------------
2847

2948
1. Navigate to the directory where you applied the patch.
3049
2. Now revert the patch with the ``-R`` option::
3150

32-
patch -R -p 1 < /path/to/the/file.patch
51+
patch -R -p 1 < ./26396.diff
52+
53+
3. Alternatively, if the patch command is not available, use::
54+
55+
git apply --reverse ./26396.diff
3356

34-
Getting a patch from a GitHub pull request
35-
------------------------------------------
57+
Notes and troubleshooting
58+
-------------------------
3659

3760
If you found a related pull request on GitHub that solves your issue, or you want to help developers and verify a fix works, you can get a patch for the pull request.
3861

0 commit comments

Comments
 (0)