Skip to content

Compare a file or folder with another revision #15

Description

@Tranthanh98

What would you like to see?

Add “Compare with Revision…” for a selected file or folder so users can compare its current state with a commit, branch, or tag without checking out that revision.

Problem it solves

Users often need the history of one path rather than an entire commit or branch. Today they must locate several commits manually or use Terminal commands to compare a file/folder against an older revision.

Feasibility

High after #14 provides a revision-aware repository browser and path model. Git already supports path-limited diffs and Commit+ already has file-list and hunk rendering. Folder comparison is a changed-file list followed by the existing per-file diff UI.

Proposed UX

  • Add “Compare with Revision…” to file/folder context menus in the revision browser and other suitable path-based views.
  • Open a revision picker that accepts a commit, local branch, remote-tracking branch, or tag.
  • For a file, open the diff directly. For a folder, show the changed paths under that folder and a per-file diff pane.
  • Clearly label both sides, including whether the current side is working tree, index/HEAD, or another revision.
  • Keep the comparison read-only; no checkout or file replacement occurs.

Acceptance criteria

  • A tracked file can be compared between current working-tree state and a selected revision.
  • A folder comparison is path-limited and includes added, deleted, modified, and renamed files beneath it.
  • The UI handles a path that exists on only one side, binary content, renames, and empty results.
  • Revision/path arguments are passed safely and do not interpret a path as an option or ref.
  • Rapid revision changes cancel or ignore stale results.
  • Tests cover file, folder, deletion, rename, spaces/Unicode, uncommitted changes, and invalid revisions.

Implementation notes

Generalize ReferenceDiffView around an optional pathspec. Git supports both arbitrary-commit comparisons and path-limited diffs. Define working-tree semantics explicitly so staged and unstaged changes are not accidentally omitted.

Depends on #14 for the primary repository-tree entry point.

References: https://www.jetbrains.com/help/idea/comparing-file-versions.html and https://git-scm.com/docs/git-diff

Area

Staging / Diff

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions