AWS CodeCommit

2026/08/13 - AWS CodeCommit - 1 new api methods

Changes  Added the GetBlobDifferences API operation, which returns line-level diffs between two blob versions without requiring a local clone. Returns structured hunks with context, additions, and deletions. Supports pagination for large diffs.

GetBlobDifferences (new) Link ΒΆ

Returns a structured, line-level diff between two blob versions in a repository. The diff is returned as an ordered list of hunks, where each hunk represents a contiguous run of changed lines together with any surrounding unchanged context lines.

Results are paginated. Use MaxResults and NextToken to retrieve additional pages.

For the typical usage workflow, see GetDifferences.

See also: AWS API Documentation

Request Syntax

client.get_blob_differences(
    repositoryName='string',
    afterBlobId='string',
    beforeBlobId='string',
    contextLines=123,
    ignoreWhitespace=True|False,
    MaxResults=123,
    NextToken='string'
)
type repositoryName:

string

param repositoryName:

[REQUIRED]

The name of the repository that contains the blobs to compare.

type afterBlobId:

string

param afterBlobId:

[REQUIRED]

The ID of the "after" (destination) blob in the diff. Typically the value of afterBlob.blobId from a Difference object returned by GetDifferences.

type beforeBlobId:

string

param beforeBlobId:

The ID of the "before" (source) blob in the diff. Typically the value of beforeBlob.blobId from a Difference object returned by GetDifferences.

If you do not specify a value, the operation returns a diff against an empty before-state. This is equivalent to treating the file as newly added.

type contextLines:

integer

param contextLines:

The number of unchanged lines of context to include before and after each block of changes in a hunk. Valid values are 0 through 20. Defaults to 3.

type ignoreWhitespace:

boolean

param ignoreWhitespace:

Specifies whether to ignore whitespace-only changes when computing the diff. When true, the operation treats lines that differ only in whitespace as unchanged. Defaults to false.

type MaxResults:

integer

param MaxResults:

The maximum number of DiffHunk entries to return in a single response page. Defaults to 100.

type NextToken:

string

param NextToken:

An enumeration token that returns the next batch of results when present in a request.

rtype:

dict

returns:

Response Syntax

{
    'hunks': [
        {
            'beforeStartLine': 123,
            'beforeLineCount': 123,
            'afterStartLine': 123,
            'afterLineCount': 123,
            'changes': [
                {
                    'type': 'CONTEXT'|'ADD'|'DELETE',
                    'beforeLineNumber': 123,
                    'afterLineNumber': 123,
                    'content': 'string'
                },
            ]
        },
    ],
    'isBinary': True|False,
    'beforeBlobSize': 123,
    'afterBlobSize': 123,
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • hunks (list) --

      An ordered list of diff hunks. Each hunk represents a contiguous run of changed and adjacent context lines. The list is empty when the blobs are identical or when the content is binary. The list is also empty when a paginated request has already returned all hunks in earlier pages, in which case NextToken is also null.

      • (dict) --

        A contiguous run of changed lines from a blob diff, together with any surrounding unchanged context lines. Hunks are returned in order from the start of the file to the end. Adjacent or overlapping hunks are merged into a single hunk in the response.

        • beforeStartLine (integer) --

          The 1-based line number in the before blob where this hunk begins. When the hunk consists entirely of additions, beforeLineCount is 0.

        • beforeLineCount (integer) --

          The number of lines from the before blob covered by this hunk, including any context lines.

        • afterStartLine (integer) --

          The 1-based line number in the after blob where this hunk begins. When the hunk consists entirely of deletions, afterLineCount is 0.

        • afterLineCount (integer) --

          The number of lines from the after blob covered by this hunk, including any context lines.

        • changes (list) --

          An ordered list of line-level changes that make up this hunk. Each entry indicates whether the line is unchanged context, an addition, or a deletion.

          • (dict) --

            A single line-level entry in a diff hunk. Each DiffChange describes one line and its change type: unchanged context, an addition in the after blob, or a deletion from the before blob.

            • type (string) --

              The type of change for this line. Possible values:

              • CONTEXT – Unchanged line included for surrounding context.

              • ADD – Line added in the after blob.

              • DELETE – Line removed from the before blob.

            • beforeLineNumber (integer) --

              The 1-based line number in the before blob. This field is omitted for ADD lines.

            • afterLineNumber (integer) --

              The 1-based line number in the after blob. This field is omitted for DELETE lines.

            • content (string) --

              The text content of the line, without the trailing newline.

    • isBinary (boolean) --

      Specifies whether the operation treated the diff content as binary. When true, the operation does not compute a line-level diff and hunks is empty.

    • beforeBlobSize (integer) --

      The size, in bytes, of the blob identified by beforeBlobId. Returns 0 when you do not specify beforeBlobId.

    • afterBlobSize (integer) --

      The size, in bytes, of the blob identified by afterBlobId.

    • NextToken (string) --

      An enumeration token that can be used in a request to return the next batch of DiffHunk entries. null when the response contains the final page of the diff.