diff --git a/CHANGELOG.md b/CHANGELOG.md index 1920e3ba..a922704a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.1 + +* Fix `safe.bareRepository = explicit` git configuration. + ## 2.3.0 - Added support for lightweight tags. diff --git a/lib/src/git_dir.dart b/lib/src/git_dir.dart index c2f95098..0a3a09fc 100644 --- a/lib/src/git_dir.dart +++ b/lib/src/git_dir.dart @@ -16,17 +16,16 @@ import 'util.dart'; /// Represents a local directory class GitDir { - static const _workTreeArg = '--work-tree='; - static const _gitDirArg = '--git-dir='; + static const _workTreeArg = '--work-tree'; + static const _gitDirArg = '--git-dir'; - final String _path; + final String path; final String? _gitWorkTree; - GitDir._raw(this._path, [this._gitWorkTree]) - : assert(p.isAbsolute(_path)), - assert(_gitWorkTree == null || p.isAbsolute(_gitWorkTree)); - - String get path => _path; + GitDir._raw(this.path, {String? gitWorkTree}) + : assert(p.isAbsolute(path)), + assert(gitWorkTree == null || p.isAbsolute(gitWorkTree)), + _gitWorkTree = gitWorkTree; Future commitCount([String branchName = 'HEAD']) async { final pr = await runCommand(['rev-list', '--count', branchName]); @@ -96,8 +95,9 @@ class GitDir { return []; } - // otherwise, it should have worked fine... - assert(pr.exitCode == 0); + if (pr.exitCode != 0) { + throw ProcessException('git', args, pr.stderr as String, pr.exitCode); + } return CommitReference.fromShowRefOutput(pr.stdout as String); } @@ -276,14 +276,18 @@ class GitDir { ); } - if (_gitWorkTree != null) { - list.insert(0, '$_workTreeArg$_gitWorkTree'); - } - return runGit( - list, + [ + if (_gitWorkTree != null) ...[ + _gitDirArg, + path, + _workTreeArg, + _gitWorkTree, + ], + ...list, + ], throwOnError: throwOnError, - processWorkingDir: _processWorkingDir, + processWorkingDir: path, echoOutput: echoOutput, ); } @@ -336,7 +340,8 @@ class GitDir { ) async { final tempGitRoot = await _createTempDir(); - final tempGitDir = GitDir._raw(tempGitRoot.path, sourceDirectoryPath); + final tempGitDir = + GitDir._raw(tempGitRoot.path, gitWorkTree: sourceDirectoryPath); // time for crazy clone tricks final args = ['clone', '--shared', '--bare', path, '.']; @@ -409,8 +414,6 @@ class GitDir { } } - String get _processWorkingDir => _path.toString(); - static Future isGitDir(String path) async { final dir = Directory(path); diff --git a/pubspec.yaml b/pubspec.yaml index 3b44c1b7..7b440953 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: git -version: 2.3.0 +version: 2.3.1 description: >- Git command line wrapper. Exposes a Git directory abstraction that makes it easy to inspect and manipulate a local Git repository.