Providing a patch
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Changes might be proposed as pull requests on GitHub or sent as patches in an e-mail or attached to a ticket. This page gives some advices for the later cases.
Advices on patch files
When providing a patch as a diff please consider the following (these are not strict rules, but it makes reviewing easier):
- Use unified diff format. See section below for reasons.
- Make patch in root directory of the source tree.
- Give them meaningful names.
- Attach patches when possible instead of providing them in body of an e-mail or in description of a ticket. Automatic text formatting can make it unreadable or even make it impossible to apply.
- (optional) How would you like to be credited, e.g. maybe real name or nick name only.
Making a patch
From git
repository:
- Uncommited:
git diff > change-description.patch
- Commited:
git format-patch -1
From unarchived sources:
patch --unified src/old-version.c src/new-version.c > change-description.patch
Why unified diff
Unified diff is more human readable. See example below.
Non-unified diff format:
$ diff src/utils/utils_nix.c_ src/utils/utils_nix.c
156,162c156
< while(select(fd + 1, &read_ready, NULL, NULL, &ts) == 0);
<
< /* Inform other parts of the application that cancellation took place. */
< if(errno == EINTR)
< {
< ui_cancellation_request();
< }
---
> while(select(fd + 1, &read_ready, NULL, NULL, &ts) == 0 || errno == EINTR);
Unified diff format:
$ diff --unified src/utils/utils_nix.c_ src/utils/utils_nix.c
--- src/utils/utils_nix.c_ 2014-07-28 19:39:36.406899060 +0300
+++ src/utils/utils_nix.c 2014-07-28 19:38:52.720898588 +0300
@@ -153,13 +153,7 @@
ts = ts_init;
FD_SET(fd, &read_ready);
}
- while(select(fd + 1, &read_ready, NULL, NULL, &ts) == 0);
-
- /* Inform other parts of the application that cancellation took place. */
- if(errno == EINTR)
- {
- ui_cancellation_request();
- }
+ while(select(fd + 1, &read_ready, NULL, NULL, &ts) == 0 || errno == EINTR);
}
int