mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-06 21:08:56 -04:00
Add a way to run GetDiff in another worktree
The next commit carries a line of a diff forward to the file as another worktree has it, and needs to diff against that worktree's working copy for this. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
64fd7d8686
commit
f343c8fd50
@@ -186,15 +186,26 @@ func (self *DiffCommands) CustomPatchDiffCmdObj(dir string, mode DiffMode) *osco
|
||||
// want to restrict the diff to specific paths, pass them in additionalArgs
|
||||
// after the `--`.
|
||||
func (self *DiffCommands) GetDiff(staged bool, additionalArgs ...string) (string, error) {
|
||||
return self.getDiffCmdObj(self.repoPaths.worktreePath, staged, additionalArgs).RunWithOutput()
|
||||
}
|
||||
|
||||
// GetDiffInOtherWorktree is GetDiff without --staged, run in the worktree at
|
||||
// worktreePath. That has to be a worktree of our repo other than the current one. A
|
||||
// diff against the working copy is then a diff against that worktree's files.
|
||||
func (self *DiffCommands) GetDiffInOtherWorktree(worktreePath string, additionalArgs ...string) (string, error) {
|
||||
return ForOtherRepo(self.getDiffCmdObj(worktreePath, false, additionalArgs)).RunWithOutput()
|
||||
}
|
||||
|
||||
func (self *DiffCommands) getDiffCmdObj(worktreePath string, staged bool, additionalArgs []string) *oscommands.CmdObj {
|
||||
return self.cmd.New(
|
||||
NewGitCmd("diff").
|
||||
ParseableDiffPrefixes().
|
||||
Arg("--no-ext-diff", "--no-color").
|
||||
ArgIf(staged, "--staged").
|
||||
Dir(self.repoPaths.worktreePath).
|
||||
Dir(worktreePath).
|
||||
Arg(additionalArgs...).
|
||||
ToArgv(),
|
||||
).DontLog().RunWithOutput()
|
||||
).DontLog()
|
||||
}
|
||||
|
||||
type DiffToolCmdOptions struct {
|
||||
|
||||
Reference in New Issue
Block a user