diff --git a/lib/src/git_types.dart b/lib/src/git_types.dart index 4518818..e77b877 100644 --- a/lib/src/git_types.dart +++ b/lib/src/git_types.dart @@ -550,6 +550,10 @@ class GitCheckout { /// Normally checkout writes the index upon completion; this prevents that. static const dontWriteIndex = GitCheckout._(8388608, 'dontWriteIndex'); + /// Show what would be done by a checkout. Stop after sending + /// notifications; don't update the working directory or index. + static const dryRun = GitCheckout._(16777216, 'dryRun'); + static const List values = [ none, safe, @@ -571,6 +575,7 @@ class GitCheckout { conflictStyleDiff3, dontRemoveExisting, dontWriteIndex, + dryRun ]; int get value => _value; diff --git a/test/checkout_test.dart b/test/checkout_test.dart index 0577348..de03fa6 100644 --- a/test/checkout_test.dart +++ b/test/checkout_test.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'package:libgit2dart/src/git_types.dart'; import 'package:test/test.dart'; import 'package:libgit2dart/libgit2dart.dart'; import 'helpers/util.dart'; @@ -93,5 +94,20 @@ void main() { }, ); }); + + test('successfully performs dry run checkout', () { + final index = repo.index; + expect(index.length, 4); + expect(File('${repo.workdir}/another_feature_file').existsSync(), false); + + repo.checkout( + refName: 'refs/heads/feature', + strategy: {GitCheckout.dryRun}, + ); + expect(index.length, 4); + expect(File('${repo.workdir}/another_feature_file').existsSync(), false); + + index.free(); + }); }); }