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').
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
- the list of changed files with their state - use
ek9_git_status. - commit messages, authors and dates - use
ek9_git_log. - per-line authorship of a file - use
ek9_git_blame. - a file's current content - use
ek9_read_file.
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
| Argument | Type | Required | What it is |
|---|---|---|---|
contextLines | integer | Unchanged lines around each hunk. Default 3. | |
from | string | Start ref for scope:'range' (with to), or the commit for scope:'commit'. | |
path | string | Workspace-relative file or directory to narrow the diff to. Default: everything. | |
ref | string | One commit to show (sha, tag, HEAD~1) - shorthand for scope:'commit' with from. | |
scope | string: working | staged | range | commit | What 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). | |
to | string | End 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.