File: diffing.go

package info (click to toggle)
lazygit 0.57.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,748 kB
  • sloc: sh: 153; makefile: 76
file content (28 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package diffing

// if ref is blank we're not diffing anything
type Diffing struct {
	Ref     string
	Reverse bool
}

func New() Diffing {
	return Diffing{}
}

func (self *Diffing) Active() bool {
	return self.Ref != ""
}

// GetFromAndReverseArgsForDiff tells us the from and reverse args to be used in a diff command.
// If we're not in diff mode we'll end up with the equivalent of a `git show` i.e `git diff blah^..blah`.
func (self *Diffing) GetFromAndReverseArgsForDiff(from string) (string, bool) {
	reverse := false

	if self.Active() {
		reverse = self.Reverse
		from = self.Ref
	}

	return from, reverse
}