Skip to content

Commit c20cbb8

Browse files
committed
Repository.gitDir: rename member from path
The name `gitDir` is less ambiguous. Also rename method `Path()` to `GitDir()`.
1 parent 2ed1053 commit c20cbb8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

git/git.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ type ObjectType string
1515

1616
// Repository represents a Git repository on disk.
1717
type Repository struct {
18-
path string
18+
// gitDir is the path to the `GIT_DIR` for this repository. It
19+
// might be absolute or it might be relative to the current
20+
// directory.
21+
gitDir string
1922

2023
// gitBin is the path of the `git` executable that should be used
2124
// when running commands in this repository.
@@ -79,7 +82,7 @@ func NewRepository(path string) (*Repository, error) {
7982
}
8083

8184
return &Repository{
82-
path: gitDir,
85+
gitDir: gitDir,
8386
gitBin: gitBin,
8487
}, nil
8588
}
@@ -103,15 +106,16 @@ func (repo *Repository) GitCommand(callerArgs ...string) *exec.Cmd {
103106

104107
cmd.Env = append(
105108
os.Environ(),
106-
"GIT_DIR="+repo.path,
109+
"GIT_DIR="+repo.gitDir,
107110
// Disable grafts when running our commands:
108111
"GIT_GRAFT_FILE="+os.DevNull,
109112
)
110113

111114
return cmd
112115
}
113116

114-
// Path returns the path to `repo`.
115-
func (repo *Repository) Path() string {
116-
return repo.path
117+
// GitDir returns the path to `repo`'s `GIT_DIR`. It might be absolute
118+
// or it might be relative to the current directory.
119+
func (repo *Repository) GitDir() string {
120+
return repo.gitDir
117121
}

0 commit comments

Comments
 (0)