Help Center/ CodeArts Repo/ API Reference/ APIs/ V4/ Commit/ Obtaining the Change Content of a Specified File Introduced by a Commit
Updated on 2026-04-28 GMT+08:00

Obtaining the Change Content of a Specified File Introduced by a Commit

Function

This API is used to obtain the change content of a specified file introduced by a commit.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

GET https://{hostURL}/v4/repositories/{repository_id}/repository/commits/file-diff

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Definition

You can query the project list to obtain the repository ID by calling the API used to query user's all repositories.

Constraints

N/A.

Value range:

1~2147483647

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

sha

Yes

String

Definition

Branch name, tag name, or commit ID.

path

No

String

Definition

File path.

Range

1–100,000 characters.

old_path

No

String

Definition

Path of the file before renaming.

Range

1–100,000 characters.

ignore_whitespace_change

No

Boolean

Definition

Whether to ignore the change of blank quantity.

Range

  • true: ignore the change of blank quantity.

  • false: not to ignore the change of blank quantity.

Default value:

false

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. Obtain a token by calling the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the user token.

Constraints

Mandatory.

Range

1–100,000 characters.

Default Value

N/A.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

[items]

Array of FileDiffDto objects

File difference list

Table 5 FileDiffDto

Parameter

Type

Description

old_path

String

Definition

Old file name.

Range

1–10,000 characters.

new_path

AnyType

Definition

New file name.

Range

1–10,000 characters.

a_mode

String

Definition

Old file permissions.

b_mode

String

Definition

New file permissions.

new_file

Boolean

Definition

New file or not.

Range

  • true: new file.

  • false: not a new file

renamed_file

Boolean

Definition

Renamed file or not.

Range

  • true: renamed file.

  • false: not a renamed file

deleted_file

Boolean

Definition

Deleted file or not.

Range

  • true: deleted file.

  • false: non-deleted file.

diff

String

Definition

Difference information.

too_large

Boolean

Definition

Large file or not.

Range

  • true: large file.

  • false: not a large file

added_lines

Integer

Definition

Number of added lines.

Value range:

0~2147483647

removed_lines

Integer

Definition

Number of deleted lines.

Value range:

0~2147483647

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error message.

Example Requests

GET https://{endpoint}/v4/repositories/2111915566/repository/commits/file-diff?sha=master&path=date2&old_path=date

Example Responses

Status code: 200

ok

{
  "old_path" : "date2",
  "new_path" : "date2",
  "a_mode" : "100644",
  "b_mode" : "0",
  "new_file" : false,
  "renamed_file" : false,
  "deleted_file" : true,
  "diff" : "@@ -1 +0,0 @@\\n-11\\n\\\\ No newline at end of file",
  "too_large" : false,
  "added_lines" : 0,
  "removed_lines" : 1
}

Status code: 401

Unauthorized

{
  "error_code" : "DEV.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

ok

401

Unauthorized

Error Codes

See Error Codes.