summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/status.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-28 18:27:14 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:24 +1000
commit4c5b1574f147fe2005bcd30bbb5dc106c4838b92 (patch)
treece7fada27e54f793024e740add3e5779a2c63262 /pkg/commands/git_commands/status.go
parentde57cfd6ff17751f7243476441beab6486fb4381 (diff)
Centralise logic for obtaining repo paths
There are quite a few paths you might want to get e.g. the repo's path, the worktree's path, the repo's git dir path, the worktree's git dir path. I want these all obtained once and then used when needed rather than having to have IO whenever we need them. This is not so much about reducing time spent on IO as it is about not having to care about errors every time we want a path.
Diffstat (limited to 'pkg/commands/git_commands/status.go')
-rw-r--r--pkg/commands/git_commands/status.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/commands/git_commands/status.go b/pkg/commands/git_commands/status.go
index 7f03c698e..13ff02cc0 100644
--- a/pkg/commands/git_commands/status.go
+++ b/pkg/commands/git_commands/status.go
@@ -24,14 +24,14 @@ func NewStatusCommands(
// RebaseMode returns "" for non-rebase mode, "normal" for normal rebase
// and "interactive" for interactive rebase
func (self *StatusCommands) RebaseMode() (enums.RebaseMode, error) {
- exists, err := self.os.FileExists(filepath.Join(self.dotGitDir, "rebase-apply"))
+ exists, err := self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-apply"))
if err != nil {
return enums.REBASE_MODE_NONE, err
}
if exists {
return enums.REBASE_MODE_NORMAL, nil
}
- exists, err = self.os.FileExists(filepath.Join(self.dotGitDir, "rebase-merge"))
+ exists, err = self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-merge"))
if exists {
return enums.REBASE_MODE_INTERACTIVE, err
} else {
@@ -69,5 +69,5 @@ func IsBareRepo(osCommand *oscommands.OSCommand) (bool, error) {
// IsInMergeState states whether we are still mid-merge
func (self *StatusCommands) IsInMergeState() (bool, error) {
- return self.os.FileExists(filepath.Join(self.dotGitDir, "MERGE_HEAD"))
+ return self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "MERGE_HEAD"))
}