• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2title: 'Applying patches'
3linkTitle: 'Applying patches'
4---
5
6If you are a Skia committer and have been asked to commit an
7externally-submitted patch, this is how to do it. (This technique is useful in
8other situations too, like if you just want to try out somebody else's patch
9locally.)
10
11Notes:
12
13- For the examples below, we will assume that this is the change you want to
14  patch into your local checkout: https://codereview.appspot.com/6201055/
15- These instructions should work on Mac or Linux; Windows is trickier, because
16  there is no standard Windows "patch" tool.
17
18See also [Contributing Code for The Chromium Projects]
19(http://dev.chromium.org/developers/contributing-code#TOC-Instructions-for-Reviewer:-Checking-in-the-patch-for-a-non-committer).
20
21If you use `git cl`, then you should be able to use the shortcut:
22
23```
24git cl patch 6201055
25```
26
27If you use `gcl`, or the above doesn't work, the following should always work.
28
291. Prepare your local workspace to accept the patch.
30
31   - cd into the root directory (usually `trunk/`) of the workspace where you
32     want to apply the patch.
33   - Make sure that the workspace is up-to-date and clean (or "updated and clean
34     enough" for your purposes). If the codereview patch was against an old
35     revision of the repo, you may need to sync your local workspace to that
36     same revision.
37
382. Download the raw patch set.
39
40   - Open the codereview web page and look for the "Download raw patch set" link
41     near the upper right-hand corner. Right-click on that link and copy it to
42     the clipboard. (In my case, the link is
43     https://codereview.appspot.com/download/issue6201055_1.diff )
44   - If you are on Linux or Mac and have "curl" or "wget" installed, you can
45     download the patch from the command line:
46
47   ```
48   curl https://codereview.appspot.com/download/issue6201055_1.diff
49   --output patch.txt
50   # or...
51   wget https://codereview.appspot.com/download/issue6201055_1.diff
52   --output-document=patch.txt
53   ```
54
55   - Otherwise, figure out some other way to download this file and save it as
56     `patch.txt`
57
583. Apply this patch to your local checkout.
59
60   - You should still be in the root directory of the workspace where you want
61     to apply the patch.
62
63   ```
64   patch -p1 <patch.txt
65   ```
66
67   - Then you can run `diff` and visually check the local changes.
68
694. Complications: If the patch fails to apply, the following may be happening:
70
71   - Wrong revision. Maybe your local workspace is not up to date? Or maybe the
72     patch was made against an old revision of the repository, and cannot be
73     applied to the latest revision? (In that case, revert any changes and sync
74     your workspace to an older revision, then re-apply the patch.)
75