How to Apply .patch Files

This topic applies to

Applies to

SuiteCommerce Advanced

Some releases of SuiteCommerce Advanced include a series of .patch files, which contain the complete diffs between new and previous releases across all source files. In some cases, a patch might be available for specific purposes, such as for backporting code to previous releases to support new features. If you encounter a .patch file, refer to this section to learn how to interpret and apply it.

A patch file contains the differences between two identically titled files. The patch designates these folders as a and b. Distributing the patch to an identically titled path/folder allows the patch to transform changes in b (the source of the changes) to the matching file in a (the target of the changes).

Follow the appropriate procedure to apply the diff, depending on how you customized the source code in previous releases.

  • If you have not altered any SuiteCommerce Advanced source files in Modules/suitecommerce/, you can use third-party software to run the patch.

  • If you have modified any source files in Modules/suitecommerce/, you must implement changes manually.


Applying a diff adds and removes lines of code. This can break your site if you are not careful. Do not apply any diffs using third-party software unless you have followed NetSuite’s best practices for customizing JavaScript files as outlined in Best Practices for Customizing SuiteCommerce Advanced. Do not patch your live site directly. Create a test site or test files locally using the dev tools. Failure to test any changes thoroughly before deploying to your live site can result in data loss.

For a list of available patches, see Patches.

To apply a diff using third-party software:

  1. Download the correct diff file to the target directory.

  2. Make a backup of your original source code.

  3. Review the diff as applicable. See Diff File Structure for details.

  4. Ensure that you have not altered any source code provided by NetSuite and apply the diff using your preferred third-party method.

    Various programs are available that can apply a diff file to your SCA source code. The following example applies a Mont Blanc release diff using Git.

    cd montblanc

    git init

    git apply /path/montblanc-sensors.patch

    rm -rf .git

To apply a diff manually:

  1. Download the correct diff file.

  2. Open the diff.

  3. Make a backup of your local source code.

  4. Make all changes manually in your local source code. For a detailed description of a diff file and its components, see Diff File Structure

Diff File Structure

This section explains how SuiteCommerce Advanced diff files are structured. The information in this section should help you understand any diff files provided by NetSuite for SuiteCommerce Advanced.


Surrounding code and estimated line numbers vary depending on each file due to existing customizations. These instructions include them here as reference points only.

Example Diff File

The following example shows a simple diff (.patch file). This example only compares one file, although most diffs include more than one file. One diff file typically contains many comparisons, each with its own components, as described in this section.

diff --git a/myDirectoryPath/myFile.js b/myDirectoryPath/myFile.js
index 5d7cd7e..fca4091 100755
--- a/myDirectoryPath/myFile.js
+++ b/myDirectoryPath/myFile.js
@@ -76,7 +77,7 @@ define('Sensors'

      _.each(arguments, function (argument)
-      if(argument)
+      if (argument)
            _.extend(data, argument);

File Comparison Header

The File Comparison Header is a statement explaining two files being compared. The two files being compared include leading directory names a and b to distinguish the two files, which typically have identical names and locations.

This example shows changes between two versions of myFile.js. Note the file names and paths are identical. --git simply informs you that this diff is written in Git-specific diff format. Each comparison within the diff begins with a header.

diff --git a/myDirectoryPath/myFile.js b/myDirectoryPath/myFile.js


Technically part of the Header, the index is a line of metadata describing technical information about the given files. The first two numbers (separated by ..) represent the IDs of the two files being compared. In this case, each version of the project file is an object at a specific revision.

The last number is a mode identifier for the file containing the changes:

  • 100644 specifies a normal, non-executable file.

  • 100755 specifies an executable file.

  • 120000 specifies a symbolic link.

In this example, this part of the diff is comparing two different file IDs (5d7cd7e and fca4091) of myFile.js, which is an executable file.

index 5d7cd7e..fca4091 100755

Change Markers

The next two lines describe the two files (and paths) being compared, but with +++ or --- prefixes. The file with the minus symbols shows lines that exist within the a version but are missing from the b version. Likewise, the file with the plus symbols contains lines missing in the a version but are present in b.

In this example, a is the existing (old) file and b is the updated (new) file.

--- a/myDirectoryPath/myFile.js +++ b/myDirectoryPath/myFile.js

Range Information

Diff files show only the portions of the file being changed. These portions are called hunks. One hunk of data containing changes is depicted within two sets of @@ symbols. This information declares the lines within the hunk that are affected by the change. One index can contain multiple hunks, depicting the various changes throughout the file.

In this example, the diff contains one hunk of differences. Seven lines are extracted from the a file, beginning at line 76. Likewise, seven lines are displayed in the b file, beginning at line 77.

@@ -76,7 +77,7 @@


The changes to each hunk immediately follow the range information. Each changed line is prepended with either a + or a - symbol. These symbols act in the same way as they do in the Change Markers section. The diff removes lines prepended with a - and adds lines prepended with a + sign. If making changes to your code manually, any lines bearing the - prefix need to be removed. Any lines bearing the + prefix need to be added.

Additionally, a hunk typically contains unchanged lines before and after the modification to provide context for the change. In this example, the diff removes if(argument) and adds the corrected code: if (argument).

define('Sensors' { _.each(arguments, function (argument) { - if(argument) + if (argument) { _.extend(data, argument); }


In diffs provided by NetSuite, a files and lines marked with - are old, and b files and lines marked with + are updates.

Related Topics