@@ -36,10 +36,12 @@ func TestGetRepoPaths(t *testing.T) {
3636 "/path/to/repo/.git" ,
3737 // --git-common-dir
3838 "/path/to/repo/.git" ,
39+ // --is-bare-repository
40+ "false" ,
3941 // --show-superproject-working-tree
4042 }
4143 runner .ExpectGitArgs (
42- append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--show-superproject-working-tree" ),
44+ append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--is-bare-repository" , "-- show-superproject-working-tree" ),
4345 strings .Join (expectedOutput , "\n " ),
4446 nil )
4547 },
@@ -50,6 +52,38 @@ func TestGetRepoPaths(t *testing.T) {
5052 repoPath : "/path/to/repo" ,
5153 repoGitDirPath : "/path/to/repo/.git" ,
5254 repoName : "repo" ,
55+ isBareRepo : false ,
56+ },
57+ Err : nil ,
58+ },
59+ {
60+ Name : "bare repo" ,
61+ BeforeFunc : func (runner * oscommands.FakeCmdObjRunner , getRevParseArgs argFn ) {
62+ // setup for main worktree
63+ expectedOutput := []string {
64+ // --show-toplevel
65+ "/path/to/repo" ,
66+ // --git-dir
67+ "/path/to/bare_repo/bare.git" ,
68+ // --git-common-dir
69+ "/path/to/bare_repo/bare.git" ,
70+ // --is-bare-repository
71+ "true" ,
72+ // --show-superproject-working-tree
73+ }
74+ runner .ExpectGitArgs (
75+ append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--is-bare-repository" , "--show-superproject-working-tree" ),
76+ strings .Join (expectedOutput , "\n " ),
77+ nil )
78+ },
79+ Path : "/path/to/repo" ,
80+ Expected : & RepoPaths {
81+ worktreePath : "/path/to/repo" ,
82+ worktreeGitDirPath : "/path/to/bare_repo/bare.git" ,
83+ repoPath : "/path/to/bare_repo" ,
84+ repoGitDirPath : "/path/to/bare_repo/bare.git" ,
85+ repoName : "bare_repo" ,
86+ isBareRepo : true ,
5387 },
5488 Err : nil ,
5589 },
@@ -63,11 +97,13 @@ func TestGetRepoPaths(t *testing.T) {
6397 "/path/to/repo/.git/modules/submodule1" ,
6498 // --git-common-dir
6599 "/path/to/repo/.git/modules/submodule1" ,
100+ // --is-bare-repository
101+ "false" ,
66102 // --show-superproject-working-tree
67103 "/path/to/repo" ,
68104 }
69105 runner .ExpectGitArgs (
70- append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--show-superproject-working-tree" ),
106+ append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--is-bare-repository" , "-- show-superproject-working-tree" ),
71107 strings .Join (expectedOutput , "\n " ),
72108 nil )
73109 },
@@ -78,14 +114,15 @@ func TestGetRepoPaths(t *testing.T) {
78114 repoPath : "/path/to/repo/submodule1" ,
79115 repoGitDirPath : "/path/to/repo/.git/modules/submodule1" ,
80116 repoName : "submodule1" ,
117+ isBareRepo : false ,
81118 },
82119 Err : nil ,
83120 },
84121 {
85122 Name : "git rev-parse returns an error" ,
86123 BeforeFunc : func (runner * oscommands.FakeCmdObjRunner , getRevParseArgs argFn ) {
87124 runner .ExpectGitArgs (
88- append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--show-superproject-working-tree" ),
125+ append (getRevParseArgs (), "--show-toplevel" , "--absolute-git-dir" , "--git-common-dir" , "--is-bare-repository" , "-- show-superproject-working-tree" ),
89126 "" ,
90127 errors .New ("fatal: invalid gitfile format: /path/to/repo/worktree2/.git" ))
91128 },
@@ -94,7 +131,7 @@ func TestGetRepoPaths(t *testing.T) {
94131 Err : func (getRevParseArgs argFn ) error {
95132 args := strings .Join (getRevParseArgs (), " " )
96133 return errors .New (
97- fmt .Sprintf ("'git %v --show-toplevel --absolute-git-dir --git-common-dir --show-superproject-working-tree' failed: fatal: invalid gitfile format: /path/to/repo/worktree2/.git" , args ),
134+ fmt .Sprintf ("'git %v --show-toplevel --absolute-git-dir --git-common-dir --is-bare-repository -- show-superproject-working-tree' failed: fatal: invalid gitfile format: /path/to/repo/worktree2/.git" , args ),
98135 )
99136 },
100137 },
@@ -120,7 +157,7 @@ func TestGetRepoPaths(t *testing.T) {
120157 // prepare the filesystem for the scenario
121158 s .BeforeFunc (runner , getRevParseArgs )
122159
123- repoPaths , err := GetRepoPaths ( cmd , version )
160+ repoPaths , err := GetRepoPathsForDir ( "" , cmd , version )
124161
125162 // check the error and the paths
126163 if s .Err != nil {
0 commit comments