Skip to content

bb diff

Print the diff of a pull request, a commit or two refs

3 commands.

bb diff commit
Diff a commit against its parent
bb diff pr
Diff a pull request
bb diff refs
Diff two refs or commits

bb diff commit

Diff a commit against its parent

bb diff commit <commit> [flags]
# What one commit changed
bb diff commit a1b2c3d --repo PROJ/repo

# In one file
bb diff commit a1b2c3d --repo PROJ/repo --path src/main.go
--path string
Optional file path for file-scoped diff

Inherited from bb diff:

--repo string
Repository as PROJECT/slug (defaults to the repository of the git checkout you are in, then BITBUCKET_PROJECT_KEY + BITBUCKET_REPO_SLUG)

Also takes the global flags.

Dry run: Runs as usual: this command changes nothing, so there is nothing to hold back

Output with --json, where ? marks a field that can be absent
data
  repository    object
    projectKey  string                Project key the repository belongs to.
    slug        string                Repository slug.
  output        patch|stat|name-only  Which form was produced: patch, stat or name-only.
  patch?        string                The unified diff, when output is patch.
  names?        list of string        Paths that differ, when output is name-only.
  stats?        map of any            Per-file addition and deletion counts, when output is stat.

bb diff pr

Diff a pull request

bb diff pr <pr-id> [flags]

Also available as bb pr diff, which is the gh spelling.

# The diff of a pull request
bb diff pr 42 --repo PROJ/repo

# Only the names of the files it changes
bb diff pr 42 --repo PROJ/repo --name-only

# As a patch, saved to a file
bb diff pr 42 --repo PROJ/repo --patch > pr-42.patch
--name-only
Output only changed file names
--patch
Output unified patch stream
--stat
Output structured diff stats

Inherited from bb diff:

--repo string
Repository as PROJECT/slug (defaults to the repository of the git checkout you are in, then BITBUCKET_PROJECT_KEY + BITBUCKET_REPO_SLUG)

Also takes the global flags.

Dry run: Runs as usual: this command changes nothing, so there is nothing to hold back

Output with --json, where ? marks a field that can be absent
data
  repository    object
    projectKey  string                Project key the repository belongs to.
    slug        string                Repository slug.
  output        patch|stat|name-only  Which form was produced: patch, stat or name-only.
  patch?        string                The unified diff, when output is patch.
  names?        list of string        Paths that differ, when output is name-only.
  stats?        map of any            Per-file addition and deletion counts, when output is stat.

bb diff refs

Diff two refs or commits

bb diff refs <from> <to> [flags]
# What feature/x changes relative to main
bb diff refs main feature/x --repo PROJ/repo

# As added and removed line counts per file
bb diff refs main feature/x --repo PROJ/repo --stat
--name-only
Output only changed file names
--patch
Output unified patch stream
--path string
Optional file path for file-scoped diff
--stat
Output structured diff stats

Inherited from bb diff:

--repo string
Repository as PROJECT/slug (defaults to the repository of the git checkout you are in, then BITBUCKET_PROJECT_KEY + BITBUCKET_REPO_SLUG)

Also takes the global flags.

Dry run: Runs as usual: this command changes nothing, so there is nothing to hold back

Output with --json, where ? marks a field that can be absent
data
  repository    object
    projectKey  string                Project key the repository belongs to.
    slug        string                Repository slug.
  output        patch|stat|name-only  Which form was produced: patch, stat or name-only.
  patch?        string                The unified diff, when output is patch.
  names?        list of string        Paths that differ, when output is name-only.
  stats?        map of any            Per-file addition and deletion counts, when output is stat.