ek9_git_diff

Answers first: summary, fileCount, additions/deletions and changedFiles names, then per-file hunks with fromLine/toLine and the unified-diff text (dropped at verbosity:'summary').

Category: Enquiry · Compare: git diff / Diff view

When to use it

'What did I change?' - one call, no arguments for the working tree; scope:'staged', ref:'<sha>' for one commit, or from/to for a range. Narrow to a file or directory with path.

When not to use it

Details

Headline first: summary, scope, fromRef/toRef, fileCount, additions, deletions and the changedFiles names; then files[] as {file, change, additions, deletions, hunks[]} with change one of modified / added / deleted / renamed / copied and each hunk carrying fromLine/fromCount/toLine/toCount plus the unified-diff text. verbosity:'summary' keeps the per-file counts and drops the hunks. ref is the one-commit shorthand for scope:'commit' + from.

Arguments

ArgumentTypeRequiredWhat it is
contextLinesintegerUnchanged lines around each hunk. Default 3.
fromstringStart ref for scope:'range' (with to), or the commit for scope:'commit'.
pathstringWorkspace-relative file or directory to narrow the diff to. Default: everything.
refstringOne commit to show (sha, tag, HEAD~1) - shorthand for scope:'commit' with from.
scopestring: working | staged | range | commitWhat to compare. Default working (working tree vs HEAD); staged (index vs HEAD); commit (one commit vs its parent, needs ref or from); range (from..to).
tostringEnd ref for scope:'range'.

It also takes the arguments every tool takes.

Recorded calls

Real calls, recorded against small projects and checked on every build - a changed answer fails it.

Working tree hunks

Request

{
  "scope" : "working"
}

Response

{
  "additions" : 1,
  "changedFiles" : [ "tracked.txt" ],
  "deletions" : 0,
  "fileCount" : 1,
  "files" : [ {
    "additions" : 1,
    "change" : "modified",
    "deletions" : 0,
    "file" : "tracked.txt",
    "hunks" : [ {
      "diff" : "@@ -1,2 +1,3 @@\n v1\n v2\n+v3-added\n",
      "fromCount" : 2,
      "fromLine" : 1,
      "toCount" : 3,
      "toLine" : 1
    } ],
    "status" : "M"
  } ],
  "fromRef" : "HEAD",
  "meta" : {
    "serverMs" : "<timing>"
  },
  "scope" : "working",
...

Cut short here: 4 more lines. The whole recorded call.