Jump to >

Diff List Resource

Provides information on a collection of complete diffs.

Each diff contains individual per-file diffs as child resources. A diff is revisioned, and more than one can be associated with any particular review request.

Details

Name diffs
URI /api/review-requests/{review_request_id}/diffs/
Token Policy ID diff
HTTP Methods
  • GET - Returns the list of public diffs on the review request.
  • POST - Creates a new diff by parsing an uploaded diff file.
Parent Resource Review Request Resource
Child Resources
Anonymous Access Yes, if anonymous site access is enabled

HTTP GET

Returns the list of public diffs on the review request.

Each diff has a revision and list of per-file diffs associated with it.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden Your OAuth2 token lacks the necessary scopes for this request.
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden OAuth2 token access for this resource is prohibited.

HTTP POST

Creates a new diff by parsing an uploaded diff file.

This will implicitly create the new Review Request draft, which can be updated separately and then published.

This accepts a unified diff file, validates it, and stores it along with the draft of a review request. The new diff will have a revision of 0.

A parent diff can be uploaded along with the main diff. A parent diff is a diff based on an existing commit in the repository, which will be applied before the main diff. The parent diff will not be included in the diff viewer. It’s useful when developing a change based on a branch that is not yet committed. In this case, a parent diff of the parent branch would be provided along with the diff of the new commit, and only the new commit will be shown.

It is expected that the client will send the data as part of a multipart/form-data mimetype. The main diff’s name and content would be stored in the path field. If a parent diff is provided, its name and content would be stored in the parent_diff_path field.

An example of this would be:

-- SoMe BoUnDaRy
Content-Disposition: form-data; name=path; filename="foo.diff"

<Unified Diff Content Here>
-- SoMe BoUnDaRy --

Extra data can be stored later lookup. See Storing/Accessing Extra Data for more information.

Request Parameters

base_commit_idString

The ID/revision this change is built upon. If using a parent diff, then this is the base for that diff. This may not be provided for all diffs or repository types, depending on how the diff was uploaded.

Added in 1.7.13

basedirString The base directory that will prepended to all paths in the diff. This is needed for some types of repositories. The directory must be between the root of the repository and the top directory referenced in the diff paths.
parent_diff_pathUploaded file The optional parent diff to upload.
pathUploaded file The main diff to upload.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
102 - Invalid AttributeHTTP 400 - Bad Request Invalid attribute
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in
105 - Invalid Form DataHTTP 400 - Bad Request One or more fields had errors
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden Your OAuth2 token lacks the necessary scopes for this request.
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden OAuth2 token access for this resource is prohibited.
207 - Repository File Not FoundHTTP 400 - Bad Request The file was not found in the repository.
219 - Diff EmptyHTTP 400 - Bad Request The specified diff file is empty.
220 - Diff Too BigHTTP 400 - Bad Request The specified diff file is too large.

Examples

application/vnd.reviewboard.org.diffs+json

$ curl http://reviews.example.com/api10/ -H "Accept: application/json"
Vary: Accept, Cookie
Item-Content-Type: application/vnd.reviewboard.org.diff+json
Content-Type: application/vnd.reviewboard.org.diffs+json
ETag: c9d4d04c313be9a65b805af56c0efe24153d264e
X-Content-Type-Options: nosniff
{
  "diffs": [
    {
      "base_commit_id": "1baa5285167980271becd922acd77a20a20b916b", 
      "basedir": "", 
      "commit_count": 1, 
      "extra_data": {}, 
      "id": 13, 
      "links": {
        "commits": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/1/commits/", 
          "method": "GET"
        }, 
        "files": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/1/files/", 
          "method": "GET"
        }, 
        "repository": {
          "href": "http://reviews.example.com/api/repositories/3/", 
          "method": "GET", 
          "title": "Git Repo"
        }, 
        "self": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/1/", 
          "method": "GET"
        }, 
        "update": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/1/", 
          "method": "PUT"
        }
      }, 
      "name": "diff", 
      "revision": 1, 
      "timestamp": "2018-08-10T22:16:22Z"
    }, 
    {
      "base_commit_id": "1baa5285167980271becd922acd77a20a20b916b", 
      "basedir": "", 
      "commit_count": 2, 
      "extra_data": {}, 
      "id": 14, 
      "links": {
        "commits": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/2/commits/", 
          "method": "GET"
        }, 
        "files": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/2/files/", 
          "method": "GET"
        }, 
        "repository": {
          "href": "http://reviews.example.com/api/repositories/3/", 
          "method": "GET", 
          "title": "Git Repo"
        }, 
        "self": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/2/", 
          "method": "GET"
        }, 
        "update": {
          "href": "http://reviews.example.com/api/review-requests/10/diffs/2/", 
          "method": "PUT"
        }
      }, 
      "name": "diff", 
      "revision": 2, 
      "timestamp": "2018-08-10T22:16:47Z"
    }
  ], 
  "links": {
    "create": {
      "href": "http://reviews.example.com/api10/", 
      "method": "POST"
    }, 
    "self": {
      "href": "http://reviews.example.com/api10/", 
      "method": "GET"
    }
  }, 
  "stat": "ok", 
  "total_results": 2
}