@@ -33,9 +33,7 @@ public class GitRepository : IDisposable
3333 /// <summary>
3434 /// Creates a new instance of the <see cref="GitRepository"/> class.
3535 /// </summary>
36- /// <param name="workingDirectory">
37- /// The current working directory. This can be a subdirectory of the Git repository.
38- /// </param>
36+ /// <param name="workingDirectory"><inheritdoc cref="GitRepository(string, string, string, string)" path="/param[@name='workingDirectory']" /></param>
3937 /// <returns>
4038 /// A <see cref="GitRepository"/> which represents the git repository, or <see langword="null"/>
4139 /// if no git repository was found.
@@ -93,18 +91,10 @@ public class GitRepository : IDisposable
9391 /// <summary>
9492 /// Creates a new instance of the <see cref="GitRepository"/> class.
9593 /// </summary>
96- /// <param name="workingDirectory">
97- /// The current working directory. This can be a subdirectory of the Git repository.
98- /// </param>
99- /// <param name="gitDirectory">
100- /// The directory in which git metadata (such as refs,...) is stored.
101- /// </param>
102- /// <param name="commonDirectory">
103- /// The common Git directory, in which Git objects are stored.
104- /// </param>
105- /// <param name="objectDirectory">
106- /// The object directory in which Git objects are stored.
107- /// </param>
94+ /// <param name="workingDirectory"><inheritdoc cref="GitRepository(string, string, string, string)" path="/param[@name='workingDirectory']" /></param>
95+ /// <param name="gitDirectory"><inheritdoc cref="GitRepository(string, string, string, string)" path="/param[@name='gitDirectory']" /> </param>
96+ /// <param name="commonDirectory"><inheritdoc cref="GitRepository(string, string, string, string)" path="/param[@name='commonDirectory']" /></param>
97+ /// <param name="objectDirectory"><inheritdoc cref="GitRepository(string, string, string, string)" path="/param[@name='objectDirectory']" /></param>
10898 public static GitRepository Create ( string workingDirectory , string gitDirectory , string commonDirectory , string objectDirectory )
10999 {
110100 return new GitRepository ( workingDirectory , gitDirectory , commonDirectory , objectDirectory ) ;
@@ -117,10 +107,10 @@ public static GitRepository Create(string workingDirectory, string gitDirectory,
117107 /// The current working directory. This can be a subdirectory of the Git repository.
118108 /// </param>
119109 /// <param name="gitDirectory">
120- /// The directory in which git metadata (such as refs,...) is stored .
110+ /// The directory in which the git HEAD file is stored. This is the .git directory unless the working directory is a worktree .
121111 /// </param>
122112 /// <param name="commonDirectory">
123- /// The common Git directory, in which Git objects are stored .
113+ /// The common Git directory, which is parent to the objects, refs, and other directories .
124114 /// </param>
125115 /// <param name="objectDirectory">
126116 /// The object directory in which Git objects are stored.
@@ -191,7 +181,8 @@ public GitRepository(string workingDirectory, string gitDirectory, string common
191181 public string WorkingDirectory { get ; private set ; }
192182
193183 /// <summary>
194- /// Gets the path to the Git directory, in which metadata (e.g. references and configuration) is stored.
184+ /// Gets the path to the Git directory, in which at minimum HEAD is stored.
185+ /// Use <see cref="CommonDirectory"/> for all other metadata (e.g. references, configuration).
195186 /// </summary>
196187 public string GitDirectory { get ; private set ; }
197188
@@ -333,9 +324,9 @@ public GitCommit GetCommit(GitObjectId sha, bool readAuthor = false)
333324 else
334325 {
335326 // Look for simple names for branch or tag.
336- possibleLooseFileMatches . Add ( Path . Combine ( this . GitDirectory , "refs" , "heads" , objectish ) ) ;
337- possibleLooseFileMatches . Add ( Path . Combine ( this . GitDirectory , "refs" , "tags" , objectish ) ) ;
338- possibleLooseFileMatches . Add ( Path . Combine ( this . GitDirectory , "refs" , "remotes" , objectish ) ) ;
327+ possibleLooseFileMatches . Add ( Path . Combine ( this . CommonDirectory , "refs" , "heads" , objectish ) ) ;
328+ possibleLooseFileMatches . Add ( Path . Combine ( this . CommonDirectory , "refs" , "tags" , objectish ) ) ;
329+ possibleLooseFileMatches . Add ( Path . Combine ( this . CommonDirectory , "refs" , "remotes" , objectish ) ) ;
339330 }
340331
341332 if ( possibleLooseFileMatches . FirstOrDefault ( File . Exists ) is string existingPath )
@@ -344,7 +335,7 @@ public GitCommit GetCommit(GitObjectId sha, bool readAuthor = false)
344335 }
345336
346337 // Match in packed-refs file.
347- string packedRefPath = Path . Combine ( this . GitDirectory , "packed-refs" ) ;
338+ string packedRefPath = Path . Combine ( this . CommonDirectory , "packed-refs" ) ;
348339 if ( File . Exists ( packedRefPath ) )
349340 {
350341 using var refReader = File . OpenText ( packedRefPath ) ;
@@ -653,7 +644,7 @@ private GitObjectId ResolveReference(object reference)
653644 {
654645 if ( reference is string )
655646 {
656- if ( ! FileHelpers . TryOpen ( Path . Combine ( this . GitDirectory , ( string ) reference ) , out FileStream ? stream ) )
647+ if ( ! FileHelpers . TryOpen ( Path . Combine ( this . CommonDirectory , ( string ) reference ) , out FileStream ? stream ) )
657648 {
658649 return GitObjectId . Empty ;
659650 }
0 commit comments