Providing a patch

From Vifm Wiki
Jump to: navigation, search

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[edit]

When providing a patch as a diff please consider the following (these are not strict rules, but it makes reviewing easier):

  1. Use unified diff format. See section below for reasons.
  2. Make patch in root directory of the source tree.
  3. Give them meaningful names.
  4. 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.
  5. (optional) How would you like to be credited, e.g. maybe real name or nick name only.

Making a patch[edit]

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[edit]

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