Skip to content

feature: add --commit and --changes command-line options to launch standalone viewers - #2916

Open
RobertFromBerlin wants to merge 2 commits into
sourcegit-org:developfrom
RobertFromBerlin:feature/standalone-viewers
Open

RobertFromBerlin wants to merge 2 commits into
sourcegit-org:developfrom
RobertFromBerlin:feature/standalone-viewers

Conversation

@RobertFromBerlin

Copy link
Copy Markdown

This adds two new command-line options that open SourceGit as a lightweight standalone viewer, similar to the existing --history and --blame options:

<SOURCEGIT_EXEC> --commit <REVISION> [<DIR>]   // details of a commit (same window as "Open in separate window")
<SOURCEGIT_EXEC> --changes [<DIR>]             // uncommitted changes (working tree vs. HEAD)

<DIR> defaults to the current directory. <REVISION> can be anything git understands (SHA, HEAD~2, a branch name, …).

Motivation

For large commits, SourceGit's changes tree with the diff next to it is a very fast way to review changes. These options let you use that view directly from the terminal or from other tools, without opening the full main window.

Implementation notes

  • Both viewers reuse the existing CommitDetailStandalone and RevisionCompareStandalone windows. The repository is opened the same lightweight way DirHistories does it (treated as bare, so no working-copy file operations).
  • The shared setup (resolving the repository root and revision) is in a small helper, OpenRepositoryForStandaloneViewer.
  • Standalone viewers now save preferences on exit, so changing the view mode of the changes list (e.g. to tree) is remembered. Previously preferences were read-only in every launch mode except the main window. Happy to drop or adjust this part if you prefer a different approach.

Also fixes

--history <DIR> didn't work when <DIR> was the repository root (e.g. --history .). It looked up the repository from the parent directory and exited silently. It now uses the directory itself.

Known limitation

--changes is based on git diff HEAD, so untracked files are not listed (same as "Compare with Worktree").

Tested on Windows 11.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant