You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: LibGit2Sharp.Tests/WorktreeFixture.cs
+105-4
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@
3
3
usingSystem.Collections.Generic;
4
4
usingSystem.IO;
5
5
usingSystem.Linq;
6
-
usingSystem.Text;
7
-
usingSystem.Threading.Tasks;
8
6
usingXunit;
9
7
10
8
namespaceLibGit2Sharp.Tests
@@ -238,7 +236,7 @@ public void CanForcePruneLockedWorktree()
238
236
}
239
237
240
238
[Fact]
241
-
publicvoidCanAddWorktree()
239
+
publicvoidCanAddWorktree_WithUncommitedChanges()
242
240
{
243
241
varrepoPath=SandboxWorktreeTestRepo();
244
242
using(varrepo=newRepository(repoPath))
@@ -252,15 +250,96 @@ public void CanAddWorktree()
252
250
Assert.False(worktree.IsLocked);
253
251
254
252
Assert.Equal(3,repo.Worktrees.Count());
253
+
254
+
// Check that branch contains same number of files and folders
255
+
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com./libgit2/libgit2sharp/issues/2037)
256
+
Assert.True(repo.RetrieveStatus().IsDirty);
257
+
varfilesInMain=GetFilesOfRepo(repoPath);
258
+
varfilesInBranch=GetFilesOfRepo(path);
259
+
Assert.NotEqual(filesInMain,filesInBranch);
260
+
261
+
repo.Reset(ResetMode.Hard);
262
+
repo.RemoveUntrackedFiles();
263
+
264
+
Assert.False(repo.RetrieveStatus().IsDirty);
265
+
filesInMain=GetFilesOfRepo(repoPath);
266
+
filesInBranch=GetFilesOfRepo(path);
267
+
Assert.Equal(filesInMain,filesInBranch);
268
+
}
269
+
}
270
+
271
+
[Fact]
272
+
publicvoidCanAddWorktree_WithCommitedChanges()
273
+
{
274
+
varrepoPath=SandboxWorktreeTestRepo();
275
+
using(varrepo=newRepository(repoPath))
276
+
{
277
+
// stage all changes
278
+
Commands.Stage(repo,"*");
279
+
repo.Commit("Apply all changes",Constants.Signature,Constants.Signature);
// Check that branch contains same number of files and folders
292
+
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com./libgit2/libgit2sharp/issues/2037)
// Check that branch contains same number of files and folders
317
+
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com./libgit2/libgit2sharp/issues/2037)
repo.Commit("Apply all changes",Constants.Signature,Constants.Signature);
342
+
264
343
Assert.Equal(2,repo.Worktrees.Count());
265
344
266
345
varname="blah";
@@ -270,6 +349,13 @@ public void CanAddLockedWorktree()
270
349
Assert.True(worktree.IsLocked);
271
350
272
351
Assert.Equal(3,repo.Worktrees.Count());
352
+
353
+
// Check that branch contains same number of files and folders
354
+
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com./libgit2/libgit2sharp/issues/2037)
355
+
Assert.False(repo.RetrieveStatus().IsDirty);
356
+
varfilesInMain=GetFilesOfRepo(repoPath);
357
+
varfilesInBranch=GetFilesOfRepo(path);
358
+
Assert.Equal(filesInMain,filesInBranch);
273
359
}
274
360
}
275
361
@@ -292,7 +378,22 @@ public void CanAddWorktreeForCommittish()
// Check that branch contains same number of files and folders
383
+
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com./libgit2/libgit2sharp/issues/2037)
// Proxy.git_worktree_add() creates a new branch of name = name, so if we want to checkout a given branch then the 'name' cannot be the same as the target branch
0 commit comments