diff --git a/.gitattributes b/.gitattributes
index be48d6222..9d132e955 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3,5 +3,3 @@
# Custom for Visual Studio
*.cs diff=csharp
-*.sln merge=union
-*.csproj merge=union
diff --git a/.gitignore b/.gitignore
index 7effe32b9..6a6337edb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,8 +37,8 @@ _ReSharper*/
*.DotSettings
#Ignore custom generated files
LibGit2Sharp/Core/UniqueIdentifier.cs
+LibGit2Sharp/Core/NativeDllName.cs
-!Lib/NativeBinaries/*/*.pdb
!nuget.package/build/
_NCrunch_LibGit2Sharp/
packages/
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 30eb68a28..000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "libgit2"]
- path = libgit2
- url = https://github.com/libgit2/libgit2.git
diff --git a/.nuget/packages.config b/.nuget/packages.config
index 05ac50048..0335ab080 100644
--- a/.nuget/packages.config
+++ b/.nuget/packages.config
@@ -1,4 +1,5 @@
-
+
+
diff --git a/.travis.yml b/.travis.yml
index 5ab00c105..700fbd296 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,10 @@ os:
- osx
- linux
+env:
+ global:
+ - MONO_OPTIONS=--debug
+
before_install:
- date -u
- uname -a
diff --git a/CHANGES.md b/CHANGES.md
index fe14217c1..22a41d5b2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,7 +8,53 @@
- @libgit2sharp:
- CI servers:
- Windows (x86/amd64):
- - Linux/MacOsX:
+ - Linux/Mac OS X:
+
+## v0.22 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.21.1...v0.22))
+
+### Additions
+
+ - Add CustomHeaders in the push options (#1217)
+ - Expose the minimal diff algorithm (#1229)
+ - Expose Reset() with checkout options (#1219)
+ - Add a prettify option to history rewrite options (#1185)
+ - Add option to describe to only follow the first parent (#1190)
+ - Allow setting the config search path (#1123)
+ - Provide access to the remote's host HTTPS certificate (#1134)
+ - Add support for rebase (#964)
+ - ListReferences() now accepts a credentials provider (#1099)
+ - Introduce FileStatus.Conflicted and introduce staging of conflicts (#1062)
+ - Support streaming filters written in C# (#1030)
+ - Add support for the pre-push callback (#1061)
+ - Add support for listing remote references without a Repository instance (#1065)
+ - Add StashCollection.Apply() and .Pop() (#1068)
+ - Support retrieving a configuration for a repository without instantiating it (#1042)
+ - Implement 'log --follow'-like functionality (#963)
+ - Introduce in-memory merging via Repository.MergeCommits() (#990)
+ - Allow setting whether to prune during a fetch (#1258)
+
+### Changes
+
+ - Deprecate MergeConflictException in a backwards-compatible way (#1243)
+ - Improve type safety in the generic type for Diff.Compare() (#1180)
+ - Obsolete Repository.Commit(), NoteCollection.Add() and
+ NoteCollection.Remove() overloads which do not require a signature (#1173)
+ - BuildSignature() no longer tries to build a signature from the
+ environment if there is none configured (#1171)
+ - Rename the commit walker's Since to IncludeReachableFrom and Until to ExcludeReachableFrom (#1069)
+ - Rename MergeConflictException to CheckoutConflictException to more
+ accurately reflect what it means (#1059)
+ - Specify the diff algorithm instead of setting a boolean to use patience (#1043)
+ - Remove optional parameters (#1031)
+ - Move Repository.Reset(paths) into Index (#959)
+ - Move FindMergeBase() overloads to ObjectDatabase (#957)
+
+### Fixes
+
+ - ListReferences() is now able to handle symbolic references (#1132)
+ - Repository.IsValid() returns false on empty paths (#1156)
+ - The included version of libgit2 includes racy-git support
+ - Fix a racy NRE in the filters (#1113)
## v0.21.1 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.21...v0.21.1))
diff --git a/CI/build.msbuild b/CI/build.msbuild
index f7bb2ee6a..97c503354 100644
--- a/CI/build.msbuild
+++ b/CI/build.msbuild
@@ -6,7 +6,7 @@
$(RootDir)\Build
-
@@ -37,7 +37,7 @@
-
+
diff --git a/CI/travis.linux.install.deps.sh b/CI/travis.linux.install.deps.sh
index 1a820d07b..365fc51a6 100755
--- a/CI/travis.linux.install.deps.sh
+++ b/CI/travis.linux.install.deps.sh
@@ -1,9 +1,10 @@
#!/bin/bash
set -ev
-sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/tpokorra:/mono/xUbuntu_12.04/ /' >> /etc/apt/sources.list.d/mono-opt.list"
+sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
-curl http://download.opensuse.org/repositories/home:/tpokorra:/mono/xUbuntu_12.04/Release.key | sudo apt-key add -
+echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.0 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
+echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
-sudo apt-get install mono-opt cmake
+sudo apt-get install mono-devel cmake
diff --git a/Lib/CustomBuildTasks/CustomBuildTasks.csproj b/Lib/CustomBuildTasks/CustomBuildTasks.csproj
index 2da370371..351e4873f 100644
--- a/Lib/CustomBuildTasks/CustomBuildTasks.csproj
+++ b/Lib/CustomBuildTasks/CustomBuildTasks.csproj
@@ -9,7 +9,7 @@
PropertiesCustomBuildTasksCustomBuildTasks
- v3.5
+ v4.0512
@@ -33,10 +33,11 @@
-
+
+
diff --git a/Lib/CustomBuildTasks/CustomBuildTasks.dll b/Lib/CustomBuildTasks/CustomBuildTasks.dll
index 3cd023b83..cd763a2e1 100644
Binary files a/Lib/CustomBuildTasks/CustomBuildTasks.dll and b/Lib/CustomBuildTasks/CustomBuildTasks.dll differ
diff --git a/Lib/CustomBuildTasks/GenerateNativeDllNameTask.cs b/Lib/CustomBuildTasks/GenerateNativeDllNameTask.cs
new file mode 100644
index 000000000..9b31fba34
--- /dev/null
+++ b/Lib/CustomBuildTasks/GenerateNativeDllNameTask.cs
@@ -0,0 +1,41 @@
+using System;
+using System.IO;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace CustomBuildTasks
+{
+ public class GenerateNativeDllNameTask : Task
+ {
+ public ITaskItem InputHashFile { get; set; }
+
+ public string OutputFile { get; set; }
+
+ public override bool Execute()
+ {
+ var fileName = InputHashFile.GetMetadata("FullPath");
+ string libgit2FileName;
+
+ using (var sr = new StreamReader(fileName))
+ {
+ libgit2FileName = sr.ReadLine();
+ }
+
+ var nativeDllName = @"namespace LibGit2Sharp.Core
+{{
+ internal static class NativeDllName
+ {{
+ public const string Name = ""{0}"";
+ }}
+}}
+";
+
+ using (var sw = new StreamWriter(OutputFile))
+ {
+ sw.Write(nativeDllName, libgit2FileName);
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/Lib/NativeBinaries/amd64/git2-e0902fb.dll b/Lib/NativeBinaries/amd64/git2-e0902fb.dll
deleted file mode 100644
index f4931dbdd..000000000
Binary files a/Lib/NativeBinaries/amd64/git2-e0902fb.dll and /dev/null differ
diff --git a/Lib/NativeBinaries/amd64/git2-e0902fb.pdb b/Lib/NativeBinaries/amd64/git2-e0902fb.pdb
deleted file mode 100644
index bdef63b09..000000000
Binary files a/Lib/NativeBinaries/amd64/git2-e0902fb.pdb and /dev/null differ
diff --git a/Lib/NativeBinaries/libgit2.license.txt b/Lib/NativeBinaries/libgit2.license.txt
deleted file mode 100644
index d1ca4d401..000000000
--- a/Lib/NativeBinaries/libgit2.license.txt
+++ /dev/null
@@ -1,930 +0,0 @@
- libgit2 is Copyright (C) the libgit2 contributors,
- unless otherwise stated. See the AUTHORS file for details.
-
- Note that the only valid version of the GPL as far as this project
- is concerned is _this_ particular version of the license (ie v2, not
- v2.2 or v3.x or whatever), unless explicitly otherwise stated.
-
-----------------------------------------------------------------------
-
- LINKING EXCEPTION
-
- In addition to the permissions in the GNU General Public License,
- the authors give you unlimited permission to link the compiled
- version of this library into combinations with other programs,
- and to distribute those combinations without any restriction
- coming from the use of this file. (The General Public License
- restrictions do apply in other respects; for example, they cover
- modification of the file, and distribution when not linked into
- a combined executable.)
-
-----------------------------------------------------------------------
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
-----------------------------------------------------------------------
-
-The bundled ZLib code is licensed under the ZLib license:
-
-Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-----------------------------------------------------------------------
-
-The priority queue implementation is based on code licensed under the
-Apache 2.0 license:
-
- Copyright 2010 Volkan Yazıcı
- Copyright 2006-2010 The Apache Software Foundation
-
-The full text of the Apache 2.0 license is available at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-----------------------------------------------------------------------
-
-The Clay framework is licensed under the MIT license:
-
-Copyright (C) 2011 by Vicent Marti
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-----------------------------------------------------------------------
-
-The regex library (deps/regex/) is licensed under the GNU LGPL
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/Lib/NativeBinaries/x86/git2-e0902fb.dll b/Lib/NativeBinaries/x86/git2-e0902fb.dll
deleted file mode 100644
index b0c55e6cf..000000000
Binary files a/Lib/NativeBinaries/x86/git2-e0902fb.dll and /dev/null differ
diff --git a/Lib/NativeBinaries/x86/git2-e0902fb.pdb b/Lib/NativeBinaries/x86/git2-e0902fb.pdb
deleted file mode 100644
index d466f239a..000000000
Binary files a/Lib/NativeBinaries/x86/git2-e0902fb.pdb and /dev/null differ
diff --git a/Lib/NuGet/NuGet.exe b/Lib/NuGet/NuGet.exe
index ed2b0a221..9ca66594f 100644
Binary files a/Lib/NuGet/NuGet.exe and b/Lib/NuGet/NuGet.exe differ
diff --git a/LibGit2Sharp.Tests/ArchiveFixture.cs b/LibGit2Sharp.Tests/ArchiveFixture.cs
index 7253e2fe8..19860ca0b 100644
--- a/LibGit2Sharp.Tests/ArchiveFixture.cs
+++ b/LibGit2Sharp.Tests/ArchiveFixture.cs
@@ -18,6 +18,8 @@ public void CanArchiveATree()
var archiver = new MockArchiver();
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
repo.ObjectDatabase.Archive(tree, archiver);
var expected = new ArrayList
@@ -30,7 +32,7 @@ public void CanArchiveATree()
};
Assert.Equal(expected, archiver.Files);
Assert.Null(archiver.ReceivedCommitSha);
- Assert.InRange(archiver.ModificationTime, DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(100)), DateTimeOffset.UtcNow);
+ Assert.InRange(archiver.ModificationTime, before, DateTimeOffset.UtcNow);
}
}
@@ -66,8 +68,10 @@ public void ArchivingANullTreeOrCommitThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Throws(() => repo.ObjectDatabase.Archive((Commit)null, null));
- Assert.Throws(() => repo.ObjectDatabase.Archive((Tree)null, null));
+ Assert.Throws(() => repo.ObjectDatabase.Archive(default(Commit), default(ArchiverBase)));
+ Assert.Throws(() => repo.ObjectDatabase.Archive(default(Commit), default(string)));
+ Assert.Throws(() => repo.ObjectDatabase.Archive(default(Tree), default(ArchiverBase)));
+ Assert.Throws(() => repo.ObjectDatabase.Archive(default(Tree), default(string)));
}
}
diff --git a/LibGit2Sharp.Tests/ArchiveTarFixture.cs b/LibGit2Sharp.Tests/ArchiveTarFixture.cs
index c1ae15783..a21847ea0 100644
--- a/LibGit2Sharp.Tests/ArchiveTarFixture.cs
+++ b/LibGit2Sharp.Tests/ArchiveTarFixture.cs
@@ -1,4 +1,3 @@
-using System;
using System.IO;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
diff --git a/LibGit2Sharp.Tests/AttributesFixture.cs b/LibGit2Sharp.Tests/AttributesFixture.cs
index c9c4eb712..c607ce651 100644
--- a/LibGit2Sharp.Tests/AttributesFixture.cs
+++ b/LibGit2Sharp.Tests/AttributesFixture.cs
@@ -9,8 +9,7 @@ public class AttributesFixture : BaseFixture
[Fact]
public void StagingHonorsTheAttributesFiles()
{
- string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = InitIsolatedRepository())
{
CreateAttributesFile(repo);
diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs
index 223a4d673..4c984bd34 100644
--- a/LibGit2Sharp.Tests/BlobFixture.cs
+++ b/LibGit2Sharp.Tests/BlobFixture.cs
@@ -222,7 +222,7 @@ public void CanTellIfTheBlobContentLooksLikeBinary()
private static void SkipIfNotSupported(string autocrlf)
{
- InconclusiveIf(() => autocrlf == "true" && IsRunningOnLinux(), "Non-Windows does not support core.autocrlf = true");
+ InconclusiveIf(() => autocrlf == "true" && Constants.IsRunningOnUnix, "Non-Windows does not support core.autocrlf = true");
}
}
}
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index ded3fbc76..715defd87 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -18,15 +18,17 @@ public class BranchFixture : BaseFixture
public void CanCreateBranch(string name)
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
const string committish = "be3563ae3f795b2b4353bcce3a527ad0a4f7f644";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
- Assert.Equal(name, newBranch.Name);
+ Assert.Equal(name, newBranch.FriendlyName);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.NotNull(newBranch.Tip);
Assert.Equal(committish, newBranch.Tip.Sha);
@@ -36,13 +38,15 @@ public void CanCreateBranch(string name)
// when they're read back:
// - from InlineData: C5-00-6E-00-67-00-73-00-74-00-72-00-F6-00-6D-00
// - from filesystem: 41-00-0A-03-6E-00-67-00-73-00-74-00-72-00-6F-00-08-03-6D-00
- Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name.Normalize() == name));
+ Assert.NotNull(repo.Branches.SingleOrDefault(p => p.FriendlyName.Normalize() == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, before);
- repo.Branches.Remove(newBranch.Name);
+ repo.Branches.Remove(newBranch.FriendlyName);
Assert.Null(repo.Branches[name]);
}
}
@@ -86,20 +90,24 @@ public void CanCreateAnUnbornBranch()
public void CanCreateBranchUsingAbbreviatedSha()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
const string name = "unit_test";
const string committish = "be3563a";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, committish);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, before);
}
}
@@ -109,25 +117,30 @@ public void CanCreateBranchUsingAbbreviatedSha()
public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
repo.Checkout(headCommitOrBranchSpec);
const string name = "unit_test";
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name);
Assert.NotNull(newBranch);
- Assert.Equal(name, newBranch.Name);
+ Assert.Equal(name, newBranch.FriendlyName);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.False(newBranch.IsCurrentRepositoryHead);
Assert.NotNull(newBranch.Tip);
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
- Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
+ Assert.NotNull(repo.Branches.SingleOrDefault(p => p.FriendlyName == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + headCommitOrBranchSpec,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + headCommitOrBranchSpec);
+ Constants.Identity, before);
}
}
@@ -137,20 +150,25 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
repo.Checkout(headCommitOrBranchSpec);
const string name = "unit_test";
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, "HEAD");
Assert.NotNull(newBranch);
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from HEAD",
+ null,
newBranch.Tip.Id,
- "branch: Created from " + headCommitOrBranchSpec);
+ Constants.Identity, before);
}
}
@@ -158,19 +176,24 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
public void CanCreateBranchFromCommit()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
const string name = "unit_test";
var commit = repo.Lookup("HEAD");
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, commit);
Assert.NotNull(newBranch);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + newBranch.Tip.Sha,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + newBranch.Tip.Sha);
+ Constants.Identity, before);
}
}
@@ -178,20 +201,24 @@ public void CanCreateBranchFromCommit()
public void CanCreateBranchFromRevparseSpec()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
const string name = "revparse_branch";
const string committish = "master~2";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal("9fd738e8f7967c078dceed8190330fc8648ee56a", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, before);
}
}
@@ -201,19 +228,23 @@ public void CanCreateBranchFromRevparseSpec()
public void CreatingABranchFromATagPeelsToTheCommit(string committish)
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
const string name = "i-peel-tag";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, before);
}
}
@@ -289,7 +320,7 @@ public void CanListAllBranches()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.Name));
+ Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.FriendlyName));
Assert.Equal(5, repo.Branches.Count());
}
@@ -310,7 +341,7 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName()
};
Assert.Equal(expectedWdBranches,
- SortedBranches(repo.Branches.Where(b => !b.IsRemote), b => b.Name));
+ SortedBranches(repo.Branches.Where(b => !b.IsRemote), b => b.FriendlyName));
}
}
@@ -327,7 +358,7 @@ public void CanListAllBranchesWhenGivenWorkingDir()
"origin/test"
};
- Assert.Equal(expectedWdBranches, SortedBranches(repo.Branches, b => b.Name));
+ Assert.Equal(expectedWdBranches, SortedBranches(repo.Branches, b => b.FriendlyName));
}
}
@@ -352,7 +383,7 @@ public void CanListAllBranchesIncludingRemoteRefs()
new { Name = "origin/test", Sha = "e90810b8df3e80c413d903f631643c716887138d", IsRemote = true },
};
Assert.Equal(expectedBranchesIncludingRemoteRefs,
- SortedBranches(repo.Branches, b => new { b.Name, b.Tip.Sha, b.IsRemote }));
+ SortedBranches(repo.Branches, b => new { Name = b.FriendlyName, b.Tip.Sha, b.IsRemote }));
}
}
@@ -443,8 +474,8 @@ public void QueryAmbigousRemoteForRemoteBranch()
{
var path = SandboxStandardTestRepo();
- var fetchRefSpec = "+refs/heads/*:refs/remotes/origin/*";
- var url = "http://github.com/libgit2/TestGitRepository";
+ const string fetchRefSpec = "+refs/heads/*:refs/remotes/origin/*";
+ const string url = "http://github.com/libgit2/TestGitRepository";
using (var repo = InitIsolatedRepository(path))
{
@@ -469,11 +500,11 @@ public void CanLookupABranchByItsCanonicalName()
{
Branch branch = repo.Branches["refs/heads/br2"];
Assert.NotNull(branch);
- Assert.Equal("br2", branch.Name);
+ Assert.Equal("br2", branch.FriendlyName);
Branch branch2 = repo.Branches["refs/heads/br2"];
Assert.NotNull(branch2);
- Assert.Equal("br2", branch2.Name);
+ Assert.Equal("br2", branch2.FriendlyName);
Assert.Equal(branch, branch2);
Assert.True((branch2 == branch));
@@ -489,7 +520,7 @@ public void CanLookupLocalBranch()
Branch master = repo.Branches["master"];
Assert.NotNull(master);
Assert.False(master.IsRemote);
- Assert.Equal("master", master.Name);
+ Assert.Equal("master", master.FriendlyName);
Assert.Equal("refs/heads/master", master.CanonicalName);
Assert.True(master.IsCurrentRepositoryHead);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", master.Tip.Sha);
@@ -537,7 +568,7 @@ public void CanGetInformationFromUnbornBranch()
Assert.Equal(0, head.Commits.Count());
Assert.True(head.IsCurrentRepositoryHead);
Assert.False(head.IsRemote);
- Assert.Equal("master", head.Name);
+ Assert.Equal("master", head.FriendlyName);
Assert.Null(head.Tip);
Assert.Null(head["huh?"]);
@@ -559,7 +590,7 @@ public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBra
{
Branch master = repo.Branches["master"];
const string logMessage = "update target message";
- repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", Constants.Signature, logMessage);
+ repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", logMessage);
Assert.True(master.IsTracking);
Assert.NotNull(master.TrackedBranch);
@@ -888,6 +919,24 @@ public void CanRemoveAnExistingBranch(string branchName)
}
}
+ [Fact]
+ public void CanCreateBranchInDeletedNestedBranchNamespace()
+ {
+ const string namespaceName = "level_one";
+ string branchWithNamespaceName = string.Join("/", namespaceName, "level_two");
+
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ Commit commit = repo.Head.Tip;
+
+ Branch branchWithNamespace = repo.Branches.Add(branchWithNamespaceName, commit);
+ repo.Branches.Remove(branchWithNamespace);
+
+ repo.Branches.Add(namespaceName, commit);
+ }
+ }
+
[Theory]
[InlineData("I-donot-exist", false)]
[InlineData("me/neither", true)]
@@ -902,7 +951,7 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Throws(() => repo.Branches.Remove(repo.Head.Name));
+ Assert.Throws(() => repo.Branches.Remove(repo.Head.FriendlyName));
}
}
@@ -913,7 +962,8 @@ public void RemovingABranchWithBadParamsThrows()
using (var repo = new Repository(path))
{
Assert.Throws(() => repo.Branches.Remove(string.Empty));
- Assert.Throws(() => repo.Branches.Remove(null));
+ Assert.Throws(() => repo.Branches.Remove(default(string)));
+ Assert.Throws(() => repo.Branches.Remove(default(Branch)));
}
}
@@ -964,7 +1014,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
public void CanRenameABranch()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -972,16 +1022,20 @@ public void CanRenameABranch()
var br2 = repo.Branches["br2"];
Assert.NotNull(br2);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.Branches.Rename("br2", "br3");
- Assert.Equal("br3", newBranch.Name);
+ Assert.Equal("br3", newBranch.FriendlyName);
Assert.Null(repo.Branches["br2"]);
Assert.NotNull(repo.Branches["br3"]);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
+ br2.Tip.Id,
newBranch.Tip.Id,
- string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName));
+ Constants.Identity, before);
}
}
@@ -999,7 +1053,7 @@ public void BlindlyRenamingABranchOverAnExistingOneThrows()
public void CanRenameABranchWhileOverwritingAnExistingOne()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -1009,8 +1063,10 @@ public void CanRenameABranchWhileOverwritingAnExistingOne()
Branch br2 = repo.Branches["br2"];
Assert.NotNull(br2);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Branch newBranch = repo.Branches.Rename("br2", "test", true);
- Assert.Equal("test", newBranch.Name);
+ Assert.Equal("test", newBranch.FriendlyName);
Assert.Null(repo.Branches["br2"]);
@@ -1021,9 +1077,10 @@ public void CanRenameABranchWhileOverwritingAnExistingOne()
Assert.Equal(br2.Tip, newTest.Tip);
AssertRefLogEntry(repo, newBranch.CanonicalName,
- newBranch.Tip.Id,
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
- test.Tip.Id);
+ br2.Tip.Id,
+ newTest.Tip.Id,
+ Constants.Identity, before);
}
}
@@ -1068,7 +1125,7 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
using (var repo = new Repository(clonedRepoPath))
{
Assert.Empty(Directory.GetFiles(scd2.RootedDirectoryPath));
- Assert.Equal(repo.Head.Name, "master");
+ Assert.Equal(repo.Head.FriendlyName, "master");
Assert.Null(repo.Head.Tip);
Assert.NotNull(repo.Head.TrackedBranch);
@@ -1129,15 +1186,27 @@ private static T[] SortedBranches(IEnumerable branches, Func(() => repo.Checkout(master.CanonicalName));
+ Assert.Throws(() => repo.Checkout(master.CanonicalName));
// Checkout with force option should succeed.
repo.Checkout(master.CanonicalName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force});
@@ -304,11 +304,11 @@ public void CheckingOutWithMergeConflictsThrows()
// Assert that checking out master throws
// when there are unstaged commits
- Assert.Throws(() => repo.Checkout("master"));
+ Assert.Throws(() => repo.Checkout("master"));
// And when there are staged commits
repo.Stage(originalFilePath);
- Assert.Throws(() => repo.Checkout("master"));
+ Assert.Throws(() => repo.Checkout("master"));
}
}
@@ -319,7 +319,7 @@ public void CanCancelCheckoutThroughNotifyCallback()
using (var repo = new Repository(repoPath))
{
- string relativePath = "a.txt";
+ const string relativePath = "a.txt";
Touch(repo.Info.WorkingDirectory, relativePath, "Hello\n");
repo.Stage(relativePath);
@@ -451,13 +451,13 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri
{
PopulateBasicRepository(repo);
- string relativePathUpdated = "updated.txt";
+ const string relativePathUpdated = "updated.txt";
Touch(repo.Info.WorkingDirectory, relativePathUpdated, "updated file text A");
repo.Stage(relativePathUpdated);
repo.Commit("Commit initial update file", Constants.Signature, Constants.Signature);
// Create conflicting change
- string relativePathConflict = "conflict.txt";
+ const string relativePathConflict = "conflict.txt";
Touch(repo.Info.WorkingDirectory, relativePathConflict, "conflict file text A");
repo.Stage(relativePathConflict);
repo.Commit("Initial commit of conflict.txt and update.txt", Constants.Signature, Constants.Signature);
@@ -492,7 +492,7 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri
Touch(repo.Info.WorkingDirectory, relativePathIgnore, "ignored file");
// Create untracked change
- string relativePathUntracked = "untracked.txt";
+ const string relativePathUntracked = "untracked.txt";
Touch(repo.Info.WorkingDirectory, relativePathUntracked, "untracked file");
bool wasCalled = false;
@@ -505,7 +505,7 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri
CheckoutNotifyFlags = notifyFlags,
};
- Assert.Throws(() => repo.Checkout("master", options));
+ Assert.Throws(() => repo.Checkout("master", options));
Assert.True(wasCalled);
Assert.Equal(expectedNotificationPath, actualNotificationPath);
@@ -527,13 +527,13 @@ public void CheckoutRetainsUntrackedChanges()
// Verify that there is an untracked entry.
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(fullPathFileB));
repo.Checkout(otherBranchName);
// Verify untracked entry still exists.
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(fullPathFileB));
}
}
@@ -551,13 +551,13 @@ public void ForceCheckoutRetainsUntrackedChanges()
// Verify that there is an untracked entry.
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(fullPathFileB));
repo.Checkout(otherBranchName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
// Verify untracked entry still exists.
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(fullPathFileB));
}
}
@@ -575,13 +575,13 @@ public void CheckoutRetainsUnstagedChanges()
// Verify that there is a modified entry.
Assert.Equal(1, repo.RetrieveStatus().Modified.Count());
- Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(fullPathFileA));
+ Assert.Equal(FileStatus.ModifiedInWorkdir, repo.RetrieveStatus(fullPathFileA));
repo.Checkout(otherBranchName);
// Verify modified entry still exists.
Assert.Equal(1, repo.RetrieveStatus().Modified.Count());
- Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(fullPathFileA));
+ Assert.Equal(FileStatus.ModifiedInWorkdir, repo.RetrieveStatus(fullPathFileA));
}
}
@@ -600,13 +600,13 @@ public void CheckoutRetainsStagedChanges()
// Verify that there is a staged entry.
Assert.Equal(1, repo.RetrieveStatus().Staged.Count());
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus(fullPathFileA));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus(fullPathFileA));
repo.Checkout(otherBranchName);
// Verify staged entry still exists.
Assert.Equal(1, repo.RetrieveStatus().Staged.Count());
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus(fullPathFileA));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus(fullPathFileA));
}
}
@@ -769,8 +769,8 @@ public void CheckoutFromDetachedHead(string commitPointer)
var reflogEntry = repo.Refs.Log(repo.Refs.Head).First();
Assert.Equal(initialHead.Tip.Id, reflogEntry.From);
Assert.Equal(commitSha, reflogEntry.To.Sha);
- Assert.NotNull(reflogEntry.Commiter.Email);
- Assert.NotNull(reflogEntry.Commiter.Name);
+ Assert.NotNull(reflogEntry.Committer.Email);
+ Assert.NotNull(reflogEntry.Committer.Name);
Assert.Equal(string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, commitPointer), reflogEntry.Message);
}
}
@@ -779,7 +779,7 @@ public void CheckoutFromDetachedHead(string commitPointer)
public void CheckoutBranchFromDetachedHead()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
// Set the working directory to the current head
ResetAndCleanWorkingDirectory(repo);
@@ -789,12 +789,14 @@ public void CheckoutBranchFromDetachedHead()
Assert.True(repo.Info.IsHeadDetached);
- Branch newHead = repo.Checkout(repo.Branches["master"], Constants.Signature);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ Branch newHead = repo.Checkout(repo.Branches["master"]);
// Assert reflog entry is created
- AssertRefLogEntry(repo, "HEAD", newHead.Tip.Id,
- string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.Name),
- initialHead.Tip.Id, Constants.Signature);
+ AssertRefLogEntry(repo, "HEAD",
+ string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.FriendlyName),
+ initialHead.Tip.Id, newHead.Tip.Id, Constants.Identity, before);
}
}
@@ -847,7 +849,7 @@ public void CheckoutPreviousCheckedOutBranch()
public void CheckoutCurrentReference()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
@@ -862,12 +864,15 @@ public void CheckoutCurrentReference()
Assert.Equal(reflogEntriesCount, repo.Refs.Log(repo.Refs.Head).Count());
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
// Checkout in detached mode
repo.Checkout(master.Tip.Sha);
Assert.True(repo.Info.IsHeadDetached);
- AssertRefLogEntry(repo, "HEAD", master.Tip.Id,
- string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id);
+ AssertRefLogEntry(repo, "HEAD",
+ string.Format("checkout: moving from master to {0}", master.Tip.Sha),
+ master.Tip.Id, master.Tip.Id, Constants.Identity, before);
// Checkout detached "HEAD" => nothing should happen
reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count();
@@ -935,10 +940,10 @@ public void CanCheckoutDetachedHead()
}
[Theory]
- [InlineData("master", "6dcf9bf", "readme.txt", FileStatus.Added)]
- [InlineData("master", "refs/tags/lw", "readme.txt", FileStatus.Added)]
- [InlineData("master", "i-do-numbers", "super-file.txt", FileStatus.Added)]
- [InlineData("i-do-numbers", "diff-test-cases", "numbers.txt", FileStatus.Staged)]
+ [InlineData("master", "6dcf9bf", "readme.txt", FileStatus.NewInIndex)]
+ [InlineData("master", "refs/tags/lw", "readme.txt", FileStatus.NewInIndex)]
+ [InlineData("master", "i-do-numbers", "super-file.txt", FileStatus.NewInIndex)]
+ [InlineData("i-do-numbers", "diff-test-cases", "numbers.txt", FileStatus.ModifiedInIndex)]
public void CanCheckoutPath(string originalBranch, string checkoutFrom, string path, FileStatus expectedStatus)
{
string repoPath = SandboxStandardTestRepo();
@@ -973,7 +978,7 @@ public void CanCheckoutPaths()
foreach (string checkoutPath in checkoutPaths)
{
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(checkoutPath));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(checkoutPath));
}
}
}
@@ -1024,6 +1029,23 @@ public void CanCheckoutPathFromCurrentBranch(string fileName)
}
}
+ [Fact]
+ public void CanCatchDeprecatedException()
+ {
+ bool caught = false;
+
+ try
+ {
+ throw new CheckoutConflictException();
+ }
+ catch (MergeConflictException)
+ {
+ caught = true;
+ }
+
+ Assert.True(caught);
+ }
+
///
/// Helper method to populate a simple repository with
/// a single file and two branches.
diff --git a/LibGit2Sharp.Tests/CherryPickFixture.cs b/LibGit2Sharp.Tests/CherryPickFixture.cs
index c4b61455f..d9828e266 100644
--- a/LibGit2Sharp.Tests/CherryPickFixture.cs
+++ b/LibGit2Sharp.Tests/CherryPickFixture.cs
@@ -1,9 +1,9 @@
-using System.IO;
+using System;
+using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
-using System;
namespace LibGit2Sharp.Tests
{
diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs
index d291ddcdc..ae98788eb 100644
--- a/LibGit2Sharp.Tests/CloneFixture.cs
+++ b/LibGit2Sharp.Tests/CloneFixture.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
+using LibGit2Sharp.Handlers;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
@@ -31,7 +33,7 @@ public void CanClone(string url)
Assert.False(repo.Info.IsBare);
Assert.True(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
- Assert.Equal(repo.Head.Name, "master");
+ Assert.Equal(repo.Head.FriendlyName, "master");
Assert.Equal(repo.Head.Tip.Id.ToString(), "49322bb17d3acc9146f98c97d078513228bbf3c0");
}
}
@@ -50,7 +52,7 @@ public void CanCloneWithCheckoutBranchName(string branchName, string headTipId)
{
var head = repo.Head;
- Assert.Equal(branchName, head.Name);
+ Assert.Equal(branchName, head.FriendlyName);
Assert.True(head.IsTracking);
Assert.Equal(headTipId, head.Tip.Sha);
}
@@ -193,19 +195,34 @@ public void CanCloneWithCredentials()
}
}
+ static Credentials CreateUsernamePasswordCredentials (string user, string pass, bool secure)
+ {
+ if (secure)
+ {
+ return new SecureUsernamePasswordCredentials
+ {
+ Username = user,
+ Password = Constants.StringToSecureString(pass),
+ };
+ }
+
+ return new UsernamePasswordCredentials
+ {
+ Username = user,
+ Password = pass,
+ };
+ }
+
[Theory]
- [InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
- public void CanCloneFromBBWithCredentials(string url, string user, string pass)
+ [InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
+ [InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", false)]
+ public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
{
var scd = BuildSelfCleaningDirectory();
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
{
- CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
- {
- Username = user,
- Password = pass,
- }
+ CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials (user, pass, secure)
});
using (var repo = new Repository(clonedRepoPath))
@@ -220,6 +237,66 @@ public void CanCloneFromBBWithCredentials(string url, string user, string pass)
}
}
+ [SkippableTheory]
+ [InlineData("https://github.com/libgit2/TestGitRepository.git", "github.com", typeof(CertificateX509))]
+ [InlineData("git@github.com:libgit2/TestGitRepository.git", "github.com", typeof(CertificateSsh))]
+ public void CanInspectCertificateOnClone(string url, string hostname, Type certType)
+ {
+ var scd = BuildSelfCleaningDirectory();
+
+ InconclusiveIf(
+ () =>
+ certType == typeof (CertificateSsh) && !GlobalSettings.Version.Features.HasFlag(BuiltInFeatures.Ssh),
+ "SSH not supported");
+
+ bool wasCalled = false;
+ bool checksHappy = false;
+
+ var options = new CloneOptions {
+ CertificateCheck = (cert, valid, host) => {
+ wasCalled = true;
+
+ Assert.Equal(hostname, host);
+ Assert.Equal(certType, cert.GetType());
+
+ if (certType == typeof(CertificateX509)) {
+ Assert.True(valid);
+ var x509 = ((CertificateX509)cert).Certificate;
+ // we get a string with the different fields instead of a structure, so...
+ Assert.True(x509.Subject.Contains("CN=github.com,"));
+ checksHappy = true;
+ return false;
+ }
+
+ if (certType == typeof(CertificateSsh)) {
+ var hostkey = (CertificateSsh)cert;
+ Assert.True(hostkey.HasMD5);
+ /*
+ * Once you've connected and thus your ssh has stored the hostkey,
+ * you can get the hostkey for a host with
+ *
+ * ssh-keygen -F github.com -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':'
+ *
+ * though GitHub's hostkey won't change anytime soon.
+ */
+ Assert.Equal("1627aca576282d36631b564debdfa648",
+ BitConverter.ToString(hostkey.HashMD5).ToLower().Replace("-", ""));
+ checksHappy = true;
+ return false;
+ }
+
+ return false;
+ },
+ };
+
+ Assert.Throws(() =>
+ Repository.Clone(url, scd.DirectoryPath, options)
+ );
+
+ Assert.True(wasCalled);
+ Assert.True(checksHappy);
+ }
+
[Fact]
public void CloningAnUrlWithoutPathThrows()
{
@@ -242,5 +319,243 @@ public void CloningWithoutUrlThrows()
Assert.Throws(() => Repository.Clone(null, scd.DirectoryPath));
}
+
+ ///
+ /// Private helper to record the callbacks that were called as part of a clone.
+ ///
+ private class CloneCallbackInfo
+ {
+ ///
+ /// Was checkout progress called.
+ ///
+ public bool CheckoutProgressCalled { get; set; }
+
+ ///
+ /// The reported remote URL.
+ ///
+ public string RemoteUrl { get; set; }
+
+ ///
+ /// Was remote ref update called.
+ ///
+ public bool RemoteRefUpdateCalled { get; set; }
+
+ ///
+ /// Was the transition callback called when starting
+ /// work on this repository.
+ ///
+ public bool StartingWorkInRepositoryCalled { get; set; }
+
+ ///
+ /// Was the transition callback called when finishing
+ /// work on this repository.
+ ///
+ public bool FinishedWorkInRepositoryCalled { get; set; }
+
+ ///
+ /// The reported recursion depth.
+ ///
+ public int RecursionDepth { get; set; }
+ }
+
+ [Fact]
+ public void CanRecursivelyCloneSubmodules()
+ {
+ var uri = new Uri(Path.GetFullPath(SandboxSubmoduleSmallTestRepo()));
+ var scd = BuildSelfCleaningDirectory();
+ string relativeSubmodulePath = "submodule_target_wd";
+
+ // Construct the expected URL the submodule will clone from.
+ string expectedSubmoduleUrl = Path.Combine(Path.GetDirectoryName(uri.AbsolutePath), relativeSubmodulePath);
+ expectedSubmoduleUrl = expectedSubmoduleUrl.Replace('\\', '/');
+
+ Dictionary callbacks = new Dictionary();
+
+ CloneCallbackInfo currentEntry = null;
+ bool unexpectedOrderOfCallbacks = false;
+
+ CheckoutProgressHandler checkoutProgressHandler = (x, y, z) =>
+ {
+ if (currentEntry != null)
+ {
+ currentEntry.CheckoutProgressCalled = true;
+ }
+ else
+ {
+ // Should not be called if there is not a current
+ // callbackInfo entry.
+ unexpectedOrderOfCallbacks = true;
+ }
+ };
+
+ UpdateTipsHandler remoteRefUpdated = (x, y, z) =>
+ {
+ if (currentEntry != null)
+ {
+ currentEntry.RemoteRefUpdateCalled = true;
+ }
+ else
+ {
+ // Should not be called if there is not a current
+ // callbackInfo entry.
+ unexpectedOrderOfCallbacks = true;
+ }
+
+ return true;
+ };
+
+ RepositoryOperationStarting repositoryOperationStarting = (x) =>
+ {
+ if (currentEntry != null)
+ {
+ // Should not be called if there is a current
+ // callbackInfo entry.
+ unexpectedOrderOfCallbacks = true;
+ }
+
+ currentEntry = new CloneCallbackInfo();
+ currentEntry.StartingWorkInRepositoryCalled = true;
+ currentEntry.RecursionDepth = x.RecursionDepth;
+ currentEntry.RemoteUrl = x.RemoteUrl;
+ callbacks.Add(x.RepositoryPath, currentEntry);
+
+ return true;
+ };
+
+ RepositoryOperationCompleted repositoryOperationCompleted = (x) =>
+ {
+ if (currentEntry != null)
+ {
+ currentEntry.FinishedWorkInRepositoryCalled = true;
+ currentEntry = null;
+ }
+ else
+ {
+ // Should not be called if there is not a current
+ // callbackInfo entry.
+ unexpectedOrderOfCallbacks = true;
+ }
+ };
+
+ CloneOptions options = new CloneOptions()
+ {
+ RecurseSubmodules = true,
+ OnCheckoutProgress = checkoutProgressHandler,
+ OnUpdateTips = remoteRefUpdated,
+ RepositoryOperationStarting = repositoryOperationStarting,
+ RepositoryOperationCompleted = repositoryOperationCompleted,
+ };
+
+ string clonedRepoPath = Repository.Clone(uri.AbsolutePath, scd.DirectoryPath, options);
+ string workDirPath;
+
+ using(Repository repo = new Repository(clonedRepoPath))
+ {
+ workDirPath = repo.Info.WorkingDirectory.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
+ }
+
+ // Verification:
+ // Verify that no callbacks were called in an unexpected order.
+ Assert.False(unexpectedOrderOfCallbacks);
+
+ Dictionary expectedCallbackInfo = new Dictionary();
+ expectedCallbackInfo.Add(workDirPath, new CloneCallbackInfo()
+ {
+ RecursionDepth = 0,
+ RemoteUrl = uri.AbsolutePath,
+ StartingWorkInRepositoryCalled = true,
+ FinishedWorkInRepositoryCalled = true,
+ CheckoutProgressCalled = true,
+ RemoteRefUpdateCalled = true,
+ });
+
+ expectedCallbackInfo.Add(Path.Combine(workDirPath, relativeSubmodulePath), new CloneCallbackInfo()
+ {
+ RecursionDepth = 1,
+ RemoteUrl = expectedSubmoduleUrl,
+ StartingWorkInRepositoryCalled = true,
+ FinishedWorkInRepositoryCalled = true,
+ CheckoutProgressCalled = true,
+ RemoteRefUpdateCalled = true,
+ });
+
+ // Callbacks for each expected repository that is cloned
+ foreach (KeyValuePair kvp in expectedCallbackInfo)
+ {
+ CloneCallbackInfo entry = null;
+ Assert.True(callbacks.TryGetValue(kvp.Key, out entry), string.Format("{0} was not found in callbacks.", kvp.Key));
+
+ Assert.Equal(kvp.Value.RemoteUrl, entry.RemoteUrl);
+ Assert.Equal(kvp.Value.RecursionDepth, entry.RecursionDepth);
+ Assert.Equal(kvp.Value.StartingWorkInRepositoryCalled, entry.StartingWorkInRepositoryCalled);
+ Assert.Equal(kvp.Value.FinishedWorkInRepositoryCalled, entry.FinishedWorkInRepositoryCalled);
+ Assert.Equal(kvp.Value.CheckoutProgressCalled, entry.CheckoutProgressCalled);
+ Assert.Equal(kvp.Value.RemoteRefUpdateCalled, entry.RemoteRefUpdateCalled);
+ }
+
+ // Verify the state of the submodule
+ using(Repository repo = new Repository(clonedRepoPath))
+ {
+ var sm = repo.Submodules[relativeSubmodulePath];
+ Assert.True(sm.RetrieveStatus().HasFlag(SubmoduleStatus.InWorkDir |
+ SubmoduleStatus.InConfig |
+ SubmoduleStatus.InIndex |
+ SubmoduleStatus.InHead));
+
+ Assert.NotNull(sm.HeadCommitId);
+ Assert.Equal("480095882d281ed676fe5b863569520e54a7d5c0", sm.HeadCommitId.Sha);
+
+ Assert.False(repo.RetrieveStatus().IsDirty);
+ }
+ }
+
+ [Fact]
+ public void CanCancelRecursiveClone()
+ {
+ var uri = new Uri(Path.GetFullPath(SandboxSubmoduleSmallTestRepo()));
+ var scd = BuildSelfCleaningDirectory();
+ string relativeSubmodulePath = "submodule_target_wd";
+
+ int cancelDepth = 0;
+
+ RepositoryOperationStarting repositoryOperationStarting = (x) =>
+ {
+ return !(x.RecursionDepth >= cancelDepth);
+ };
+
+ CloneOptions options = new CloneOptions()
+ {
+ RecurseSubmodules = true,
+ RepositoryOperationStarting = repositoryOperationStarting,
+ };
+
+ Assert.Throws(() =>
+ Repository.Clone(uri.AbsolutePath, scd.DirectoryPath, options));
+
+ // Cancel after super repository is cloned, but before submodule is cloned.
+ cancelDepth = 1;
+
+ string clonedRepoPath = null;
+
+ try
+ {
+ Repository.Clone(uri.AbsolutePath, scd.DirectoryPath, options);
+ }
+ catch(RecurseSubmodulesException ex)
+ {
+ Assert.NotNull(ex.InnerException);
+ Assert.Equal(typeof(UserCancelledException), ex.InnerException.GetType());
+ clonedRepoPath = ex.InitialRepositoryPath;
+ }
+
+ // Verify that the submodule was not initialized.
+ using(Repository repo = new Repository(clonedRepoPath))
+ {
+ var submoduleStatus = repo.Submodules[relativeSubmodulePath].RetrieveStatus();
+ Assert.Equal(SubmoduleStatus.InConfig | SubmoduleStatus.InHead | SubmoduleStatus.InIndex | SubmoduleStatus.WorkDirUninitialized,
+ submoduleStatus);
+
+ }
+ }
}
}
diff --git a/LibGit2Sharp.Tests/CommitAncestorFixture.cs b/LibGit2Sharp.Tests/CommitAncestorFixture.cs
index 6ea6176b6..c752f7415 100644
--- a/LibGit2Sharp.Tests/CommitAncestorFixture.cs
+++ b/LibGit2Sharp.Tests/CommitAncestorFixture.cs
@@ -41,7 +41,7 @@ public void FindCommonAncestorForTwoCommits(string result, string sha1, string s
var first = sha1 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha1);
var second = sha2 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha2);
- Commit ancestor = repo.Commits.FindMergeBase(first, second);
+ Commit ancestor = repo.ObjectDatabase.FindMergeBase(first, second);
if (result == null)
{
@@ -71,7 +71,7 @@ public void FindCommonAncestorForCommitsAsEnumerable(string result, string[] sha
{
var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray();
- Commit ancestor = repo.Commits.FindMergeBase(commits, strategy);
+ Commit ancestor = repo.ObjectDatabase.FindMergeBase(commits, strategy);
if (result == null)
{
@@ -96,7 +96,7 @@ public void FindCommonAncestorForTwoCommitsThrows(string sha1, string sha2)
var first = repo.Lookup(sha1);
var second = repo.Lookup(sha2);
- Assert.Throws(() => repo.Commits.FindMergeBase(first, second));
+ Assert.Throws(() => repo.ObjectDatabase.FindMergeBase(first, second));
}
}
@@ -112,7 +112,7 @@ public void FindCommonAncestorForCommitsAsEnumerableThrows(string[] shas, MergeB
{
var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray();
- Assert.Throws(() => repo.Commits.FindMergeBase(commits, strategy));
+ Assert.Throws(() => repo.ObjectDatabase.FindMergeBase(commits, strategy));
}
}
diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs
index fa76f585f..82148246d 100644
--- a/LibGit2Sharp.Tests/CommitFixture.cs
+++ b/LibGit2Sharp.Tests/CommitFixture.cs
@@ -92,7 +92,7 @@ public void CanEnumerateCommitsFromSha()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
+ foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
{
Assert.NotNull(commit);
count++;
@@ -107,9 +107,9 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = Constants.UnknownSha }).Count());
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = "refs/heads/deadbeef" }).Count());
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = null }).Count());
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = Constants.UnknownSha }).Count());
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = "refs/heads/deadbeef" }).Count());
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = null }).Count());
}
}
@@ -121,8 +121,8 @@ public void QueryingTheCommitHistoryFromACorruptedReferenceThrows()
{
CreateCorruptedDeadBeefHead(repo.Info.Path);
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Branches["deadbeef"] }).Count());
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs["refs/heads/deadbeef"] }).Count());
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Branches["deadbeef"] }).Count());
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Refs["refs/heads/deadbeef"] }).Count());
}
}
@@ -132,8 +132,8 @@ public void QueryingTheCommitHistoryWithBadParamsThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = string.Empty }));
- Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = null }));
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = string.Empty }));
+ Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = null }));
Assert.Throws(() => repo.Commits.QueryBy(default(CommitFilter)));
}
}
@@ -150,7 +150,7 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
- Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
+ IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}))
{
@@ -170,7 +170,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
{
List commits = repo.Commits.QueryBy(new CommitFilter
{
- Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
+ IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}).ToList();
foreach (Commit commit in commits)
@@ -189,7 +189,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
public void CanSimplifyByFirstParent()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = repo.Head, FirstParentOnly = true },
+ repo => new CommitFilter { IncludeReachableFrom = repo.Head, FirstParentOnly = true },
new[]
{
"4c062a6", "be3563a", "9fd738e",
@@ -216,7 +216,7 @@ public void CanEnumerateCommitsWithTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
- Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
+ IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time
}))
{
@@ -236,7 +236,7 @@ public void CanEnumerateCommitsWithTopoSorting()
{
List commits = repo.Commits.QueryBy(new CommitFilter
{
- Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
+ IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Topological
}).ToList();
foreach (Commit commit in commits)
@@ -255,7 +255,7 @@ public void CanEnumerateCommitsWithTopoSorting()
public void CanEnumerateFromHead()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = repo.Head },
+ repo => new CommitFilter { IncludeReachableFrom = repo.Head },
new[]
{
"4c062a6", "be3563a", "c47800c", "9fd738e",
@@ -277,7 +277,7 @@ public void CanEnumerateFromDetachedHead()
repoClone.Checkout(headSha);
AssertEnumerationOfCommitsInRepo(repoClone,
- repo => new CommitFilter { Since = repo.Head },
+ repo => new CommitFilter { IncludeReachableFrom = repo.Head },
new[]
{
"32eab9c", "592d3c8", "4c062a6",
@@ -291,7 +291,7 @@ public void CanEnumerateFromDetachedHead()
public void CanEnumerateUsingTwoHeadsAsBoundaries()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = "HEAD", Until = "refs/heads/br2" },
+ repo => new CommitFilter { IncludeReachableFrom = "HEAD", ExcludeReachableFrom = "refs/heads/br2" },
new[] { "4c062a6", "be3563a" }
);
}
@@ -300,7 +300,7 @@ public void CanEnumerateUsingTwoHeadsAsBoundaries()
public void CanEnumerateUsingImplicitHeadAsSinceBoundary()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Until = "refs/heads/br2" },
+ repo => new CommitFilter { ExcludeReachableFrom = "refs/heads/br2" },
new[] { "4c062a6", "be3563a" }
);
}
@@ -309,7 +309,7 @@ public void CanEnumerateUsingImplicitHeadAsSinceBoundary()
public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = "a4a7dce", Until = "4a202b3" },
+ repo => new CommitFilter { IncludeReachableFrom = "a4a7dce", ExcludeReachableFrom = "4a202b3" },
new[] { "a4a7dce", "c47800c", "9fd738e" }
);
}
@@ -318,7 +318,7 @@ public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
public void CanEnumerateCommitsFromTwoHeads()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = new[] { "refs/heads/br2", "refs/heads/master" } },
+ repo => new CommitFilter { IncludeReachableFrom = new[] { "refs/heads/br2", "refs/heads/master" } },
new[]
{
"4c062a6", "a4a7dce", "be3563a", "c47800c",
@@ -330,7 +330,7 @@ public void CanEnumerateCommitsFromTwoHeads()
public void CanEnumerateCommitsFromMixedStartingPoints()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = new object[] { repo.Branches["br2"],
+ repo => new CommitFilter { IncludeReachableFrom = new object[] { repo.Branches["br2"],
"refs/heads/master",
new ObjectId("e90810b8df3e80c413d903f631643c716887138d") } },
new[]
@@ -345,7 +345,7 @@ public void CanEnumerateCommitsFromMixedStartingPoints()
public void CanEnumerateCommitsUsingGlob()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = repo.Refs.FromGlob("refs/heads/*") },
+ repo => new CommitFilter { IncludeReachableFrom = repo.Refs.FromGlob("refs/heads/*") },
new[]
{
"4c062a6", "e90810b", "6dcf9bf", "a4a7dce", "be3563a", "c47800c", "9fd738e", "4a202b3", "41bc8c6", "5001298", "5b5b025", "8496071"
@@ -356,7 +356,7 @@ public void CanEnumerateCommitsUsingGlob()
public void CanHideCommitsUsingGlob()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = "refs/heads/packed-test", Until = repo.Refs.FromGlob("*/packed") },
+ repo => new CommitFilter { IncludeReachableFrom = "refs/heads/packed-test", ExcludeReachableFrom = repo.Refs.FromGlob("*/packed") },
new[]
{
"4a202b3", "5b5b025", "8496071"
@@ -378,7 +378,7 @@ public void CanEnumerateCommitsFromATagAnnotation()
private void CanEnumerateCommitsFromATag(Func transformer)
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = transformer(repo.Tags["test"]) },
+ repo => new CommitFilter { IncludeReachableFrom = transformer(repo.Tags["test"]) },
new[] { "e90810b", "6dcf9bf", }
);
}
@@ -389,7 +389,7 @@ public void CanEnumerateAllCommits()
AssertEnumerationOfCommits(
repo => new CommitFilter
{
- Since = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
+ IncludeReachableFrom = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
},
new[]
{
@@ -404,7 +404,7 @@ public void CanEnumerateAllCommits()
public void CanEnumerateCommitsFromATagWhichPointsToABlob()
{
AssertEnumerationOfCommits(
- repo => new CommitFilter { Since = repo.Tags["point_to_blob"] },
+ repo => new CommitFilter { IncludeReachableFrom = repo.Tags["point_to_blob"] },
new string[] { });
}
@@ -419,7 +419,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToATree()
Tag tag = repo.ApplyTag("point_to_tree", headTreeSha);
AssertEnumerationOfCommitsInRepo(repo,
- r => new CommitFilter { Since = tag },
+ r => new CommitFilter { IncludeReachableFrom = tag },
new string[] { });
}
}
@@ -538,32 +538,11 @@ public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull()
}
}
- [Theory]
- [InlineData(null, "x@example.com")]
- [InlineData("", "x@example.com")]
- [InlineData("X", null)]
- [InlineData("X", "")]
- public void CommitWithInvalidSignatureConfigThrows(string name, string email)
- {
- string repoPath = InitNewRepository();
- string configPath = CreateConfigurationWithDummyUser(name, email);
- var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
-
- using (var repo = new Repository(repoPath, options))
- {
- Assert.Equal(name, repo.Config.GetValueOrDefault("user.name"));
- Assert.Equal(email, repo.Config.GetValueOrDefault("user.email"));
-
- Assert.Throws(
- () => repo.Commit("Initial egotistic commit", new CommitOptions { AllowEmptyCommit = true }));
- }
- }
-
[Fact]
public void CanCommitWithSignatureFromConfig()
{
string repoPath = InitNewRepository();
- string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
+ string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, options))
@@ -581,12 +560,14 @@ public void CanCommitWithSignatureFromConfig()
Assert.Null(repo.Head[relativeFilepath]);
- Commit commit = repo.Commit("Initial egotistic commit");
+ Signature signature = repo.Config.BuildSignature(DateTimeOffset.Now);
+
+ Commit commit = repo.Commit("Initial egotistic commit", signature, signature);
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
AssertBlobContent(commit[relativeFilepath], "nulltoken\n");
- AssertCommitSignaturesAre(commit, Constants.Signature);
+ AssertCommitIdentitiesAre(commit, Constants.Identity);
}
}
@@ -615,8 +596,8 @@ public void CommitParentsAreMergeHeads()
// Assert reflog entry is created
var reflogEntry = repo.Refs.Log(repo.Refs.Head).First();
Assert.Equal(repo.Head.Tip.Id, reflogEntry.To);
- Assert.NotNull(reflogEntry.Commiter.Email);
- Assert.NotNull(reflogEntry.Commiter.Name);
+ Assert.NotNull(reflogEntry.Committer.Email);
+ Assert.NotNull(reflogEntry.Committer.Name);
Assert.Equal(string.Format("commit (merge): {0}", newMergedCommit.MessageShort), reflogEntry.Message);
}
}
@@ -661,7 +642,9 @@ public void CanCommitALittleBit()
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
string dir = repo.Info.Path;
Assert.True(Path.IsPathRooted(dir));
@@ -680,6 +663,8 @@ public void CanCommitALittleBit()
const string shortMessage = "Initial egotistic commit";
const string commitMessage = shortMessage + "\n\nOnly the coolest commits from us";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Commit commit = repo.Commit(commitMessage, author, author);
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
@@ -691,7 +676,13 @@ public void CanCommitALittleBit()
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Commiter);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, before, now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Assert.Equal(string.Format("commit (initial): {0}", shortMessage), reflogEntry.Message);
@@ -805,7 +796,7 @@ public void CanAmendARootCommit()
public void CanAmendACommitWithMoreThanOneParent()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
var mergedCommit = repo.Lookup("be3563a");
Assert.NotNull(mergedCommit);
@@ -816,16 +807,18 @@ public void CanAmendACommitWithMoreThanOneParent()
CreateAndStageANewFile(repo);
const string commitMessage = "I'm rewriting the history!";
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Commit amendedCommit = repo.Commit(commitMessage, Constants.Signature, Constants.Signature,
new CommitOptions { AmendPreviousCommit = true });
AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);
AssertRefLogEntry(repo, "HEAD",
- amendedCommit.Id,
string.Format("commit (amend): {0}", commitMessage),
mergedCommit.Id,
- amendedCommit.Committer);
+ amendedCommit.Id,
+ Constants.Identity, before);
}
}
@@ -868,10 +861,10 @@ public void CanRetrieveChildrenOfASpecificCommit()
var filter = new CommitFilter
{
/* Revwalk from all the refs (git log --all) ... */
- Since = repo.Refs,
+ IncludeReachableFrom = repo.Refs,
/* ... and stop when the parent is reached */
- Until = parentSha
+ ExcludeReachableFrom = parentSha
};
var commits = repo.Commits.QueryBy(filter);
diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs
index edce94932..30c8b207f 100644
--- a/LibGit2Sharp.Tests/ConfigurationFixture.cs
+++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs
@@ -1,8 +1,10 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
@@ -14,35 +16,6 @@ private static void AssertValueInLocalConfigFile(string repoPath, string regex)
AssertValueInConfigFile(configFilePath, regex);
}
- private static string RetrieveGlobalConfigLocation()
- {
- string[] variables = { "HOME", "USERPROFILE", };
-
- foreach (string variable in variables)
- {
- string potentialLocation = Environment.GetEnvironmentVariable(variable);
- if (string.IsNullOrEmpty(potentialLocation))
- {
- continue;
- }
-
- string potentialPath = Path.Combine(potentialLocation, ".gitconfig");
-
- if (File.Exists(potentialPath))
- {
- return potentialPath;
- }
- }
-
- throw new InvalidOperationException("Unable to determine the location of '.gitconfig' file.");
- }
-
- private static void AssertValueInGlobalConfigFile(string regex)
- {
- string configFilePath = RetrieveGlobalConfigLocation();
- AssertValueInConfigFile(configFilePath, regex);
- }
-
[Fact]
public void CanUnsetAnEntryFromTheLocalConfiguration()
{
@@ -170,7 +143,7 @@ public void CanReadStringValue()
[Fact]
public void CanEnumerateGlobalConfig()
{
- string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
+ string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
var path = SandboxStandardTestRepoGitDir();
@@ -217,14 +190,17 @@ public void CanFindInLocalConfig()
Assert.NotNull(matches);
Assert.Equal(new[] { "unittests.intsetting", "unittests.longsetting" },
- matches.Select(m => m.Key).ToArray());
+ matches
+ .Select(m => m.Key)
+ .OrderBy(s => s)
+ .ToArray());
}
}
[Fact]
public void CanFindInGlobalConfig()
{
- string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
+ string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
var path = SandboxStandardTestRepoGitDir();
@@ -253,7 +229,7 @@ public void CanSetBooleanValue()
[Fact]
public void SettingLocalConfigurationOutsideAReposThrows()
{
- using (var config = new Configuration())
+ using (var config = Configuration.BuildFrom(null, null, null, null))
{
Assert.Throws(() => config.Set("unittests.intsetting", 3));
}
@@ -392,5 +368,190 @@ public void CanTellIfASpecificStoreContainsAKey()
Assert.Null(repo.Config.Get("MCHammer.You-cant-touch-this", ConfigurationLevel.System));
}
}
+
+ public static IEnumerable
-
+
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/MergeFixture.cs b/LibGit2Sharp.Tests/MergeFixture.cs
index af386bd69..eadbffec5 100644
--- a/LibGit2Sharp.Tests/MergeFixture.cs
+++ b/LibGit2Sharp.Tests/MergeFixture.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics;
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
@@ -296,6 +295,24 @@ public void ConflictingMergeReposBinary()
}
}
+ [Fact]
+ public void CanFailOnFirstMergeConflict()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var mergeResult = repo.Merge("conflicts", Constants.Signature, new MergeOptions() { FailOnConflict = true, });
+ Assert.Equal(MergeStatus.Conflicts, mergeResult.Status);
+
+ var master = repo.Branches["master"];
+ var branch = repo.Branches["conflicts"];
+ var mergeTreeResult = repo.ObjectDatabase.MergeCommits(master.Tip, branch.Tip, new MergeTreeOptions() { FailOnConflict = true });
+ Assert.Equal(MergeTreeStatus.Conflicts, mergeTreeResult.Status);
+ Assert.Empty(mergeTreeResult.Conflicts);
+ }
+
+ }
+
[Theory]
[InlineData(true, FastForwardStrategy.Default, fastForwardBranchInitialId, MergeStatus.FastForward)]
[InlineData(true, FastForwardStrategy.FastForwardOnly, fastForwardBranchInitialId, MergeStatus.FastForward)]
@@ -324,9 +341,9 @@ public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fast
[Theory]
[InlineData(true, FastForwardStrategy.Default, MergeStatus.NonFastForward)]
- [InlineData(true, FastForwardStrategy.NoFastFoward, MergeStatus.NonFastForward)]
+ [InlineData(true, FastForwardStrategy.NoFastForward, MergeStatus.NonFastForward)]
[InlineData(false, FastForwardStrategy.Default, MergeStatus.NonFastForward)]
- [InlineData(false, FastForwardStrategy.NoFastFoward, MergeStatus.NonFastForward)]
+ [InlineData(false, FastForwardStrategy.NoFastForward, MergeStatus.NonFastForward)]
public void CanNonFastForwardMergeCommit(bool fromDetachedHead, FastForwardStrategy fastForwardStrategy, MergeStatus expectedMergeStatus)
{
string path = SandboxMergeTestRepo();
@@ -362,7 +379,7 @@ public void MergeReportsCheckoutProgress()
OnCheckoutProgress = (path, completed, total) => wasCalled = true,
};
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, options);
+ repo.Merge(commitToMerge, Constants.Signature, options);
Assert.True(wasCalled);
}
@@ -385,7 +402,7 @@ public void MergeReportsCheckoutNotifications()
CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
};
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, options);
+ repo.Merge(commitToMerge, Constants.Signature, options);
Assert.True(wasCalled);
Assert.Equal(CheckoutNotifyFlags.Updated, actualNotifyFlags);
@@ -407,7 +424,7 @@ public void FastForwardMergeReportsCheckoutProgress()
OnCheckoutProgress = (path, completed, total) => wasCalled = true,
};
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, options);
+ repo.Merge(commitToMerge, Constants.Signature, options);
Assert.True(wasCalled);
}
@@ -430,7 +447,7 @@ public void FastForwardMergeReportsCheckoutNotifications()
CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
};
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, options);
+ repo.Merge(commitToMerge, Constants.Signature, options);
Assert.True(wasCalled);
Assert.Equal(CheckoutNotifyFlags.Updated, actualNotifyFlags);
@@ -504,7 +521,7 @@ public void CanMergeAndNotCommit()
// Verify that there is a staged entry.
Assert.Equal(1, repoStatus.Count());
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("b.txt"));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus("b.txt"));
}
}
@@ -516,7 +533,7 @@ public void CanForceNonFastForwardMerge()
{
Commit commitToMerge = repo.Branches["fast_forward"].Tip;
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastFoward });
+ MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastForward });
Assert.Equal(MergeStatus.NonFastForward, result.Status);
Assert.Equal("f58f780d5a0ae392efd4a924450b1bbdc0577d32", result.Commit.Id.Sha);
@@ -550,7 +567,7 @@ public void VerifyUpToDateMerge()
{
Commit commitToMerge = repo.Branches["master"].Tip;
- MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastFoward });
+ MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastForward });
Assert.Equal(MergeStatus.UpToDate, result.Status);
Assert.Equal(null, result.Commit);
@@ -578,14 +595,14 @@ public void CanMergeCommittish(string committish, FastForwardStrategy strategy,
[Theory]
[InlineData(true, FastForwardStrategy.FastForwardOnly)]
[InlineData(false, FastForwardStrategy.FastForwardOnly)]
- [InlineData(true, FastForwardStrategy.NoFastFoward)]
- [InlineData(false, FastForwardStrategy.NoFastFoward)]
+ [InlineData(true, FastForwardStrategy.NoFastForward)]
+ [InlineData(false, FastForwardStrategy.NoFastForward)]
public void MergeWithWorkDirConflictsThrows(bool shouldStage, FastForwardStrategy strategy)
{
// Merging the fast_forward branch results in a change to file
// b.txt. In this test we modify the file in the working directory
// and then attempt to perform a merge. We expect the merge to fail
- // due to merge conflicts.
+ // due to checkout conflicts.
string committishToMerge = "fast_forward";
using (var repo = new Repository(SandboxMergeTestRepo()))
@@ -597,7 +614,7 @@ public void MergeWithWorkDirConflictsThrows(bool shouldStage, FastForwardStrateg
repo.Stage("b.txt");
}
- Assert.Throws(() => repo.Merge(committishToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy }));
+ Assert.Throws(() => repo.Merge(committishToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy }));
}
}
@@ -666,7 +683,6 @@ public void MergeCanSpecifyMergeFileFavorOption(MergeFileFavor fileFavorFlag)
Branch branch = repo.Branches[conflictBranchName];
Assert.NotNull(branch);
- var status = repo.RetrieveStatus();
MergeOptions mergeOptions = new MergeOptions()
{
MergeFileFavor = fileFavorFlag,
@@ -749,6 +765,106 @@ public void CanMergeIntoOrphanedBranch()
}
}
+
+ [Fact]
+ public void CanMergeTreeIntoSameTree()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Branches["master"].Tip;
+
+ var result = repo.ObjectDatabase.MergeCommits(master, master, null);
+ Assert.Equal(MergeTreeStatus.Succeeded, result.Status);
+ Assert.Equal(0, result.Conflicts.Count());
+ }
+ }
+
+ [Fact]
+ public void CanMergeTreeIntoTreeFromUnbornBranch()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
+
+ Touch(repo.Info.WorkingDirectory, "README", "Yeah!\n");
+ repo.Index.Clear();
+ repo.Stage("README");
+
+ repo.Commit("A new world, free of the burden of the history", Constants.Signature, Constants.Signature);
+
+ var master = repo.Branches["master"].Tip;
+ var branch = repo.Branches["unborn"].Tip;
+
+ var result = repo.ObjectDatabase.MergeCommits(master, branch, null);
+ Assert.Equal(MergeTreeStatus.Succeeded, result.Status);
+ Assert.NotNull(result.Tree);
+ Assert.Equal(0, result.Conflicts.Count());
+ }
+ }
+
+ [Fact]
+ public void CanMergeCommitsAndDetectConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
+
+ repo.Index.Replace(repo.Lookup("conflicts"));
+
+ repo.Commit("A conflicting world, free of the burden of the history", Constants.Signature, Constants.Signature);
+
+ var master = repo.Branches["master"].Tip;
+ var branch = repo.Branches["unborn"].Tip;
+
+ var result = repo.ObjectDatabase.MergeCommits(master, branch, null);
+ Assert.Equal(MergeTreeStatus.Conflicts, result.Status);
+ Assert.Null(result.Tree);
+ Assert.NotEqual(0, result.Conflicts.Count());
+ }
+ }
+
+ [Fact]
+ public void CanMergeFastForwardTreeWithoutConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Lookup("master");
+ var branch = repo.Lookup("fast_forward");
+
+ var result = repo.ObjectDatabase.MergeCommits(master, branch, null);
+ Assert.Equal(MergeTreeStatus.Succeeded, result.Status);
+ Assert.NotNull(result.Tree);
+ Assert.Equal(0, result.Conflicts.Count());
+ }
+ }
+
+ [Fact]
+ public void CanIdentifyConflictsInMergeCommits()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Lookup("master");
+ var branch = repo.Lookup("conflicts");
+
+ var result = repo.ObjectDatabase.MergeCommits(master, branch, null);
+
+ Assert.Equal(MergeTreeStatus.Conflicts, result.Status);
+
+ Assert.Null(result.Tree);
+ Assert.Equal(1, result.Conflicts.Count());
+
+ var conflict = result.Conflicts.First();
+ Assert.Equal(new ObjectId("8e9daea300fbfef6c0da9744c6214f546d55b279"), conflict.Ancestor.Id);
+ Assert.Equal(new ObjectId("610b16886ca829cebd2767d9196f3c4378fe60b5"), conflict.Ours.Id);
+ Assert.Equal(new ObjectId("3dd9738af654bbf1c363f6c3bbc323bacdefa179"), conflict.Theirs.Id);
+ }
+ }
+
private Commit AddFileCommitToRepo(IRepository repository, string filename, string content = null)
{
Touch(repository.Info.WorkingDirectory, filename, content);
diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs
index 9a53cdd14..057c9a1d4 100644
--- a/LibGit2Sharp.Tests/MetaFixture.cs
+++ b/LibGit2Sharp.Tests/MetaFixture.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Globalization;
using System.Linq;
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
+using Moq;
namespace LibGit2Sharp.Tests
{
@@ -14,7 +17,7 @@ public class MetaFixture
{
private static readonly HashSet explicitOnlyInterfaces = new HashSet
{
- typeof(IBelongToARepository),
+ typeof(IBelongToARepository), typeof(IDiffResult),
};
[Fact]
@@ -105,6 +108,28 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()
{
nonTestableTypes.Add(type, new List());
}
+
+ if (type.IsAbstract)
+ {
+ continue;
+ }
+
+ try
+ {
+ if (type.ContainsGenericParameters)
+ {
+ var constructType = type.MakeGenericType(Enumerable.Repeat(typeof(object), type.GetGenericArguments().Length).ToArray());
+ Activator.CreateInstance(constructType, true);
+ }
+ else
+ {
+ Activator.CreateInstance(type, true);
+ }
+ }
+ catch
+ {
+ nonTestableTypes.Add(type, new List());
+ }
}
if (nonTestableTypes.Any())
@@ -244,7 +269,7 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
var nonVirtualGetEnumeratorMethods = Assembly.GetAssembly(typeof(IRepository))
.GetExportedTypes()
.Where(t =>
- t.Namespace == typeof (IRepository).Namespace &&
+ t.Namespace == typeof(IRepository).Namespace &&
!t.IsSealed &&
!t.IsAbstract &&
t.GetInterfaces().Any(i => i.IsAssignableFrom(typeof(IEnumerable<>))))
@@ -254,12 +279,150 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
(!m.IsVirtual || m.IsFinal))
.ToList();
- foreach (var method in nonVirtualGetEnumeratorMethods)
+ if (nonVirtualGetEnumeratorMethods.Any())
+ {
+ var sb = new StringBuilder();
+
+ foreach (var method in nonVirtualGetEnumeratorMethods)
+ {
+ sb.AppendFormat("GetEnumerator in type '{0}' isn't virtual.{1}",
+ method.DeclaringType, Environment.NewLine);
+ }
+
+ Assert.True(false, Environment.NewLine + sb.ToString());
+ }
+ }
+
+ [Fact]
+ public void NoPublicTypesUnderLibGit2SharpCoreNamespace()
+ {
+ const string coreNamespace = "LibGit2Sharp.Core";
+
+ var types = Assembly.GetAssembly(typeof(IRepository))
+ .GetExportedTypes()
+ .Where(t => t.FullName.StartsWith(coreNamespace + "."))
+
+ // Ugly hack to circumvent a Mono bug
+ // cf. https://bugzilla.xamarin.com/show_bug.cgi?id=27010
+ .Where(t => !t.FullName.Contains("+"))
+
+#if LEAKS_IDENTIFYING
+ .Where(t => t != typeof(LibGit2Sharp.Core.LeaksContainer))
+#endif
+ .ToList();
+
+ if (types.Any())
+ {
+ var sb = new StringBuilder();
+
+ foreach (var type in types)
+ {
+ sb.AppendFormat("Public type '{0}' under the '{1}' namespace.{2}",
+ type.FullName, coreNamespace, Environment.NewLine);
+ }
+
+ Assert.True(false, Environment.NewLine + sb.ToString());
+ }
+ }
+
+ [Fact]
+ public void NoOptionalParametersinMethods()
+ {
+ IEnumerable mis =
+ from t in Assembly.GetAssembly(typeof(IRepository))
+ .GetExportedTypes()
+ from m in t.GetMethods()
+ where !m.IsObsolete()
+ from p in m.GetParameters()
+ where p.IsOptional
+ select m.DeclaringType + "." + m.Name;
+
+ var sb = new StringBuilder();
+
+ foreach (var method in mis.Distinct())
{
- Debug.WriteLine(String.Format("GetEnumerator in type '{0}' isn't virtual.", method.DeclaringType));
+ sb.AppendFormat("At least one overload of method '{0}' accepts an optional parameter.{1}",
+ method, Environment.NewLine);
}
- Assert.Empty(nonVirtualGetEnumeratorMethods);
+ Assert.Equal("", sb.ToString());
+ }
+
+ [Fact]
+ public void NoOptionalParametersinConstructors()
+ {
+ IEnumerable mis =
+ from t in Assembly.GetAssembly(typeof(IRepository))
+ .GetExportedTypes()
+ from c in t.GetConstructors()
+ from p in c.GetParameters()
+ where p.IsOptional
+ select c.DeclaringType.Name;
+
+ var sb = new StringBuilder();
+
+ foreach (var method in mis.Distinct())
+ {
+ sb.AppendFormat("At least one constructor of type '{0}' accepts an optional parameter.{1}",
+ method, Environment.NewLine);
+ }
+
+ Assert.Equal("", sb.ToString());
+ }
+
+ [Fact]
+ public void PublicExtensionMethodsShouldonlyTargetInterfacesOrEnums()
+ {
+ IEnumerable mis =
+ from m in GetInvalidPublicExtensionMethods()
+ select m.DeclaringType + "." + m.Name;
+
+ var sb = new StringBuilder();
+
+ foreach (var method in mis.Distinct())
+ {
+ sb.AppendFormat("'{0}' is a public extension method that doesn't target an interface or an enum.{1}",
+ method, Environment.NewLine);
+ }
+
+ Assert.Equal("", sb.ToString());
+ }
+
+ // Inspired from http://stackoverflow.com/a/299526
+
+ static IEnumerable GetInvalidPublicExtensionMethods()
+ {
+ var query = from type in (Assembly.GetAssembly(typeof(IRepository))).GetTypes()
+ where type.IsSealed && !type.IsGenericType && !type.IsNested && type.IsPublic
+ from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)
+ where method.IsDefined(typeof(ExtensionAttribute), false)
+ let parameterType = method.GetParameters()[0].ParameterType
+ where parameterType != null && !parameterType.IsInterface && !parameterType.IsEnum
+ select method;
+ return query;
+ }
+
+ [Fact]
+ public void AllIDiffResultsAreInChangesBuilder()
+ {
+ var diff = typeof(Diff).GetField("ChangesBuilders", BindingFlags.NonPublic | BindingFlags.Static);
+ var changesBuilders = (System.Collections.IDictionary)diff.GetValue(null);
+
+ IEnumerable diffResults = typeof(Diff).Assembly.GetExportedTypes()
+ .Where(type => type.GetInterface("IDiffResult") != null);
+
+ var nonBuilderTypes = diffResults.Where(diffResult => !changesBuilders.Contains(diffResult));
+ Assert.False(nonBuilderTypes.Any(), "Classes which implement IDiffResult but are not registered under ChangesBuilders in Diff:" + Environment.NewLine +
+ string.Join(Environment.NewLine, nonBuilderTypes.Select(type => type.FullName)));
+ }
+ }
+
+ internal static class TypeExtensions
+ {
+ internal static bool IsObsolete(this MethodInfo methodInfo)
+ {
+ var attributes = methodInfo.GetCustomAttributes(false);
+ return attributes.Any(a => a is ObsoleteAttribute);
}
}
}
diff --git a/LibGit2Sharp.Tests/MockingFixture.cs b/LibGit2Sharp.Tests/MockingFixture.cs
index 6b99a6bb8..6db7dc645 100644
--- a/LibGit2Sharp.Tests/MockingFixture.cs
+++ b/LibGit2Sharp.Tests/MockingFixture.cs
@@ -73,8 +73,8 @@ public int NumberOfCommits
[Fact]
public void CanFakeConfigurationBuildSignature()
{
- var name = "name";
- var email = "email";
+ const string name = "name";
+ const string email = "email";
var now = DateTimeOffset.UtcNow;
var fakeConfig = new Mock();
diff --git a/LibGit2Sharp.Tests/NetworkFixture.cs b/LibGit2Sharp.Tests/NetworkFixture.cs
index 31959286c..dd5350b56 100644
--- a/LibGit2Sharp.Tests/NetworkFixture.cs
+++ b/LibGit2Sharp.Tests/NetworkFixture.cs
@@ -22,23 +22,26 @@ public void CanListRemoteReferences(string url)
using (var repo = new Repository(repoPath))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);
- IList references = repo.Network.ListReferences(remote).ToList();
+ IList references = repo.Network.ListReferences(remote).ToList();
- foreach (var directReference in references)
+
+ foreach (var reference in references)
{
// None of those references point to an existing
// object in this brand new repository
- Assert.Null(directReference.Target);
+ Assert.Null(reference.ResolveToDirectReference().Target);
}
List> actualRefs = references.
- Select(directRef => new Tuple(directRef.CanonicalName, directRef.TargetIdentifier)).ToList();
+ Select(directRef => new Tuple(directRef.CanonicalName, directRef.ResolveToDirectReference()
+ .TargetIdentifier)).ToList();
- Assert.Equal(ExpectedRemoteRefs.Count, actualRefs.Count);
- for (int i = 0; i < ExpectedRemoteRefs.Count; i++)
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs.Count, actualRefs.Count);
+ Assert.True(references.Single(reference => reference.CanonicalName == "HEAD") is SymbolicReference);
+ for (int i = 0; i < TestRemoteRefs.ExpectedRemoteRefs.Count; i++)
{
- Assert.Equal(ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
- Assert.Equal(ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
}
}
}
@@ -53,23 +56,25 @@ public void CanListRemoteReferencesFromUrl(string url)
using (var repo = new Repository(repoPath))
{
- IList references = repo.Network.ListReferences(url).ToList();
+ IList references = repo.Network.ListReferences(url).ToList();
- foreach (var directReference in references)
+ foreach (var reference in references)
{
// None of those references point to an existing
// object in this brand new repository
- Assert.Null(directReference.Target);
+ Assert.Null(reference.ResolveToDirectReference().Target);
}
List> actualRefs = references.
- Select(directRef => new Tuple(directRef.CanonicalName, directRef.TargetIdentifier)).ToList();
+ Select(directRef => new Tuple(directRef.CanonicalName, directRef.ResolveToDirectReference()
+ .TargetIdentifier)).ToList();
- Assert.Equal(ExpectedRemoteRefs.Count, actualRefs.Count);
- for (int i = 0; i < ExpectedRemoteRefs.Count; i++)
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs.Count, actualRefs.Count);
+ Assert.True(references.Single(reference => reference.CanonicalName == "HEAD") is SymbolicReference);
+ for (int i = 0; i < TestRemoteRefs.ExpectedRemoteRefs.Count; i++)
{
- Assert.Equal(ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
- Assert.Equal(ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
}
}
}
@@ -87,22 +92,26 @@ public void CanListRemoteReferenceObjects()
using (var repo = new Repository(clonedRepoPath))
{
Remote remote = repo.Network.Remotes[remoteName];
- IEnumerable references = repo.Network.ListReferences(remote);
+ IEnumerable references = repo.Network.ListReferences(remote).ToList();
var actualRefs = new List>();
- foreach(DirectReference reference in references)
+ foreach(Reference reference in references)
{
Assert.NotNull(reference.CanonicalName);
- Assert.NotNull(reference.Target);
- actualRefs.Add(new Tuple(reference.CanonicalName, reference.Target.Id.Sha));
+
+ var directReference = reference.ResolveToDirectReference();
+
+ Assert.NotNull(directReference.Target);
+ actualRefs.Add(new Tuple(reference.CanonicalName, directReference.Target.Id.Sha));
}
- Assert.Equal(ExpectedRemoteRefs.Count, actualRefs.Count);
- for (int i = 0; i < ExpectedRemoteRefs.Count; i++)
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs.Count, actualRefs.Count);
+ Assert.True(references.Single(reference => reference.CanonicalName == "HEAD") is SymbolicReference);
+ for (int i = 0; i < TestRemoteRefs.ExpectedRemoteRefs.Count; i++)
{
- Assert.Equal(ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
- Assert.Equal(ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
}
}
}
@@ -123,16 +132,16 @@ public void CanListRemoteReferencesWithCredentials()
var references = repo.Network.ListReferences(remote, Constants.PrivateRepoCredentials);
- foreach (var directReference in references)
+ foreach (var reference in references)
{
- Assert.NotNull(directReference);
+ Assert.NotNull(reference);
}
}
}
[Theory]
[InlineData(FastForwardStrategy.Default)]
- [InlineData(FastForwardStrategy.NoFastFoward)]
+ [InlineData(FastForwardStrategy.NoFastForward)]
public void CanPull(FastForwardStrategy fastForwardStrategy)
{
string url = "https://github.com/libgit2/TestGitRepository";
@@ -180,7 +189,7 @@ public void CanPullIntoEmptyRepo()
using (var repo = new Repository(repoPath))
{
// Set up remote
- Remote remote = repo.Network.Remotes.Add(remoteName, url);
+ repo.Network.Remotes.Add(remoteName, url);
// Set up tracking information
repo.Branches.Update(repo.Head,
@@ -228,32 +237,66 @@ public void PullWithoutMergeBranchThrows()
}
}
- /*
- * git ls-remote http://github.com/libgit2/TestGitRepository
- * 49322bb17d3acc9146f98c97d078513228bbf3c0 HEAD
- * 0966a434eb1a025db6b71485ab63a3bfbea520b6 refs/heads/first-merge
- * 49322bb17d3acc9146f98c97d078513228bbf3c0 refs/heads/master
- * 42e4e7c5e507e113ebbb7801b16b52cf867b7ce1 refs/heads/no-parent
- * d96c4e80345534eccee5ac7b07fc7603b56124cb refs/tags/annotated_tag
- * c070ad8c08840c8116da865b2d65593a6bb9cd2a refs/tags/annotated_tag^{}
- * 55a1a760df4b86a02094a904dfa511deb5655905 refs/tags/blob
- * 8f50ba15d49353813cc6e20298002c0d17b0a9ee refs/tags/commit_tree
- * 6e0c7bdb9b4ed93212491ee778ca1c65047cab4e refs/tags/nearly-dangling
- */
- ///
- /// Expected references on http://github.com/libgit2/TestGitRepository
- ///
- private static List> ExpectedRemoteRefs = new List>()
+ [Fact]
+ public void CanMergeFetchedRefs()
+ {
+ string url = "https://github.com/libgit2/TestGitRepository";
+
+ var scd = BuildSelfCleaningDirectory();
+ string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);
+
+ using (var repo = new Repository(clonedRepoPath))
+ {
+ repo.Reset(ResetMode.Hard, "HEAD~1");
+
+ Assert.False(repo.RetrieveStatus().Any());
+ Assert.Equal(repo.Lookup("refs/remotes/origin/master~1"), repo.Head.Tip);
+
+ repo.Network.Fetch(repo.Head.Remote);
+
+ MergeOptions mergeOptions = new MergeOptions()
+ {
+ FastForwardStrategy = FastForwardStrategy.NoFastForward
+ };
+
+ MergeResult mergeResult = repo.MergeFetchedRefs(Constants.Signature, mergeOptions);
+ Assert.Equal(mergeResult.Status, MergeStatus.NonFastForward);
+ }
+ }
+
+ [Fact]
+ public void CanPruneRefs()
{
- new Tuple("HEAD", "49322bb17d3acc9146f98c97d078513228bbf3c0"),
- new Tuple("refs/heads/first-merge", "0966a434eb1a025db6b71485ab63a3bfbea520b6"),
- new Tuple("refs/heads/master", "49322bb17d3acc9146f98c97d078513228bbf3c0"),
- new Tuple("refs/heads/no-parent", "42e4e7c5e507e113ebbb7801b16b52cf867b7ce1"),
- new Tuple("refs/tags/annotated_tag", "d96c4e80345534eccee5ac7b07fc7603b56124cb"),
- new Tuple("refs/tags/annotated_tag^{}", "c070ad8c08840c8116da865b2d65593a6bb9cd2a"),
- new Tuple("refs/tags/blob", "55a1a760df4b86a02094a904dfa511deb5655905"),
- new Tuple("refs/tags/commit_tree", "8f50ba15d49353813cc6e20298002c0d17b0a9ee"),
- new Tuple("refs/tags/nearly-dangling", "6e0c7bdb9b4ed93212491ee778ca1c65047cab4e"),
- };
+ string url = "https://github.com/libgit2/TestGitRepository";
+
+ var scd = BuildSelfCleaningDirectory();
+ string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);
+
+ var scd2 = BuildSelfCleaningDirectory();
+ string clonedRepoPath2 = Repository.Clone(url, scd2.DirectoryPath);
+
+
+ using (var repo = new Repository(clonedRepoPath))
+ {
+ repo.Network.Remotes.Add("pruner", clonedRepoPath2);
+ var remote = repo.Network.Remotes["pruner"];
+ repo.Network.Fetch(remote);
+ Assert.NotNull(repo.Refs["refs/remotes/pruner/master"]);
+
+ // Remove the branch from the source repository
+ using (var repo2 = new Repository(clonedRepoPath2))
+ {
+ repo2.Refs.Remove("refs/heads/master");
+ }
+
+ // and by default we don't prune it
+ repo.Network.Fetch(remote);
+ Assert.NotNull(repo.Refs["refs/remotes/pruner/master"]);
+
+ // but we do when asked by the user
+ repo.Network.Fetch(remote, new FetchOptions { Prune = true} );
+ Assert.Null(repo.Refs["refs/remotes/pruner/master"]);
+ }
+ }
}
}
diff --git a/LibGit2Sharp.Tests/NoteFixture.cs b/LibGit2Sharp.Tests/NoteFixture.cs
index 7da99db07..0c879e3e1 100644
--- a/LibGit2Sharp.Tests/NoteFixture.cs
+++ b/LibGit2Sharp.Tests/NoteFixture.cs
@@ -168,14 +168,17 @@ public void CreatingANoteWhichAlreadyExistsOverwritesThePreviousNote()
[Fact]
public void CanAddANoteWithSignatureFromConfig()
{
- string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
+ string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
string path = SandboxBareTestRepo();
using (var repo = new Repository(path, options))
{
var commit = repo.Lookup("9fd738e8f7967c078dceed8190330fc8648ee56a");
- var note = repo.Notes.Add(commit.Id, "I'm batman!\n", "batmobile");
+
+ Signature signature = repo.Config.BuildSignature(DateTimeOffset.Now);
+
+ var note = repo.Notes.Add(commit.Id, "I'm batman!\n", signature, signature, "batmobile");
var newNote = commit.Notes.Single();
Assert.Equal(note, newNote);
@@ -183,7 +186,7 @@ public void CanAddANoteWithSignatureFromConfig()
Assert.Equal("I'm batman!\n", newNote.Message);
Assert.Equal("batmobile", newNote.Namespace);
- AssertCommitSignaturesAre(repo.Lookup("refs/notes/batmobile"), Constants.Signature);
+ AssertCommitIdentitiesAre(repo.Lookup("refs/notes/batmobile"), Constants.Identity);
}
}
@@ -265,7 +268,7 @@ public void RemovingANonExistingNoteDoesntThrow()
[Fact]
public void CanRemoveANoteWithSignatureFromConfig()
{
- string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
+ string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
RepositoryOptions options = new RepositoryOptions() { GlobalConfigurationLocation = configPath };
string path = SandboxBareTestRepo();
@@ -276,11 +279,13 @@ public void CanRemoveANoteWithSignatureFromConfig()
Assert.NotEmpty(notes);
- repo.Notes.Remove(commit.Id, repo.Notes.DefaultNamespace);
+ Signature signature = repo.Config.BuildSignature(DateTimeOffset.Now);
+
+ repo.Notes.Remove(commit.Id, signature, signature, repo.Notes.DefaultNamespace);
Assert.Empty(notes);
- AssertCommitSignaturesAre(repo.Lookup("refs/notes/" + repo.Notes.DefaultNamespace), Constants.Signature);
+ AssertCommitIdentitiesAre(repo.Lookup("refs/notes/" + repo.Notes.DefaultNamespace), Constants.Identity);
}
}
diff --git a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
index 1ec121e93..8e2a1d843 100644
--- a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
+++ b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
@@ -41,7 +41,7 @@ public void CanCreateABlobFromAFileInTheWorkingDirectory()
Assert.Equal("dc53d4c6b8684c21b0b57db29da4a2afea011565", blob.Sha);
/* The file is unknown from the Index nor the Head ... */
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("hello.txt"));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus("hello.txt"));
/* ...however, it's indeed stored in the repository. */
var fetchedBlob = repo.Lookup(blob.Id);
@@ -103,15 +103,13 @@ public void CanCreateABlobIntoTheDatabaseOfABareRepository()
[InlineData("e9671e138a780833cb689753570fd10a55be84fb", "dummy.guess")]
public void CanCreateABlobFromAStream(string expectedSha, string hintPath)
{
- string path = InitNewRepository();
-
var sb = new StringBuilder();
for (int i = 0; i < 6; i++)
{
sb.Append("libgit2\n\r\n");
}
- using (var repo = new Repository(path))
+ using (var repo = InitIsolatedRepository())
{
CreateAttributesFiles(Path.Combine(repo.Info.Path, "info"), "attributes");
@@ -654,6 +652,90 @@ public void CanShortenObjectIdentifier()
}
}
+ [Fact]
+ public void TestMergeIntoSelfHasNoConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Lookup("master");
+
+ var result = repo.ObjectDatabase.CanMergeWithoutConflict(master, master);
+
+ Assert.True(result);
+ }
+ }
+
+ [Fact]
+ public void TestMergeIntoOtherUnbornBranchHasNoConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
+
+ Touch(repo.Info.WorkingDirectory, "README", "Yeah!\n");
+ repo.Index.Clear();
+ repo.Stage("README");
+
+ repo.Commit("A new world, free of the burden of the history", Constants.Signature, Constants.Signature);
+
+ var master = repo.Branches["master"].Tip;
+ var branch = repo.Branches["unborn"].Tip;
+
+ Assert.True(repo.ObjectDatabase.CanMergeWithoutConflict(master, branch));
+ }
+ }
+
+ [Fact]
+ public void TestMergeIntoOtherUnbornBranchHasConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
+
+ repo.Index.Replace(repo.Lookup("conflicts"));
+
+ repo.Commit("A conflicting world, free of the burden of the history", Constants.Signature, Constants.Signature);
+
+ var master = repo.Branches["master"].Tip;
+ var branch = repo.Branches["unborn"].Tip;
+
+ Assert.False(repo.ObjectDatabase.CanMergeWithoutConflict(master, branch));
+ }
+ }
+
+ [Fact]
+ public void TestMergeIntoOtherBranchHasNoConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Lookup("master");
+ var branch = repo.Lookup("fast_forward");
+
+ var result = repo.ObjectDatabase.CanMergeWithoutConflict(master, branch);
+
+ Assert.True(result);
+ }
+ }
+
+ [Fact]
+ public void TestMergeIntoWrongBranchHasConflicts()
+ {
+ string path = SandboxMergeTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var master = repo.Lookup("master");
+ var branch = repo.Lookup("conflicts");
+
+ var result = repo.ObjectDatabase.CanMergeWithoutConflict(master, branch);
+
+ Assert.False(result);
+ }
+ }
+
private static Blob CreateBlob(Repository repo, string content)
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content)))
diff --git a/LibGit2Sharp.Tests/PackBuilderFixture.cs b/LibGit2Sharp.Tests/PackBuilderFixture.cs
new file mode 100644
index 000000000..3d0071df0
--- /dev/null
+++ b/LibGit2Sharp.Tests/PackBuilderFixture.cs
@@ -0,0 +1,192 @@
+using System;
+using System.IO;
+using System.Linq;
+using LibGit2Sharp.Tests.TestHelpers;
+using Xunit;
+
+namespace LibGit2Sharp.Tests
+{
+ public class PackBuilderFixture : BaseFixture
+ {
+ [Fact]
+ public void TestDefaultPackDelegate()
+ {
+ TestIfSameRepoAfterPacking(null);
+ }
+
+ [Fact]
+ public void TestCommitsPerBranchPackDelegate()
+ {
+ TestIfSameRepoAfterPacking(AddingObjectIdsTestDelegate);
+ }
+
+ [Fact]
+ public void TestCommitsPerBranchIdsPackDelegate()
+ {
+ TestIfSameRepoAfterPacking(AddingObjectsTestDelegate);
+ }
+
+ internal void TestIfSameRepoAfterPacking(Action packDelegate)
+ {
+ // read a repo
+ // pack with the provided action
+ // write the pack file in a mirror repo
+ // read new repo
+ // compare
+
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+ string mrrRepoPath = SandboxPackBuilderTestRepo();
+ string mrrRepoPackDirPath = Path.Combine(mrrRepoPath + "/.git/objects");
+
+ DirectoryHelper.DeleteDirectory(mrrRepoPackDirPath);
+ Directory.CreateDirectory(mrrRepoPackDirPath + "/pack");
+
+ PackBuilderOptions packBuilderOptions = new PackBuilderOptions(mrrRepoPackDirPath + "/pack");
+
+ using (Repository orgRepo = new Repository(orgRepoPath))
+ {
+ PackBuilderResults results;
+ if (packDelegate != null)
+ results = orgRepo.ObjectDatabase.Pack(packBuilderOptions, b => packDelegate(orgRepo, b));
+ else
+ results = orgRepo.ObjectDatabase.Pack(packBuilderOptions);
+
+ // written objects count is the same as in objects database
+ Assert.Equal(orgRepo.ObjectDatabase.Count(), results.WrittenObjectsCount);
+
+ // loading a repo from the written pack file.
+ using (Repository mrrRepo = new Repository(mrrRepoPath))
+ {
+ // make sure the objects of the original repo are the same as the ones in the mirror repo
+ // doing that by making sure the count is the same, and the set difference is empty
+ Assert.True(mrrRepo.ObjectDatabase.Count() == orgRepo.ObjectDatabase.Count() && !mrrRepo.ObjectDatabase.Except(orgRepo.ObjectDatabase).Any());
+
+ Assert.Equal(orgRepo.Commits.Count(), mrrRepo.Commits.Count());
+ Assert.Equal(orgRepo.Branches.Count(), mrrRepo.Branches.Count());
+ Assert.Equal(orgRepo.Refs.Count(), mrrRepo.Refs.Count());
+ }
+ }
+ }
+
+ internal void AddingObjectIdsTestDelegate(IRepository repo, PackBuilder builder)
+ {
+ foreach (Branch branch in repo.Branches)
+ {
+ foreach (Commit commit in branch.Commits)
+ {
+ builder.AddRecursively(commit.Id);
+ }
+ }
+
+ foreach (Tag tag in repo.Tags)
+ {
+ builder.Add(tag.Target.Id);
+ }
+ }
+
+ internal void AddingObjectsTestDelegate(IRepository repo, PackBuilder builder)
+ {
+ foreach (Branch branch in repo.Branches)
+ {
+ foreach (Commit commit in branch.Commits)
+ {
+ builder.AddRecursively(commit);
+ }
+ }
+
+ foreach (Tag tag in repo.Tags)
+ {
+ builder.Add(tag.Target);
+ }
+ }
+
+ [Fact]
+ public void ExceptionIfPathDoesNotExist()
+ {
+ Assert.Throws(() => new PackBuilderOptions("aaa"));
+ }
+
+ [Fact]
+ public void ExceptionIfPathEqualsNull()
+ {
+ Assert.Throws(() => new PackBuilderOptions(null));
+ }
+
+ [Fact]
+ public void ExceptionIfOptionsEqualsNull()
+ {
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+
+ using (Repository orgRepo = new Repository(orgRepoPath))
+ {
+ Assert.Throws(() =>
+ {
+ orgRepo.ObjectDatabase.Pack(null);
+ });
+ }
+ }
+
+ [Fact]
+ public void ExceptionIfBuildDelegateEqualsNull()
+ {
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+ PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath);
+
+ using (Repository orgRepo = new Repository(orgRepoPath))
+ {
+ Assert.Throws(() =>
+ {
+ orgRepo.ObjectDatabase.Pack(packBuilderOptions, null);
+ });
+ }
+ }
+
+ [Fact]
+ public void ExceptionIfNegativeNumberOfThreads()
+ {
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+ PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath);
+
+ Assert.Throws(() =>
+ {
+ packBuilderOptions.MaximumNumberOfThreads = -1;
+ });
+ }
+
+ [Fact]
+ public void ExceptionIfAddNullObjectID()
+ {
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+ PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath);
+
+ using (Repository orgRepo = new Repository(orgRepoPath))
+ {
+ Assert.Throws(() =>
+ {
+ orgRepo.ObjectDatabase.Pack(packBuilderOptions, builder =>
+ {
+ builder.Add(null);
+ });
+ });
+ }
+ }
+
+ [Fact]
+ public void ExceptionIfAddRecursivelyNullObjectID()
+ {
+ string orgRepoPath = SandboxPackBuilderTestRepo();
+ PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath);
+
+ using (Repository orgRepo = new Repository(orgRepoPath))
+ {
+ Assert.Throws(() =>
+ {
+ orgRepo.ObjectDatabase.Pack(packBuilderOptions, builder =>
+ {
+ builder.AddRecursively(null);
+ });
+ });
+ }
+ }
+ }
+}
diff --git a/LibGit2Sharp.Tests/PushFixture.cs b/LibGit2Sharp.Tests/PushFixture.cs
index f0e950465..7dde5efd6 100644
--- a/LibGit2Sharp.Tests/PushFixture.cs
+++ b/LibGit2Sharp.Tests/PushFixture.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
+using LibGit2Sharp.Handlers;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
@@ -62,7 +64,7 @@ private void AssertPush(Action push)
public void CanPushABranchTrackingAnUpstreamBranch()
{
bool packBuilderCalled = false;
- Handlers.PackBuilderProgressHandler packBuilderCb = (x, y, z) => { packBuilderCalled = true; return true; };
+ PackBuilderProgressHandler packBuilderCb = (x, y, z) => { packBuilderCalled = true; return true; };
AssertPush(repo => repo.Network.Push(repo.Head));
AssertPush(repo => repo.Network.Push(repo.Branches["master"]));
@@ -77,6 +79,63 @@ public void CanPushABranchTrackingAnUpstreamBranch()
Assert.True(packBuilderCalled);
}
+ [Fact]
+ public void CanInvokePrePushCallbackAndSucceed()
+ {
+ bool packBuilderCalled = false;
+ bool prePushHandlerCalled = false;
+ PackBuilderProgressHandler packBuilderCb = (x, y, z) => { packBuilderCalled = true; return true; };
+ PrePushHandler prePushHook = (IEnumerable updates) =>
+ {
+ Assert.True(updates.Count() == 1, "Expected 1 update, received " + updates.Count());
+ prePushHandlerCalled = true;
+ return true;
+ };
+
+ AssertPush(repo => repo.Network.Push(repo.Head));
+ AssertPush(repo => repo.Network.Push(repo.Branches["master"]));
+
+ PushOptions options = new PushOptions()
+ {
+ OnPushStatusError = OnPushStatusError,
+ OnPackBuilderProgress = packBuilderCb,
+ OnNegotiationCompletedBeforePush = prePushHook,
+ };
+
+ AssertPush(repo => repo.Network.Push(repo.Network.Remotes["origin"], "HEAD", @"refs/heads/master", options));
+ Assert.True(packBuilderCalled);
+ Assert.True(prePushHandlerCalled);
+ }
+
+ [Fact]
+ public void CanInvokePrePushCallbackAndFail()
+ {
+ bool packBuilderCalled = false;
+ bool prePushHandlerCalled = false;
+ PackBuilderProgressHandler packBuilderCb = (x, y, z) => { packBuilderCalled = true; return true; };
+ PrePushHandler prePushHook = (IEnumerable updates) =>
+ {
+ Assert.True(updates.Count() == 1, "Expected 1 update, received " + updates.Count());
+ prePushHandlerCalled = true;
+ return false;
+ };
+
+ AssertPush(repo => repo.Network.Push(repo.Head));
+ AssertPush(repo => repo.Network.Push(repo.Branches["master"]));
+
+ PushOptions options = new PushOptions()
+ {
+ OnPushStatusError = OnPushStatusError,
+ OnPackBuilderProgress = packBuilderCb,
+ OnNegotiationCompletedBeforePush = prePushHook
+ };
+
+ Assert.Throws(() => { AssertPush(repo => repo.Network.Push(repo.Network.Remotes["origin"], "HEAD", @"refs/heads/master", options)); });
+
+ Assert.False(packBuilderCalled);
+ Assert.True(prePushHandlerCalled);
+ }
+
[Fact]
public void PushingABranchThatDoesNotTrackAnUpstreamBranchThrows()
{
@@ -97,7 +156,7 @@ public void CanForcePush()
// Create a new repository
string localRepoPath = InitNewRepository();
- using (var localRepo = new Repository(localRepoPath))
+ using (var localRepo = new Repository(localRepoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
// Add a commit
Commit first = AddCommitToRepo(localRepo);
@@ -123,22 +182,26 @@ public void CanForcePush()
// Force push the new commit
string pushRefSpec = string.Format("+{0}:{0}", localRepo.Head.CanonicalName);
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
localRepo.Network.Push(localRepo.Network.Remotes.Single(), pushRefSpec);
AssertRemoteHeadTipEquals(localRepo, second.Sha);
AssertRefLogEntry(localRepo, "refs/remotes/origin/master",
- localRepo.Head.Tip.Id, "update by push",
- oldId);
+ "update by push",
+ oldId, localRepo.Head.Tip.Id,
+ Constants.Identity, before);
}
}
private static void AssertRemoteHeadTipEquals(IRepository localRepo, string sha)
{
var remoteReferences = localRepo.Network.ListReferences(localRepo.Network.Remotes.Single());
- DirectReference remoteHead = remoteReferences.Single(r => r.CanonicalName == "HEAD");
+ Reference remoteHead = remoteReferences.Single(r => r.CanonicalName == "HEAD");
- Assert.Equal(sha, remoteHead.TargetIdentifier);
+ Assert.Equal(sha, remoteHead.ResolveToDirectReference().TargetIdentifier);
}
private void UpdateTheRemoteRepositoryWithANewCommit(string remoteRepoPath)
diff --git a/LibGit2Sharp.Tests/RebaseFixture.cs b/LibGit2Sharp.Tests/RebaseFixture.cs
new file mode 100644
index 000000000..d70851bdc
--- /dev/null
+++ b/LibGit2Sharp.Tests/RebaseFixture.cs
@@ -0,0 +1,784 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using LibGit2Sharp.Tests.TestHelpers;
+using Xunit;
+using Xunit.Extensions;
+
+namespace LibGit2Sharp.Tests
+{
+ public class RebaseFixture : BaseFixture
+ {
+ const string masterBranch1Name = "M1";
+ const string masterBranch2Name = "M2";
+ const string topicBranch1Name = "T1";
+ const string topicBranch2Name = "T2";
+ const string conflictBranch1Name = "C1";
+ const string topicBranch1PrimeName = "T1Prime";
+
+ string filePathA = "a.txt";
+ string filePathB = "b.txt";
+ string filePathC = "c.txt";
+ string filePathD = "d.txt";
+
+ [Theory]
+ [InlineData(topicBranch2Name, topicBranch2Name, topicBranch1Name, masterBranch1Name, 3)]
+ [InlineData(topicBranch2Name, topicBranch2Name, topicBranch1Name, topicBranch1Name, 3)]
+ [InlineData(topicBranch2Name, topicBranch1Name, masterBranch2Name, masterBranch2Name, 3)]
+ [InlineData(topicBranch2Name, topicBranch1Name, masterBranch2Name, null, 3)]
+ [InlineData(topicBranch1Name, null, masterBranch2Name, null, 3)]
+ public void CanRebase(string initialBranchName,
+ string branchName,
+ string upstreamName,
+ string ontoName,
+ int stepCount)
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(initialBranchName);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = (branchName == null) ? null : repo.Branches[branchName];
+ Branch upstream = repo.Branches[upstreamName];
+ Branch onto = (ontoName == null) ? null : repo.Branches[ontoName];
+ Commit expectedSinceCommit = (branch == null) ? repo.Head.Tip : branch.Tip;
+ Commit expectedUntilCommit = upstream.Tip;
+ Commit expectedOntoCommit = (onto == null) ? upstream.Tip : onto.Tip;
+
+ int beforeStepCallCount = 0;
+ int afterStepCallCount = 0;
+ bool beforeRebaseStepCountCorrect = true;
+ bool afterRebaseStepCountCorrect = true;
+ bool totalStepCountCorrect = true;
+
+ List PreRebaseCommits = new List();
+ List PostRebaseResults = new List();
+ ObjectId expectedParentId = upstream.Tip.Id;
+
+ RebaseOptions options = new RebaseOptions()
+ {
+ RebaseStepStarting = x =>
+ {
+ beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
+ totalStepCountCorrect &= (x.TotalStepCount == stepCount);
+ beforeStepCallCount++;
+ PreRebaseCommits.Add(x.StepInfo.Commit);
+ },
+ RebaseStepCompleted = x =>
+ {
+ afterRebaseStepCountCorrect &= (afterStepCallCount == x.CompletedStepIndex);
+ totalStepCountCorrect &= (x.TotalStepCount == stepCount);
+ afterStepCallCount++;
+ PostRebaseResults.Add(new CompletedRebaseStepInfo(x.Commit, x.WasPatchAlreadyApplied));
+ },
+ };
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
+
+ // Validation:
+ Assert.True(afterRebaseStepCountCorrect, "Unexpected CompletedStepIndex value in RebaseStepCompleted");
+ Assert.True(beforeRebaseStepCountCorrect, "Unexpected StepIndex value in RebaseStepStarting");
+ Assert.True(totalStepCountCorrect, "Unexpected TotalStepcount value in Rebase step callback");
+ Assert.Equal(RebaseStatus.Complete, rebaseResult.Status);
+ Assert.Equal(stepCount, rebaseResult.TotalStepCount);
+ Assert.Null(rebaseResult.CurrentStepInfo);
+
+ Assert.Equal(stepCount, rebaseResult.CompletedStepCount);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Assert.Equal(stepCount, beforeStepCallCount);
+ Assert.Equal(stepCount, afterStepCallCount);
+
+ // Verify the chain of source commits that were rebased.
+ CommitFilter sourceCommitFilter = new CommitFilter()
+ {
+ IncludeReachableFrom = expectedSinceCommit,
+ ExcludeReachableFrom = expectedUntilCommit,
+ SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological,
+ };
+ Assert.Equal(repo.Commits.QueryBy(sourceCommitFilter), PreRebaseCommits);
+
+ // Verify the chain of commits that resulted from the rebase.
+ Commit expectedParent = expectedOntoCommit;
+ foreach (CompletedRebaseStepInfo stepInfo in PostRebaseResults)
+ {
+ Commit rebasedCommit = stepInfo.Commit;
+ Assert.Equal(expectedParent.Id, rebasedCommit.Parents.First().Id);
+ Assert.False(stepInfo.WasPatchAlreadyApplied);
+ expectedParent = rebasedCommit;
+ }
+
+ Assert.Equal(repo.Head.Tip, PostRebaseResults.Last().Commit);
+ }
+ }
+
+ [Fact]
+ public void CanRebaseBranchOntoItself()
+ {
+ // Maybe we should have an "up-to-date" return type for scenarios such as these,
+ // but for now this test is to make sure we do something reasonable
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+ repo.Checkout(topicBranch2Name);
+ Branch b = repo.Branches[topicBranch2Name];
+
+ RebaseResult result = repo.Rebase.Start(b, b, null, Constants.Identity, new RebaseOptions());
+ Assert.Equal(0, result.TotalStepCount);
+ Assert.Equal(RebaseStatus.Complete, result.Status);
+ Assert.Equal(0, result.CompletedStepCount);
+ }
+ }
+
+ private class CompletedRebaseStepInfo
+ {
+ public CompletedRebaseStepInfo(Commit commit, bool wasPatchAlreadyApplied)
+ {
+ Commit = commit;
+ WasPatchAlreadyApplied = wasPatchAlreadyApplied;
+ }
+
+ public Commit Commit { get; set; }
+
+ public bool WasPatchAlreadyApplied { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("CompletedRebaseStepInfo: {0}", Commit);
+ }
+ }
+
+ private class CompletedRebaseStepInfoEqualityComparer : IEqualityComparer
+ {
+ bool IEqualityComparer.Equals(CompletedRebaseStepInfo x, CompletedRebaseStepInfo y)
+ {
+ if (x == null && y == null)
+ {
+ return true;
+ }
+
+ if ((x == null && y != null) ||
+ (x != null && y == null))
+ {
+ return false;
+ }
+
+ return x.WasPatchAlreadyApplied == y.WasPatchAlreadyApplied &&
+ ObjectId.Equals(x.Commit, y.Commit);
+ }
+
+ int IEqualityComparer.GetHashCode(CompletedRebaseStepInfo obj)
+ {
+ int hashCode = obj.WasPatchAlreadyApplied.GetHashCode();
+
+ if (obj.Commit != null)
+ {
+ hashCode += obj.Commit.GetHashCode();
+ }
+
+ return hashCode;
+ }
+ }
+
+ ///
+ /// Verify a single rebase, but in more detail.
+ ///
+ [Theory]
+ [InlineData("* text=auto", "\r\n", new[] { "2cad6e96a0028f1764dcbde6292a9a1471acb114", "18fd3deebe6124b5dacc8426d589d617a968e8d1", "048977d8cb90d530e83cc615a17a49f3068f68c1" })]
+ [InlineData("* text=auto", "\n", new[] { "2cad6e96a0028f1764dcbde6292a9a1471acb114", "18fd3deebe6124b5dacc8426d589d617a968e8d1", "048977d8cb90d530e83cc615a17a49f3068f68c1" })]
+ [InlineData("* text=auto\n*.txt eol=lf", "\n", new[] { "577d176b00a55e88e9b34da87e4357dfc9a486fd", "ea0ad4d8b500394a61874ebfda5904376e2b1098", "521b8383ca3fde9e369587492e7a3945677f1b2c" })]
+ [InlineData("* text=auto\r\n*.txt eol=crlf", "\r\n", new[] { "67d29fdf654ac4773c9405ab4b54aa7ff092f339", "7b70c02e175d378b44ea28aeeece775cd972047a", "81f203dbfe00a5c1ecd9c0e6b03705e6cffda5c0" })]
+ [InlineData("* binary", "\r\n", new[] { "f5a5ded935597108709224170accddc5aeb5c287", "518adb8bb1ea1058d1825d3fe08d27f80c0e829b", "d2db503ab553c970d34e1b5e3ff68768adef05bc" })]
+ [InlineData("* binary", "\n", new[] { "93a0e9680246d1f1e43fbd5308f7936424d9e81a", "5fd40bffbdd884632c330a254a2bd1dfaaaad3c1", "4df5c91b2d8318781b07d04f6bfa77304c372f1e" })]
+ public void VerifyRebaseDetailed(string attributes, string lineEnding, string[] expectedIds)
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo, attributes, lineEnding);
+
+ Branch initialBranch = repo.Branches[topicBranch1Name];
+ Branch upstreamBranch = repo.Branches[masterBranch2Name];
+
+ repo.Checkout(initialBranch);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ bool wasCheckoutProgressCalled = false;
+ bool wasCheckoutProgressCalledForResetingHead = false;
+ bool wasCheckoutNotifyCalled = false;
+ bool wasCheckoutNotifyCalledForResetingHead = false;
+
+ bool startedApplyingSteps = false;
+
+ RebaseOptions options = new RebaseOptions()
+ {
+ OnCheckoutProgress = (x, y, z) =>
+ {
+ if (startedApplyingSteps)
+ {
+ wasCheckoutProgressCalled = true;
+ }
+ else
+ {
+ wasCheckoutProgressCalledForResetingHead = true;
+ }
+ },
+ OnCheckoutNotify = (x, y) =>
+ {
+ if (startedApplyingSteps)
+ {
+ wasCheckoutNotifyCalled = true;
+ }
+ else
+ {
+ wasCheckoutNotifyCalledForResetingHead = true;
+ }
+
+ return true;
+ },
+ CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
+
+ RebaseStepStarting = x => startedApplyingSteps = true,
+
+ };
+
+ repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
+
+ Assert.Equal(true, wasCheckoutNotifyCalledForResetingHead);
+ Assert.Equal(true, wasCheckoutProgressCalledForResetingHead);
+ Assert.Equal(true, wasCheckoutNotifyCalled);
+ Assert.Equal(true, wasCheckoutProgressCalled);
+
+ // Verify the chain of resultant rebased commits.
+ CommitFilter commitFilter = new CommitFilter()
+ {
+ IncludeReachableFrom = repo.Head.Tip,
+ ExcludeReachableFrom = upstreamBranch.Tip,
+ SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological,
+ };
+
+ List expectedTreeIds = new List()
+ {
+ new ObjectId(expectedIds[0]),
+ new ObjectId(expectedIds[1]),
+ new ObjectId(expectedIds[2]),
+ };
+
+ List rebasedCommits = repo.Commits.QueryBy(commitFilter).ToList();
+
+ Assert.Equal(3, rebasedCommits.Count);
+ for(int i = 0; i < 3; i++)
+ {
+ Assert.Equal(expectedTreeIds[i], rebasedCommits[i].Tree.Id);
+ Assert.Equal(Constants.Signature.Name, rebasedCommits[i].Author.Name);
+ Assert.Equal(Constants.Signature.Email, rebasedCommits[i].Author.Email);
+ Assert.Equal(Constants.Signature2.Name, rebasedCommits[i].Committer.Name);
+ Assert.Equal(Constants.Signature2.Email, rebasedCommits[i].Committer.Email);
+ }
+ }
+ }
+
+ [Fact]
+ public void CanContinueRebase()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ int beforeStepCallCount = 0;
+ int afterStepCallCount = 0;
+ bool wasCheckoutProgressCalled = false;
+ bool wasCheckoutNotifyCalled = false;
+
+ RebaseOptions options = new RebaseOptions()
+ {
+ RebaseStepStarting = x => beforeStepCallCount++,
+ RebaseStepCompleted = x => afterStepCallCount++,
+ OnCheckoutProgress = (x, y, z) => wasCheckoutProgressCalled = true,
+ OnCheckoutNotify = (x, y) => { wasCheckoutNotifyCalled = true; return true; },
+ CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
+ };
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
+
+ // Verify that we have a conflict.
+ Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.False(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ // Verify that expected callbacks were called
+ Assert.Equal(1, beforeStepCallCount);
+ Assert.Equal(0, afterStepCallCount);
+ Assert.True(wasCheckoutProgressCalled, "CheckoutProgress callback was not called.");
+
+ // Resolve the conflict
+ foreach (Conflict conflict in repo.Index.Conflicts)
+ {
+ Touch(repo.Info.WorkingDirectory,
+ conflict.Theirs.Path,
+ repo.Lookup(conflict.Theirs.Id).GetContentText(new FilteringOptions(conflict.Theirs.Path)));
+ repo.Stage(conflict.Theirs.Path);
+ }
+
+ Assert.True(repo.Index.IsFullyMerged);
+
+ // Clear the flags:
+ wasCheckoutProgressCalled = false; wasCheckoutNotifyCalled = false;
+ RebaseResult continuedRebaseResult = repo.Rebase.Continue(Constants.Identity, options);
+
+ Assert.NotNull(continuedRebaseResult);
+ Assert.Equal(RebaseStatus.Complete, continuedRebaseResult.Status);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+ Assert.True(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ Assert.Equal(3, beforeStepCallCount);
+ Assert.Equal(3, afterStepCallCount);
+ Assert.True(wasCheckoutProgressCalled, "CheckoutProgress callback was not called.");
+ Assert.True(wasCheckoutNotifyCalled, "CheckoutNotify callback was not called.");
+ }
+ }
+
+ [Fact]
+ public void ContinuingRebaseWithUnstagedChangesThrows()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
+
+ // Verify that we have a conflict.
+ Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.False(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ Assert.Throws(() =>
+ repo.Rebase.Continue(Constants.Identity, null));
+
+ // Resolve the conflict
+ foreach (Conflict conflict in repo.Index.Conflicts)
+ {
+ Touch(repo.Info.WorkingDirectory,
+ conflict.Theirs.Path,
+ repo.Lookup(conflict.Theirs.Id).GetContentText(new FilteringOptions(conflict.Theirs.Path)));
+ repo.Stage(conflict.Theirs.Path);
+ }
+
+ Touch(repo.Info.WorkingDirectory,
+ filePathA,
+ "Unstaged content");
+
+ Assert.Throws(() =>
+ repo.Rebase.Continue(Constants.Identity, null));
+
+ Assert.True(repo.Index.IsFullyMerged);
+ }
+ }
+
+ [Fact]
+ public void CanSpecifyFileConflictStrategy()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ RebaseOptions options = new RebaseOptions()
+ {
+ FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
+ };
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
+
+ // Verify that we have a conflict.
+ Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.False(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ string conflictFile = filePathB;
+ // Get the information on the conflict.
+ Conflict conflict = repo.Index.Conflicts[conflictFile];
+
+ Assert.NotNull(conflict);
+ Assert.NotNull(conflict.Theirs);
+ Assert.NotNull(conflict.Ours);
+
+ Blob expectedBlob = repo.Lookup(conflict.Ours.Id);
+
+ // Check the content of the file on disk matches what is expected.
+ string expectedContent = expectedBlob.GetContentText(new FilteringOptions(conflictFile));
+ Assert.Equal(expectedContent, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, conflictFile)));
+ }
+ }
+
+ [Fact]
+ public void CanQueryRebaseOperation()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
+
+ // Verify that we have a conflict.
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.False(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ RebaseStepInfo info = repo.Rebase.GetCurrentStepInfo();
+
+ Assert.Equal(0, repo.Rebase.GetCurrentStepIndex());
+ Assert.Equal(3, repo.Rebase.GetTotalStepCount());
+ Assert.Equal(RebaseStepOperation.Pick, info.Type);
+ }
+ }
+
+ [Fact]
+ public void CanAbortRebase()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
+
+ // Verify that we have a conflict.
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.False(repo.Index.IsFullyMerged);
+ Assert.Equal(0, rebaseResult.CompletedStepCount);
+ Assert.Equal(3, rebaseResult.TotalStepCount);
+
+ // Set up the callbacks to verify that checkout progress / notify
+ // callbacks are called.
+ bool wasCheckoutProgressCalled = false;
+ bool wasCheckoutNotifyCalled = false;
+ RebaseOptions options = new RebaseOptions()
+ {
+ OnCheckoutProgress = (x, y, z) => wasCheckoutProgressCalled = true,
+ OnCheckoutNotify = (x, y) => { wasCheckoutNotifyCalled = true; return true; },
+ CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
+ };
+
+ repo.Rebase.Abort(options);
+ Assert.False(repo.RetrieveStatus().IsDirty, "Repository workdir is dirty after Rebase.Abort.");
+ Assert.True(repo.Index.IsFullyMerged, "Repository index is not fully merged after Rebase.Abort.");
+ Assert.Equal(CurrentOperation.None, repo.Info.CurrentOperation);
+
+ Assert.True(wasCheckoutProgressCalled, "Checkout progress callback was not called during Rebase.Abort.");
+ Assert.True(wasCheckoutNotifyCalled, "Checkout notify callback was not called during Rebase.Abort.");
+ }
+ }
+
+ [Fact]
+ public void RebaseWhileAlreadyRebasingThrows()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+ Assert.False(repo.RetrieveStatus().IsDirty);
+
+ Branch branch = repo.Branches[topicBranch1Name];
+ Branch upstream = repo.Branches[conflictBranch1Name];
+ Branch onto = repo.Branches[conflictBranch1Name];
+
+ RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
+
+ // Verify that we have a conflict.
+ Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
+ Assert.True(repo.RetrieveStatus().IsDirty);
+ Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
+
+ Assert.Throws(() =>
+ repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null));
+ }
+ }
+
+ [Fact]
+ public void RebaseOperationsWithoutRebasingThrow()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+
+ repo.Checkout(topicBranch1Name);
+
+ Assert.Throws(() =>
+ repo.Rebase.Continue(Constants.Identity, new RebaseOptions()));
+
+ Assert.Throws(() =>
+ repo.Rebase.Abort());
+ }
+ }
+
+ [Fact]
+ public void CurrentStepInfoIsNullWhenNotRebasing()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo);
+ repo.Checkout(topicBranch1Name);
+
+ Assert.Null(repo.Rebase.GetCurrentStepInfo());
+ }
+ }
+
+ [Theory]
+ [InlineData("* text=auto", "\r\n", "379e80ed7824be7672e1e30ddd8f44aa081d57d4")]
+ [InlineData("* text=auto", "\n", "379e80ed7824be7672e1e30ddd8f44aa081d57d4")]
+ [InlineData("* text=auto\n*.txt eol=lf", "\n", "94121eeebf7cfe0acf22425eab36fcdc737132b6")]
+ [InlineData("* text=auto\r\n*.txt eol=crlf", "\r\n", "dad06142cc632aea81cbc8486583011c4d622580")]
+ [InlineData("* binary", "\r\n", "44492d98b725189cfc0203d4192dfbb1fd34bf02")]
+ [InlineData("* binary", "\n", "f4b5b95de77f4cd97b4728617bae2dd8ba9af914")]
+ public void CanRebaseHandlePatchAlreadyApplied(string attributes, string lineEnding, string expectedShaText)
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+ var path = Repository.Init(scd.DirectoryPath);
+ using (Repository repo = new Repository(path))
+ {
+ ConstructRebaseTestRepository(repo, attributes, lineEnding);
+
+ repo.Checkout(topicBranch1Name);
+
+ Branch topicBranch1Prime = repo.CreateBranch(topicBranch1PrimeName, masterBranch1Name);
+
+ string newFileRelativePath = "new_file.txt";
+ Touch(repo.Info.WorkingDirectory, newFileRelativePath, "New Content");
+ repo.Stage(newFileRelativePath);
+ Commit commit = repo.Commit("new commit 1", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ repo.Checkout(topicBranch1Prime);
+ var cherryPickResult = repo.CherryPick(commit, Constants.Signature2);
+ Assert.Equal(CherryPickStatus.CherryPicked, cherryPickResult.Status);
+
+ string newFileRelativePath2 = "new_file_2.txt";
+ Touch(repo.Info.WorkingDirectory, newFileRelativePath2, "New Content for path 2");
+ repo.Stage(newFileRelativePath2);
+ repo.Commit("new commit 2", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Branch upstreamBranch = repo.Branches[topicBranch1Name];
+
+ List rebaseResults = new List();
+
+ RebaseOptions options = new RebaseOptions()
+ {
+ RebaseStepCompleted = x =>
+ {
+ rebaseResults.Add(new CompletedRebaseStepInfo(x.Commit, x.WasPatchAlreadyApplied));
+ }
+ };
+
+ repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
+ ObjectId secondCommitExpectedTreeId = new ObjectId(expectedShaText);
+ Signature secondCommitAuthorSignature = Constants.Signature;
+ Identity secondCommitCommiterIdentity = Constants.Identity2;
+
+ Assert.Equal(2, rebaseResults.Count);
+ Assert.True(rebaseResults[0].WasPatchAlreadyApplied);
+
+ Assert.False(rebaseResults[1].WasPatchAlreadyApplied);
+ Assert.NotNull(rebaseResults[1].Commit);
+
+ // This is the expected tree ID of the new commit.
+ Assert.Equal(secondCommitExpectedTreeId, rebaseResults[1].Commit.Tree.Id);
+ Assert.True(Signature.Equals(secondCommitAuthorSignature, rebaseResults[1].Commit.Author));
+ Assert.Equal(secondCommitCommiterIdentity.Name, rebaseResults[1].Commit.Committer.Name, StringComparer.Ordinal);
+ Assert.Equal(secondCommitCommiterIdentity.Email, rebaseResults[1].Commit.Committer.Email, StringComparer.Ordinal);
+ }
+ }
+
+ [Fact]
+ public void RebasingInBareRepositoryThrows()
+ {
+ string path = SandboxBareTestRepo();
+ using (var repo = new Repository(path))
+ {
+ Branch rebaseUpstreamBranch = repo.Branches["refs/heads/test"];
+
+ Assert.NotNull(rebaseUpstreamBranch);
+ Assert.Throws(() => repo.Rebase.Start(null, rebaseUpstreamBranch, null, Constants.Identity, new RebaseOptions()));
+ Assert.Throws(() => repo.Rebase.Continue(Constants.Identity, new RebaseOptions()));
+ Assert.Throws(() => repo.Rebase.Abort());
+ }
+ }
+
+ private void ConstructRebaseTestRepository(Repository repo, string attributes = "* text=auto", string lineEnding = "\r\n")
+ {
+ // Constructs a graph that looks like:
+ // * -- * -- * (modifications to c.txt)
+ // / |
+ // / T2
+ // /
+ // * -- * -- * (modifications to b.txt)
+ // / |
+ // / T1
+ // /
+ // *--*--*--*--*--*----
+ // | | \
+ // M1 M2 \
+ // ---*
+ // |
+ // C1
+ const string fileContentA1 = "A1";
+
+ const string fileContentB1 = "B1";
+ const string fileContentB2 = "B2";
+ const string fileContentB3 = "B3";
+ const string fileContentB4 = "B4";
+
+ const string fileContentC1 = "C1";
+ const string fileContentC2 = "C2";
+ const string fileContentC3 = "C3";
+ const string fileContentC4 = "C4";
+
+ const string fileContentD1 = "D1";
+ const string fileContentD2 = "D2";
+ const string fileContentD3 = "D3";
+
+ string workdir = repo.Info.WorkingDirectory;
+ Commit commit = null;
+
+ CreateAttributesFile(repo, attributes);
+
+ repo.Stage(".gitattributes");
+ commit = repo.Commit("setup", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathA, fileContentA1);
+ repo.Stage(filePathA);
+ commit = repo.Commit("commit 1", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathB, fileContentB1);
+ repo.Stage(filePathB);
+ commit = repo.Commit("commit 2", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathC, fileContentC1);
+ repo.Stage(filePathC);
+ commit = repo.Commit("commit 3", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Branch masterBranch1 = repo.CreateBranch(masterBranch1Name, commit);
+
+ Touch(workdir, filePathB, string.Join(lineEnding, fileContentB1, fileContentB2));
+ repo.Stage(filePathB);
+ commit = repo.Commit("commit 4", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathB, string.Join(lineEnding, fileContentB1, fileContentB2, fileContentB3));
+ repo.Stage(filePathB);
+ commit = repo.Commit("commit 5", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathB, string.Join(lineEnding, fileContentB1, fileContentB2, fileContentB3, fileContentB4));
+ repo.Stage(filePathB);
+ commit = repo.Commit("commit 6", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ repo.CreateBranch(topicBranch1Name, commit);
+
+ Touch(workdir, filePathC, string.Join(lineEnding, fileContentC1, fileContentC2));
+ repo.Stage(filePathC);
+ commit = repo.Commit("commit 7", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathC, string.Join(lineEnding, fileContentC1, fileContentC2, fileContentC3));
+ repo.Stage(filePathC);
+ commit = repo.Commit("commit 8", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathC, string.Join(lineEnding, fileContentC1, fileContentC2, fileContentC3, fileContentC4));
+ repo.Stage(filePathC);
+ commit = repo.Commit("commit 9", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ repo.CreateBranch(topicBranch2Name, commit);
+
+ repo.Checkout(masterBranch1.Tip);
+ Touch(workdir, filePathD, fileContentD1);
+ repo.Stage(filePathD);
+ commit = repo.Commit("commit 10", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathD, string.Join(lineEnding, fileContentD1, fileContentD2));
+ repo.Stage(filePathD);
+ commit = repo.Commit("commit 11", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ Touch(workdir, filePathD, string.Join(lineEnding, fileContentD1, fileContentD2, fileContentD3));
+ repo.Stage(filePathD);
+ commit = repo.Commit("commit 12", Constants.Signature, Constants.Signature, new CommitOptions());
+
+ repo.CreateBranch(masterBranch2Name, commit);
+
+ // Create commit / branch that conflicts with T1 and T2
+ Touch(workdir, filePathB, string.Join(lineEnding, fileContentB1, fileContentB2 + fileContentB3 + fileContentB4));
+ repo.Stage(filePathB);
+ commit = repo.Commit("commit 13", Constants.Signature, Constants.Signature, new CommitOptions());
+ repo.CreateBranch(conflictBranch1Name, commit);
+ }
+ }
+}
diff --git a/LibGit2Sharp.Tests/RefSpecFixture.cs b/LibGit2Sharp.Tests/RefSpecFixture.cs
index 1473ac704..dc82a5fc3 100644
--- a/LibGit2Sharp.Tests/RefSpecFixture.cs
+++ b/LibGit2Sharp.Tests/RefSpecFixture.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
@@ -184,7 +183,7 @@ public void SettingInvalidRefSpecsThrows(string refSpec)
var remote = repo.Network.Remotes["origin"];
var oldRefSpecs = remote.RefSpecs.Select(r => r.Specification).ToList();
- Assert.Throws(() =>
+ Assert.Throws(() =>
repo.Network.Remotes.Update(remote, r => r.FetchRefSpecs.Add(refSpec)));
var newRemote = repo.Network.Remotes["origin"];
diff --git a/LibGit2Sharp.Tests/ReferenceFixture.cs b/LibGit2Sharp.Tests/ReferenceFixture.cs
index 4674ecefb..ac2af3c24 100644
--- a/LibGit2Sharp.Tests/ReferenceFixture.cs
+++ b/LibGit2Sharp.Tests/ReferenceFixture.cs
@@ -22,10 +22,12 @@ public void CanAddADirectReference()
const string name = "refs/heads/unit_test";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
var newRef = (DirectReference)repo.Refs.Add(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
@@ -35,8 +37,9 @@ public void CanAddADirectReference()
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
- "branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ "branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
+ null, newRef.ResolveToDirectReference().Target.Id, Constants.Identity, before
+ );
}
}
@@ -47,11 +50,13 @@ public void CanAddADirectReferenceFromRevParseSpec()
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
- var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", Constants.Signature, logMessage);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -59,9 +64,9 @@ public void CanAddADirectReferenceFromRevParseSpec()
Assert.Equal(newRef.Target.Sha, newRef.TargetIdentifier);
Assert.NotNull(repo.Refs[name]);
- AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
- logMessage, committer: Constants.Signature);
+ AssertRefLogEntry(repo, name, logMessage,
+ null, newRef.ResolveToDirectReference().Target.Id,
+ Constants.Identity, before);
}
}
@@ -106,7 +111,7 @@ public void CanAddASymbolicReferenceFromTheTargetReference()
var targetRef = repo.Refs[target];
- var newRef = repo.Refs.Add(name, targetRef, Constants.Signature, logMessage);
+ var newRef = repo.Refs.Add(name, targetRef, logMessage);
AssertSymbolicRef(newRef, repo, target, name);
Assert.Empty(repo.Refs.Log(newRef));
@@ -151,12 +156,15 @@ public void CanAddAndOverwriteADirectReference()
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldRef = repo.Refs[name];
- var newRef = (DirectReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ var newRef = (DirectReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -164,9 +172,9 @@ public void CanAddAndOverwriteADirectReference()
Assert.Equal(target, ((DirectReference)repo.Refs[name]).Target.Sha);
AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
logMessage, ((DirectReference)oldRef).Target.Id,
- Constants.Signature);
+ newRef.ResolveToDirectReference().Target.Id,
+ Constants.Identity, before);
}
}
@@ -178,22 +186,25 @@ public void CanAddAndOverwriteASymbolicReference()
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldtarget = repo.Refs[name].ResolveToDirectReference().Target.Id;
- var newRef = (SymbolicReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ var newRef = (SymbolicReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
Assert.Equal("a4a7dce85cf63874e984719f4fdd239f5145052f", newRef.ResolveToDirectReference().Target.Sha);
Assert.Equal(target, ((SymbolicReference)repo.Refs.Head).Target.CanonicalName);
- AssertRefLogEntry(repo, name,
+ AssertRefLogEntry(repo, name, logMessage,
+ oldtarget,
newRef.ResolveToDirectReference().Target.Id,
- logMessage, oldtarget,
- Constants.Signature);
+ Constants.Identity, before);
}
}
@@ -498,36 +509,40 @@ public void CanUpdateHeadWithARevparseSpec()
public void CanUpdateHeadWithEitherAnObjectIdOrAReference()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
Reference head = repo.Refs.Head;
Reference test = repo.Refs["refs/heads/test"];
- Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), Constants.Signature, null);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), null);
Assert.True((direct is DirectReference));
Assert.Equal(test.TargetIdentifier, direct.TargetIdentifier);
Assert.Equal(repo.Refs.Head, direct);
var testTargetId = test.ResolveToDirectReference().Target.Id;
- AssertRefLogEntry(repo, "HEAD",
- testTargetId,
- null,
+ AssertRefLogEntry(repo, "HEAD", null,
head.ResolveToDirectReference().Target.Id,
- Constants.Signature);
+ testTargetId,
+ Constants.Identity, before);
const string secondLogMessage = "second update target message";
- Reference symref = repo.Refs.UpdateTarget(head, test, Constants.Signature, secondLogMessage);
+
+ before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ Reference symref = repo.Refs.UpdateTarget(head, test, secondLogMessage);
Assert.True((symref is SymbolicReference));
Assert.Equal(test.CanonicalName, symref.TargetIdentifier);
Assert.Equal(repo.Refs.Head, symref);
AssertRefLogEntry(repo, "HEAD",
- testTargetId,
secondLogMessage,
testTargetId,
- Constants.Signature);
+ testTargetId,
+ Constants.Identity, before);
}
}
@@ -535,7 +550,7 @@ public void CanUpdateHeadWithEitherAnObjectIdOrAReference()
public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -545,7 +560,10 @@ public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()
var @from = master.Target.Id;
const string logMessage = "update target message";
- var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", Constants.Signature, logMessage);
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
+ var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -554,10 +572,10 @@ public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
- newRef.Target.Id,
logMessage,
@from,
- Constants.Signature);
+ newRef.Target.Id,
+ Constants.Identity, before);
}
}
@@ -648,7 +666,7 @@ public void CanRenameAReferenceToAUpperReferenceHierarchy()
public void CanRenameAReferenceToADifferentReferenceHierarchy()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
const string oldName = "refs/tags/test";
const string newName = "refs/atic/tagtest";
@@ -657,13 +675,18 @@ public void CanRenameAReferenceToADifferentReferenceHierarchy()
var oldId = repo.Refs[oldName].ResolveToDirectReference().Target.Id;
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Reference renamed = repo.Refs.Rename(oldName, newName);
Assert.NotNull(renamed);
Assert.Equal(newName, renamed.CanonicalName);
Assert.Equal(oldId, renamed.ResolveToDirectReference().Target.Id);
- AssertRefLogEntry(repo, newName, renamed.ResolveToDirectReference().Target.Id,
- string.Format("reference: renamed {0} to {1}", oldName, newName));
+ AssertRefLogEntry(repo, newName,
+ string.Format("reference: renamed {0} to {1}", oldName, newName),
+ oldId,
+ renamed.ResolveToDirectReference().Target.Id,
+ Constants.Identity, before);
}
}
@@ -806,15 +829,15 @@ public void CanIdentifyReferenceKind()
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
- Assert.True(repo.Refs["refs/heads/master"].IsLocalBranch());
- Assert.True(repo.Refs["refs/remotes/origin/master"].IsRemoteTrackingBranch());
- Assert.True(repo.Refs["refs/tags/lw"].IsTag());
+ Assert.True(repo.Refs["refs/heads/master"].IsLocalBranch);
+ Assert.True(repo.Refs["refs/remotes/origin/master"].IsRemoteTrackingBranch);
+ Assert.True(repo.Refs["refs/tags/lw"].IsTag);
}
path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.True(repo.Refs["refs/notes/commits"].IsNote());
+ Assert.True(repo.Refs["refs/notes/commits"].IsNote);
}
}
@@ -848,7 +871,7 @@ public void CanQueryReachabilityAmongASubsetOfreferences()
using (var repo = new Repository(path))
{
var result = repo.Refs.ReachableFrom(
- repo.Refs.Where(r => r.IsTag()),
+ repo.Refs.Where(r => r.IsTag),
new[] { repo.Lookup("f8d44d7"), repo.Lookup("6dcf9bf") });
var expected = new[]
diff --git a/LibGit2Sharp.Tests/ReflogFixture.cs b/LibGit2Sharp.Tests/ReflogFixture.cs
index 9f1339893..72f9faa0f 100644
--- a/LibGit2Sharp.Tests/ReflogFixture.cs
+++ b/LibGit2Sharp.Tests/ReflogFixture.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System;
+using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
@@ -21,7 +22,7 @@ public void CanReadReflog()
Assert.Equal(expectedReflogEntriesCount, reflog.Count());
// Initial commit assertions
- Assert.Equal("timothy.clem@gmail.com", reflog.Last().Commiter.Email);
+ Assert.Equal("timothy.clem@gmail.com", reflog.Last().Committer.Email);
Assert.True(reflog.Last().Message.StartsWith("clone: from"));
Assert.Equal(ObjectId.Zero, reflog.Last().From);
@@ -56,7 +57,9 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference()
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = identity }))
{
// setup refs as HEAD => unit_test => master
var newRef = repo.Refs.Add("refs/heads/unit_test", "refs/heads/master");
@@ -69,19 +72,33 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference()
var author = Constants.Signature;
const string commitMessage = "Hope reflog behaves as it should";
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
Commit commit = repo.Commit(commitMessage, author, author);
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Commiter);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, before, now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
// Assert the same reflog entry is created on refs/heads/master
Assert.Equal(1, repo.Refs.Log("refs/heads/master").Count());
reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Commiter);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ Assert.InRange(reflogEntry.Committer.When, before, now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
@@ -116,7 +133,9 @@ public void CommitOnDetachedHeadShouldInsertReflogEntry()
{
string repoPath = SandboxStandardTestRepo();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
Assert.False(repo.Info.IsHeadDetached);
@@ -130,11 +149,20 @@ public void CommitOnDetachedHeadShouldInsertReflogEntry()
var author = Constants.Signature;
const string commitMessage = "Commit on detached head";
+
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
var commit = repo.Commit(commitMessage, author, author);
// Assert a reflog entry is created on HEAD
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Commiter);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, before, now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(string.Format("commit: {0}", commitMessage), repo.Refs.Log("HEAD").First().Message);
}
@@ -174,7 +202,7 @@ public void AppendingToReflogDependsOnCoreLogAllRefUpdatesSetting(bool isBare, b
public void UnsignedMethodsWriteCorrectlyToTheReflog()
{
var repoPath = InitNewRepository(true);
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -183,8 +211,11 @@ public void UnsignedMethodsWriteCorrectlyToTheReflog()
var commit = repo.ObjectDatabase.CreateCommit(Constants.Signature, Constants.Signature, "yoink",
tree, Enumerable.Empty(), false);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
var direct = repo.Refs.Add("refs/heads/direct", commit.Id);
- AssertRefLogEntry(repo, direct.CanonicalName, direct.ResolveToDirectReference().Target.Id, null);
+ AssertRefLogEntry(repo, direct.CanonicalName, null, null,
+ direct.ResolveToDirectReference().Target.Id, Constants.Identity, before);
var symbolic = repo.Refs.Add("refs/heads/symbolic", direct);
Assert.Empty(repo.Refs.Log(symbolic)); // creation of symbolic refs doesn't update the reflog
diff --git a/LibGit2Sharp.Tests/RemoteFixture.cs b/LibGit2Sharp.Tests/RemoteFixture.cs
index 47d51390f..8b8c81133 100644
--- a/LibGit2Sharp.Tests/RemoteFixture.cs
+++ b/LibGit2Sharp.Tests/RemoteFixture.cs
@@ -91,6 +91,35 @@ public void CanSetRemoteUrl()
r => r.Url = newUrl);
Assert.Equal(newUrl, updatedremote.Url);
+ // with no push url set, PushUrl defaults to the fetch url
+ Assert.Equal(newUrl, updatedremote.PushUrl);
+ }
+ }
+
+ [Fact]
+ public void CanSetRemotePushUrl()
+ {
+ string path = SandboxBareTestRepo();
+ using (var repo = new Repository(path))
+ {
+ const string name = "upstream";
+ const string url = "https://github.com/libgit2/libgit2sharp.git";
+ const string pushurl = "https://github.com/libgit2/libgit2.git";
+
+ repo.Network.Remotes.Add(name, url);
+ Remote remote = repo.Network.Remotes[name];
+ Assert.NotNull(remote);
+
+ // before setting push, both push and fetch urls should match
+ Assert.Equal(url, remote.Url);
+ Assert.Equal(url, remote.PushUrl);
+
+ Remote updatedremote = repo.Network.Remotes.Update(remote,
+ r => r.PushUrl = pushurl);
+
+ // url should not change, push url should be set to new value
+ Assert.Equal(url, updatedremote.Url);
+ Assert.Equal(pushurl, updatedremote.PushUrl);
}
}
@@ -334,5 +363,43 @@ public void CanNotRenameWhenRemoteWithSameNameExists()
Assert.Throws(() => repo.Network.Remotes.Rename("origin", "upstream"));
}
}
+
+ [Theory]
+ [InlineData(null, null, false)]
+ [InlineData(null, false, false)]
+ [InlineData(null, true, true)]
+ [InlineData(false, null, false)]
+ [InlineData(false, false, false)]
+ [InlineData(false, true, true)]
+ [InlineData(true, null, true)]
+ [InlineData(true, false, false)]
+ [InlineData(true, true, true)]
+ public void ShoudlPruneOnFetchReflectsTheConfiguredSetting(bool? fetchPrune, bool? remotePrune, bool expectedFetchPrune)
+ {
+ var path = SandboxStandardTestRepo();
+ var scd = BuildSelfCleaningDirectory();
+
+ using (var repo = new Repository(path, BuildFakeConfigs(scd)))
+ {
+ Assert.Null(repo.Config.Get("fetch.prune"));
+ Assert.Null(repo.Config.Get("remote.origin.prune"));
+
+ SetIfNotNull(repo, "fetch.prune", fetchPrune);
+ SetIfNotNull(repo, "remote.origin.prune", remotePrune);
+
+ var remote = repo.Network.Remotes["origin"];
+ Assert.Equal(expectedFetchPrune, remote.AutomaticallyPruneOnFetch);
+ }
+ }
+
+ private void SetIfNotNull(IRepository repo, string configName, bool? value)
+ {
+ if (!value.HasValue)
+ {
+ return;
+ }
+
+ repo.Config.Set(configName, value.Value);
+ }
}
}
diff --git a/LibGit2Sharp.Tests/RemoveFixture.cs b/LibGit2Sharp.Tests/RemoveFixture.cs
index 52a3aba0f..94a376daf 100644
--- a/LibGit2Sharp.Tests/RemoveFixture.cs
+++ b/LibGit2Sharp.Tests/RemoveFixture.cs
@@ -14,36 +14,36 @@ public class RemoveFixture : BaseFixture
* 'git rm --cached ' works (file removed only from index).
* 'git rm ' works (file removed from both index and workdir).
*/
- [InlineData(false, "1/branch_file.txt", false, FileStatus.Unaltered, true, true, FileStatus.Untracked | FileStatus.Removed)]
- [InlineData(true, "1/branch_file.txt", false, FileStatus.Unaltered, true, false, FileStatus.Removed)]
+ [InlineData(false, "1/branch_file.txt", false, FileStatus.Unaltered, true, true, FileStatus.NewInWorkdir | FileStatus.DeletedFromIndex)]
+ [InlineData(true, "1/branch_file.txt", false, FileStatus.Unaltered, true, false, FileStatus.DeletedFromIndex)]
/***
* Test case: file exists in the index, and has been removed from the wd.
* 'git rm and 'git rm --cached ' both work (file removed from the index)
*/
- [InlineData(true, "deleted_unstaged_file.txt", false, FileStatus.Missing, false, false, FileStatus.Removed)]
- [InlineData(false, "deleted_unstaged_file.txt", false, FileStatus.Missing, false, false, FileStatus.Removed)]
+ [InlineData(true, "deleted_unstaged_file.txt", false, FileStatus.DeletedFromWorkdir, false, false, FileStatus.DeletedFromIndex)]
+ [InlineData(false, "deleted_unstaged_file.txt", false, FileStatus.DeletedFromWorkdir, false, false, FileStatus.DeletedFromIndex)]
/***
* Test case: modified file in wd, the modifications have not been promoted to the index yet.
* 'git rm --cached ' works (removes the file from the index)
* 'git rm ' fails ("error: '' has local modifications").
*/
- [InlineData(false, "modified_unstaged_file.txt", false, FileStatus.Modified, true, true, FileStatus.Untracked | FileStatus.Removed)]
- [InlineData(true, "modified_unstaged_file.txt", true, FileStatus.Modified, true, true, 0)]
+ [InlineData(false, "modified_unstaged_file.txt", false, FileStatus.ModifiedInWorkdir, true, true, FileStatus.NewInWorkdir | FileStatus.DeletedFromIndex)]
+ [InlineData(true, "modified_unstaged_file.txt", true, FileStatus.ModifiedInWorkdir, true, true, 0)]
/***
* Test case: modified file in wd, the modifications have already been promoted to the index.
* 'git rm --cached ' works (removes the file from the index)
* 'git rm ' fails ("error: '' has changes staged in the index")
*/
- [InlineData(false, "modified_staged_file.txt", false, FileStatus.Staged, true, true, FileStatus.Untracked | FileStatus.Removed)]
- [InlineData(true, "modified_staged_file.txt", true, FileStatus.Staged, true, true, 0)]
+ [InlineData(false, "modified_staged_file.txt", false, FileStatus.ModifiedInIndex, true, true, FileStatus.NewInWorkdir | FileStatus.DeletedFromIndex)]
+ [InlineData(true, "modified_staged_file.txt", true, FileStatus.ModifiedInIndex, true, true, 0)]
/***
* Test case: modified file in wd, the modifications have already been promoted to the index, and
* the file does not exist in the HEAD.
* 'git rm --cached ' works (removes the file from the index)
* 'git rm ' throws ("error: '' has changes staged in the index")
*/
- [InlineData(false, "new_tracked_file.txt", false, FileStatus.Added, true, true, FileStatus.Untracked)]
- [InlineData(true, "new_tracked_file.txt", true, FileStatus.Added, true, true, 0)]
+ [InlineData(false, "new_tracked_file.txt", false, FileStatus.NewInIndex, true, true, FileStatus.NewInWorkdir)]
+ [InlineData(true, "new_tracked_file.txt", true, FileStatus.NewInIndex, true, true, 0)]
public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory(
bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus)
{
@@ -91,7 +91,7 @@ public void RemovingAModifiedFileWhoseChangesHaveBeenPromotedToTheIndexAndWithAd
Assert.Equal(true, File.Exists(fullpath));
File.AppendAllText(fullpath, "additional content");
- Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.ModifiedInIndex | FileStatus.ModifiedInWorkdir, repo.RetrieveStatus(filename));
Assert.Throws(() => repo.Remove(filename));
Assert.Throws(() => repo.Remove(filename, false));
@@ -136,7 +136,7 @@ public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndI
}
[Theory]
- [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
+ [InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex)]
[InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
public void RemovingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(string relativePath, FileStatus status)
{
@@ -156,7 +156,7 @@ public void RemovingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(strin
}
[Theory]
- [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
+ [InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex)]
[InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileStatus status)
{
diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs
index 381973348..509ff7bac 100644
--- a/LibGit2Sharp.Tests/RepositoryFixture.cs
+++ b/LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -4,6 +4,7 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
@@ -56,6 +57,26 @@ public void CanCheckIfADirectoryLeadsToAValidRepository()
Assert.False(Repository.IsValid(scd.DirectoryPath));
}
+
+ [Fact]
+ public void IsValidWithNullPathThrows()
+ {
+ Assert.Throws(() => Repository.IsValid(null));
+ }
+
+ [Fact]
+ public void IsNotValidWithEmptyPath()
+ {
+ Assert.False(Repository.IsValid(string.Empty));
+ }
+
+ [Fact]
+ public void IsValidWithValidPath()
+ {
+ string repoPath = InitNewRepository();
+ Assert.True(Repository.IsValid(repoPath));
+ }
+
[Fact]
public void CanCreateStandardRepo()
{
@@ -243,10 +264,10 @@ private static void AssertInitializedRepository(IRepository repo, string expecte
Assert.Equal(0, repo.Commits.Count());
Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter()).Count());
- Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs.Head }).Count());
- Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { Since = repo.Head }).Count());
- Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { Since = "HEAD" }).Count());
- Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { Since = expectedHeadTargetIdentifier }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Refs.Head }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Head }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = "HEAD" }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = expectedHeadTargetIdentifier }).Count());
Assert.Null(repo.Head["subdir/I-do-not-exist"]);
@@ -651,5 +672,92 @@ public void CanDetectShallowness()
Assert.False(repo.Info.IsShallow);
}
}
+
+ [SkippableFact]
+ public void CanListRemoteReferencesWithCredentials()
+ {
+ InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl),
+ "Populate Constants.PrivateRepo* to run this test");
+
+ IEnumerable references = Repository.ListRemoteReferences(Constants.PrivateRepoUrl,
+ Constants.PrivateRepoCredentials);
+
+ foreach (var reference in references)
+ {
+ Assert.NotNull(reference);
+ }
+ }
+
+ [Theory]
+ [InlineData("http://github.com/libgit2/TestGitRepository")]
+ [InlineData("https://github.com/libgit2/TestGitRepository")]
+ [InlineData("git://github.com/libgit2/TestGitRepository.git")]
+ public void CanListRemoteReferences(string url)
+ {
+ IEnumerable references = Repository.ListRemoteReferences(url).ToList();
+
+ List> actualRefs = references.
+ Select(reference => new Tuple(reference.CanonicalName, reference.ResolveToDirectReference().TargetIdentifier)).ToList();
+
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs.Count, actualRefs.Count);
+ Assert.True(references.Single(reference => reference.CanonicalName == "HEAD") is SymbolicReference);
+ for (int i = 0; i < TestRemoteRefs.ExpectedRemoteRefs.Count; i++)
+ {
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item2, actualRefs[i].Item2);
+ Assert.Equal(TestRemoteRefs.ExpectedRemoteRefs[i].Item1, actualRefs[i].Item1);
+ }
+ }
+
+ [Fact]
+ public void CanListRemoteReferencesWithDetachedRemoteHead()
+ {
+ string originalRepoPath = SandboxStandardTestRepo();
+
+ string detachedHeadSha;
+
+ using (var originalRepo = new Repository(originalRepoPath))
+ {
+ detachedHeadSha = originalRepo.Head.Tip.Sha;
+ originalRepo.Checkout(detachedHeadSha);
+
+ Assert.True(originalRepo.Info.IsHeadDetached);
+ }
+
+ IEnumerable references = Repository.ListRemoteReferences(originalRepoPath);
+
+ Reference head = references.SingleOrDefault(reference => reference.CanonicalName == "HEAD");
+
+ Assert.NotNull(head);
+ Assert.True(head is DirectReference);
+ Assert.Equal(detachedHeadSha, head.TargetIdentifier);
+ }
+
+ [Theory]
+ [InlineData("http://github.com/libgit2/TestGitRepository")]
+ public void ReadingReferenceRepositoryThroughListRemoteReferencesThrows(string url)
+ {
+ IEnumerable references = Repository.ListRemoteReferences(url);
+
+ foreach (var reference in references)
+ {
+ IBelongToARepository repositoryReference = reference;
+ Assert.Throws(() => repositoryReference.Repository);
+ }
+ }
+
+ [Theory]
+ [InlineData("http://github.com/libgit2/TestGitRepository")]
+ public void ReadingReferenceTargetFromListRemoteReferencesThrows(string url)
+ {
+ IEnumerable references = Repository.ListRemoteReferences(url);
+
+ foreach (var reference in references)
+ {
+ Assert.Throws(() =>
+ {
+ var target = reference.ResolveToDirectReference().Target;
+ });
+ }
+ }
}
}
diff --git a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs
index 1d2072863..496cf3029 100644
--- a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs
+++ b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs
@@ -35,7 +35,7 @@ public void CanOpenABareRepoAsIfItWasAStandardOne()
using (var repo = new Repository(path, options))
{
var st = repo.RetrieveStatus("1/branch_file.txt");
- Assert.Equal(FileStatus.Missing, st);
+ Assert.Equal(FileStatus.DeletedFromWorkdir, st);
}
}
@@ -48,7 +48,7 @@ public void CanOpenABareRepoAsIfItWasAStandardOneWithANonExisitingIndexFile()
using (var repo = new Repository(path, options))
{
var st = repo.RetrieveStatus("1/branch_file.txt");
- Assert.Equal(FileStatus.Removed, st);
+ Assert.Equal(FileStatus.DeletedFromIndex, st);
}
}
@@ -78,7 +78,7 @@ public void CanProvideADifferentWorkDirToAStandardRepo()
var path2 = SandboxStandardTestRepo();
using (var repo = new Repository(path2, options))
{
- Assert.Equal(FileStatus.Missing, repo.RetrieveStatus("1/branch_file.txt"));
+ Assert.Equal(FileStatus.DeletedFromWorkdir, repo.RetrieveStatus("1/branch_file.txt"));
}
}
@@ -88,11 +88,11 @@ public void CanProvideADifferentIndexToAStandardRepo()
var path1 = SandboxStandardTestRepo();
using (var repo = new Repository(path1))
{
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("new_untracked_file.txt"));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus("new_untracked_file.txt"));
repo.Stage("new_untracked_file.txt");
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus("new_untracked_file.txt"));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus("new_untracked_file.txt"));
File.Copy(Path.Combine(repo.Info.Path, "index"), newIndex);
}
@@ -102,7 +102,7 @@ public void CanProvideADifferentIndexToAStandardRepo()
var path2 = SandboxStandardTestRepo();
using (var repo = new Repository(path2, options))
{
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus("new_untracked_file.txt"));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus("new_untracked_file.txt"));
}
}
@@ -131,7 +131,7 @@ public void CanSneakAdditionalCommitsIntoAStandardRepoWithoutAlteringTheWorkdirO
Assert.NotEqual(head.Tip.Sha, newHead.Tip.Sha);
Assert.Equal(commitSha, newHead.Tip.Sha);
- Assert.Equal(FileStatus.Removed, repo.RetrieveStatus("zomg.txt"));
+ Assert.Equal(FileStatus.DeletedFromIndex, repo.RetrieveStatus("zomg.txt"));
}
}
diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs
index b1cfda8df..2a2927328 100644
--- a/LibGit2Sharp.Tests/ResetHeadFixture.cs
+++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs
@@ -80,7 +80,7 @@ public void ResettingWithBadParamsThrows()
public void SoftResetSetsTheHeadToTheSpecifiedCommit()
{
/* Make the Head point to a branch through its name */
- AssertSoftReset(b => b.Name, false, b => b.Name);
+ AssertSoftReset(b => b.FriendlyName, false, b => b.FriendlyName);
}
[Fact]
@@ -94,7 +94,7 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@@ -107,49 +107,55 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo
Assert.Equal(shouldHeadBeDetached, repo.Info.IsHeadDetached);
string expectedHeadName = expectedHeadNameRetriever(branch);
- Assert.Equal(expectedHeadName, repo.Head.Name);
+ Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
/* Reset --soft the Head to a tag through its canonical name */
repo.Reset(ResetMode.Soft, tag.CanonicalName);
- Assert.Equal(expectedHeadName, repo.Head.Name);
+ Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(tag.Target.Id, repo.Head.Tip.Id);
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("a.txt"));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, before);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, before);
}
+ before = DateTimeOffset.Now.TruncateMilliseconds();
+
/* Reset --soft the Head to a commit through its sha */
- repo.Reset(ResetMode.Soft, branch.Tip.Sha, Constants.Signature, "FOO");
- Assert.Equal(expectedHeadName, repo.Head.Name);
+ repo.Reset(ResetMode.Soft, branch.Tip.Sha);
+ Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- branch.Tip.Id,
- "FOO",
+ string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
- Constants.Signature);
+ branch.Tip.Id,
+ Constants.Identity, before);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
- branch.Tip.Id,
- "FOO",
+ string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
- Constants.Signature);
+ branch.Tip.Id,
+ Constants.Identity, before);
}
}
}
@@ -178,7 +184,7 @@ public void MixedResetRefreshesTheIndex()
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@@ -186,19 +192,23 @@ public void MixedResetRefreshesTheIndex()
Tag tag = repo.Tags["mytag"];
+ var before = DateTimeOffset.Now.TruncateMilliseconds();
+
repo.Reset(ResetMode.Mixed, tag.CanonicalName);
- Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt"));
+ Assert.Equal(FileStatus.ModifiedInWorkdir, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, before);
AssertRefLogEntry(repo, "refs/heads/mybranch",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, before);
}
}
@@ -225,6 +235,8 @@ public void HardResetInABareRepositoryThrows()
[Fact]
public void HardResetUpdatesTheContentOfTheWorkingDirectory()
{
+ bool progressCalled = false;
+
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
@@ -235,11 +247,16 @@ public void HardResetUpdatesTheContentOfTheWorkingDirectory()
Assert.True(names.Count > 4);
- repo.Reset(ResetMode.Hard, "HEAD~3");
+ var commit = repo.Lookup("HEAD~3");
+ repo.Reset(ResetMode.Hard, commit, new CheckoutOptions()
+ {
+ OnCheckoutProgress = (_path, _completed, _total) => { progressCalled = true; },
+ });
names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
names.Sort(StringComparer.Ordinal);
+ Assert.Equal(true, progressCalled);
Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
}
}
diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs
index a87c4ef23..082566218 100644
--- a/LibGit2Sharp.Tests/ResetIndexFixture.cs
+++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs
@@ -14,18 +14,7 @@ public void ResetANewlyInitializedBareRepositoryThrows()
using (var repo = new Repository(repoPath))
{
- Assert.Throws(() => repo.Reset());
- }
- }
-
- [Fact]
- public void ResetANewlyInitializedNonBareRepositoryThrows()
- {
- string repoPath = InitNewRepository(false);
-
- using (var repo = new Repository(repoPath))
- {
- Assert.Throws(() => repo.Reset());
+ Assert.Throws(() => repo.Index.Replace(repo.Head.Tip));
}
}
@@ -35,23 +24,23 @@ public void ResettingInABareRepositoryThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
- Assert.Throws(() => repo.Reset());
+ Assert.Throws(() => repo.Index.Replace(repo.Head.Tip));
}
}
private static bool IsStaged(StatusEntry entry)
{
- if ((entry.State & FileStatus.Added) == FileStatus.Added)
+ if ((entry.State & FileStatus.NewInIndex) == FileStatus.NewInIndex)
{
return true;
}
- if ((entry.State & FileStatus.Staged) == FileStatus.Staged)
+ if ((entry.State & FileStatus.ModifiedInIndex) == FileStatus.ModifiedInIndex)
{
return true;
}
- if ((entry.State & FileStatus.Removed) == FileStatus.Removed)
+ if ((entry.State & FileStatus.DeletedFromIndex) == FileStatus.DeletedFromIndex)
{
return true;
}
@@ -70,7 +59,7 @@ public void ResetTheIndexWithTheHeadUnstagesEverything()
var reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count();
- repo.Reset();
+ repo.Index.Replace(repo.Head.Tip);
RepositoryStatus newStatus = repo.RetrieveStatus();
Assert.Equal(0, newStatus.Where(IsStaged).Count());
@@ -80,31 +69,13 @@ public void ResetTheIndexWithTheHeadUnstagesEverything()
}
}
- [Fact]
- public void CanResetTheIndexToTheContentOfACommitWithCommittishAsArgument()
- {
- string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
- {
- repo.Reset("be3563a");
-
- RepositoryStatus newStatus = repo.RetrieveStatus();
-
- var expected = new[] { "1.txt", Path.Combine("1", "branch_file.txt"), "deleted_staged_file.txt",
- "deleted_unstaged_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt" };
-
- Assert.Equal(expected.Length, newStatus.Where(IsStaged).Count());
- Assert.Equal(expected, newStatus.Removed.Select(s => s.FilePath));
- }
- }
-
[Fact]
public void CanResetTheIndexToTheContentOfACommitWithCommitAsArgument()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
- repo.Reset(repo.Lookup("be3563a"));
+ repo.Index.Replace(repo.Lookup("be3563a"));
RepositoryStatus newStatus = repo.RetrieveStatus();
@@ -116,26 +87,13 @@ public void CanResetTheIndexToTheContentOfACommitWithCommitAsArgument()
}
}
- [Fact]
- public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommittishAsArgument()
- {
- string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
- {
- repo.Reset("5b5b025", new[]{ "new.txt" });
-
- Assert.Equal("a8233120f6ad708f843d861ce2b7228ec4e3dec6", repo.Index["README"].Id.Sha);
- Assert.Equal("fa49b077972391ad58037050f2a75f74e3671e92", repo.Index["new.txt"].Id.Sha);
- }
- }
-
[Fact]
public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentAndLaxUnmatchedExplicitPathsValidation()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
- repo.Reset(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" },
+ repo.Index.Replace(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" },
new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false });
Assert.Equal("a8233120f6ad708f843d861ce2b7228ec4e3dec6", repo.Index["README"].Id.Sha);
@@ -149,7 +107,7 @@ public void ResettingTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentA
using (var repo = new Repository(SandboxStandardTestRepo()))
{
Assert.Throws(() =>
- repo.Reset(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" }, new ExplicitPathsOptions()));
+ repo.Index.Replace(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" }, new ExplicitPathsOptions()));
}
}
@@ -159,7 +117,7 @@ public void CanResetTheIndexWhenARenameExists()
using (var repo = new Repository(SandboxStandardTestRepo()))
{
repo.Move("branch_file.txt", "renamed_branch_file.txt");
- repo.Reset(repo.Lookup("32eab9c"));
+ repo.Index.Replace(repo.Lookup("32eab9c"));
RepositoryStatus status = repo.RetrieveStatus();
Assert.Equal(0, status.Where(IsStaged).Count());
@@ -178,12 +136,12 @@ public void CanResetSourceOfARenameInIndex()
Assert.Equal(FileStatus.Nonexistent, oldStatus["branch_file.txt"].State);
Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);
- repo.Reset(repo.Lookup("32eab9c"), new string[] { "branch_file.txt" });
+ repo.Index.Replace(repo.Lookup("32eab9c"), new string[] { "branch_file.txt" });
RepositoryStatus newStatus = repo.RetrieveStatus();
Assert.Equal(0, newStatus.RenamedInIndex.Count());
- Assert.Equal(FileStatus.Missing, newStatus["branch_file.txt"].State);
- Assert.Equal(FileStatus.Added, newStatus["renamed_branch_file.txt"].State);
+ Assert.Equal(FileStatus.DeletedFromWorkdir, newStatus["branch_file.txt"].State);
+ Assert.Equal(FileStatus.NewInIndex, newStatus["renamed_branch_file.txt"].State);
}
}
@@ -198,12 +156,12 @@ public void CanResetTargetOfARenameInIndex()
Assert.Equal(1, oldStatus.RenamedInIndex.Count());
Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);
- repo.Reset(repo.Lookup("32eab9c"), new string[] { "renamed_branch_file.txt" });
+ repo.Index.Replace(repo.Lookup("32eab9c"), new string[] { "renamed_branch_file.txt" });
RepositoryStatus newStatus = repo.RetrieveStatus();
Assert.Equal(0, newStatus.RenamedInIndex.Count());
- Assert.Equal(FileStatus.Untracked, newStatus["renamed_branch_file.txt"].State);
- Assert.Equal(FileStatus.Removed, newStatus["branch_file.txt"].State);
+ Assert.Equal(FileStatus.NewInWorkdir, newStatus["renamed_branch_file.txt"].State);
+ Assert.Equal(FileStatus.DeletedFromIndex, newStatus["branch_file.txt"].State);
}
}
}
diff --git a/LibGit2Sharp.Tests/Resources/.gitattributes b/LibGit2Sharp.Tests/Resources/.gitattributes
index 23d9bdb29..48eb3141c 100644
--- a/LibGit2Sharp.Tests/Resources/.gitattributes
+++ b/LibGit2Sharp.Tests/Resources/.gitattributes
@@ -1 +1,4 @@
* binary
+.gitattributes diff
+.gitignore diff
+config diff
diff --git a/LibGit2Sharp.Tests/Resources/.gitignore b/LibGit2Sharp.Tests/Resources/.gitignore
index 29ebe04b9..6b70b2273 100644
--- a/LibGit2Sharp.Tests/Resources/.gitignore
+++ b/LibGit2Sharp.Tests/Resources/.gitignore
@@ -1 +1,6 @@
*.sample
+COMMIT_EDITMSG
+exclude
+logs/
+!testrepo_wd/dot_git/logs/
+description
diff --git a/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/HEAD
deleted file mode 100644
index 8a423a7ae..000000000
--- a/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 872129051d644790636b416d1ef1ec830c5f6b90 nulltoken 1422023333 +0100 commit (initial): Initial commit
diff --git a/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index 8a423a7ae..000000000
--- a/LibGit2Sharp.Tests/Resources/assume_unchanged_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 872129051d644790636b416d1ef1ec830c5f6b90 nulltoken 1422023333 +0100 commit (initial): Initial commit
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/HEAD
deleted file mode 100644
index 9e2a5c74a..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1,9 +0,0 @@
-0000000000000000000000000000000000000000 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902455 -0500 commit (initial): Initial commit
-a3ccc66533922b02858da9ed489cd19d573d6378 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1393902574 -0500 commit: Second commit on master
-83cebf5389a4adbcb80bda6b68513caee4559802 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1393902595 -0500 checkout: moving from master to fast_forward
-83cebf5389a4adbcb80bda6b68513caee4559802 4dfaa1500526214ae7b33f9b2c1144ca8b6b1f53 Jameson Miller 1393902643 -0500 commit: Commit on fast_forward
-4dfaa1500526214ae7b33f9b2c1144ca8b6b1f53 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902655 -0500 checkout: moving from fast_forward to normal_merge
-a3ccc66533922b02858da9ed489cd19d573d6378 625186280ed2a6ec9b65d250ed90cf2e4acef957 Jameson Miller 1393902725 -0500 commit: Commit on normal_merge
-625186280ed2a6ec9b65d250ed90cf2e4acef957 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902735 -0500 checkout: moving from normal_merge to conflicts
-a3ccc66533922b02858da9ed489cd19d573d6378 0771966a0d112d3787006a6fda5b6226a770e15a Jameson Miller 1393902760 -0500 commit: Commit on conflicts
-0771966a0d112d3787006a6fda5b6226a770e15a 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1393907470 -0500 checkout: moving from conflicts to master
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/conflicts b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/conflicts
deleted file mode 100644
index bf17c1056..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/conflicts
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902539 -0500 branch: Created from master
-a3ccc66533922b02858da9ed489cd19d573d6378 0771966a0d112d3787006a6fda5b6226a770e15a Jameson Miller 1393902760 -0500 commit: Commit on conflicts
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/fast_forward b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/fast_forward
deleted file mode 100644
index 9b3d80c28..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/fast_forward
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1393902591 -0500 branch: Created from master
-83cebf5389a4adbcb80bda6b68513caee4559802 4dfaa1500526214ae7b33f9b2c1144ca8b6b1f53 Jameson Miller 1393902643 -0500 commit: Commit on fast_forward
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index 8201a1408..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902455 -0500 commit (initial): Initial commit
-a3ccc66533922b02858da9ed489cd19d573d6378 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1393902574 -0500 commit: Second commit on master
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/normal_merge b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/normal_merge
deleted file mode 100644
index e17413bdb..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/normal_merge
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 a3ccc66533922b02858da9ed489cd19d573d6378 Jameson Miller 1393902530 -0500 branch: Created from master
-a3ccc66533922b02858da9ed489cd19d573d6378 625186280ed2a6ec9b65d250ed90cf2e4acef957 Jameson Miller 1393902725 -0500 commit: Commit on normal_merge
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename
deleted file mode 100644
index a2466a9d2..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename
+++ /dev/null
@@ -1,3 +0,0 @@
-0000000000000000000000000000000000000000 83cebf5389a4adbcb80bda6b68513caee4559802 Jameson Miller 1398366152 -0400 branch: Created from HEAD
-83cebf5389a4adbcb80bda6b68513caee4559802 9075c06ff9cd736610dea688bca7e912903ff2d1 Jameson Miller 1398366254 -0400 commit: Add content to b.txt
-9075c06ff9cd736610dea688bca7e912903ff2d1 24434077dec097c1203ef9e1345c0545c190936a Jameson Miller 1398366641 -0400 commit: edit to b.txt
diff --git a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename_source b/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename_source
deleted file mode 100644
index 1515dd26e..000000000
--- a/LibGit2Sharp.Tests/Resources/merge_testrepo_wd/dot_git/logs/refs/heads/rename_source
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 9075c06ff9cd736610dea688bca7e912903ff2d1 Jameson Miller 1398366267 -0400 branch: Created from rename
-9075c06ff9cd736610dea688bca7e912903ff2d1 2bc71d0e8acfbb9fd1cc2d9d48c23dbf8aea52c9 Jameson Miller 1398366593 -0400 commit: rename and edit b.txt
diff --git a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/config b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/config
index 78387c50b..277bd5530 100644
--- a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/config
+++ b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/config
@@ -6,3 +6,4 @@
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
+ autocrlf = false
diff --git a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/HEAD
deleted file mode 100644
index 839dfc811..000000000
--- a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1,15 +0,0 @@
-0000000000000000000000000000000000000000 9107b30fe11ff310fec93876469147b263fb958c Edward Thomson 1360632480 -0600 commit (initial): ancestor
-9107b30fe11ff310fec93876469147b263fb958c 9107b30fe11ff310fec93876469147b263fb958c Edward Thomson 1360632483 -0600 checkout: moving from master to branch
-9107b30fe11ff310fec93876469147b263fb958c d4c107581ff54a41fd496e0a1f1b7b3354752103 Edward Thomson 1360632833 -0600 commit: branch
-d4c107581ff54a41fd496e0a1f1b7b3354752103 9107b30fe11ff310fec93876469147b263fb958c Edward Thomson 1360632835 -0600 checkout: moving from branch to master
-9107b30fe11ff310fec93876469147b263fb958c 8b19fd77de5995e6e502e7c3b82657248f510325 Edward Thomson 1360633224 -0600 commit: ours
-8b19fd77de5995e6e502e7c3b82657248f510325 91116bad97c50a2daa278ca6cffe16d0118befe5 Edward Thomson 1360633337 -0600 commit: ours
-91116bad97c50a2daa278ca6cffe16d0118befe5 8b19fd77de5995e6e502e7c3b82657248f510325 Edward Thomson 1360633358 -0600 checkout: moving from master to 8b19fd7
-8b19fd77de5995e6e502e7c3b82657248f510325 9b2f98b1c086d3929eac387d39fae94425e0115f Edward Thomson 1360633359 -0600 rebase -i (squash): ours
-9b2f98b1c086d3929eac387d39fae94425e0115f 9b2f98b1c086d3929eac387d39fae94425e0115f Edward Thomson 1360633362 -0600 rebase -i (finish): returning to refs/heads/master
-9b2f98b1c086d3929eac387d39fae94425e0115f d4c107581ff54a41fd496e0a1f1b7b3354752103 Edward Thomson 1360633367 -0600 checkout: moving from master to branch
-d4c107581ff54a41fd496e0a1f1b7b3354752103 493209f496e504d63fd78e8c5b800083b442ea34 Edward Thomson 1360633416 -0600 commit: branch
-493209f496e504d63fd78e8c5b800083b442ea34 d4c107581ff54a41fd496e0a1f1b7b3354752103 Edward Thomson 1360633427 -0600 checkout: moving from branch to d4c1075
-d4c107581ff54a41fd496e0a1f1b7b3354752103 8eefb6f8061e4d10a7a59aac8771dc17958d93eb Edward Thomson 1360633429 -0600 rebase -i (squash): branch
-8eefb6f8061e4d10a7a59aac8771dc17958d93eb 8eefb6f8061e4d10a7a59aac8771dc17958d93eb Edward Thomson 1360633436 -0600 rebase -i (finish): returning to refs/heads/branch
-8eefb6f8061e4d10a7a59aac8771dc17958d93eb 9b2f98b1c086d3929eac387d39fae94425e0115f Edward Thomson 1360633440 -0600 checkout: moving from branch to master
diff --git a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/branch b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/branch
deleted file mode 100644
index 13819577f..000000000
--- a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/branch
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 9107b30fe11ff310fec93876469147b263fb958c Edward Thomson 1360632483 -0600 branch: Created from HEAD
-9107b30fe11ff310fec93876469147b263fb958c d4c107581ff54a41fd496e0a1f1b7b3354752103 Edward Thomson 1360632833 -0600 commit: branch
-d4c107581ff54a41fd496e0a1f1b7b3354752103 493209f496e504d63fd78e8c5b800083b442ea34 Edward Thomson 1360633416 -0600 commit: branch
-493209f496e504d63fd78e8c5b800083b442ea34 8eefb6f8061e4d10a7a59aac8771dc17958d93eb Edward Thomson 1360633436 -0600 rebase -i (finish): refs/heads/branch onto d4c1075
diff --git a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index 167ae3e56..000000000
--- a/LibGit2Sharp.Tests/Resources/mergedrepo_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 9107b30fe11ff310fec93876469147b263fb958c Edward Thomson 1360632480 -0600 commit (initial): ancestor
-9107b30fe11ff310fec93876469147b263fb958c 8b19fd77de5995e6e502e7c3b82657248f510325 Edward Thomson 1360633224 -0600 commit: ours
-8b19fd77de5995e6e502e7c3b82657248f510325 91116bad97c50a2daa278ca6cffe16d0118befe5 Edward Thomson 1360633337 -0600 commit: ours
-91116bad97c50a2daa278ca6cffe16d0118befe5 9b2f98b1c086d3929eac387d39fae94425e0115f Edward Thomson 1360633362 -0600 rebase -i (finish): refs/heads/master onto 8b19fd7
diff --git a/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/HEAD
deleted file mode 100644
index 7b5293fd3..000000000
--- a/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson 1365715620 -0500 moving to bd59328
diff --git a/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index a46518da8..000000000
--- a/LibGit2Sharp.Tests/Resources/mergerenames_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson 1351875584 -0500 reset: moving to 977c696519c5a3004c5f1d15d60c89dbeb8f235f
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/HEAD b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/config b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/config
new file mode 100644
index 000000000..78387c50b
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/config
@@ -0,0 +1,8 @@
+[core]
+ repositoryformatversion = 0
+ filemode = false
+ bare = false
+ logallrefupdates = true
+ symlinks = false
+ ignorecase = true
+ hideDotFiles = dotGitOnly
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/index b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/index
new file mode 100644
index 000000000..1af67f2d4
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/index differ
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/87/2129051d644790636b416d1ef1ec830c5f6b90 b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/87/2129051d644790636b416d1ef1ec830c5f6b90
new file mode 100644
index 000000000..3c800a797
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/87/2129051d644790636b416d1ef1ec830c5f6b90
@@ -0,0 +1,3 @@
+xI
+B1]>'[oU/Zni"5SQhC.n=?
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/88/e38705fdbd3608cddbe904b67c731f3234c45b b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/88/e38705fdbd3608cddbe904b67c731f3234c45b
new file mode 100644
index 000000000..783449ff9
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/88/e38705fdbd3608cddbe904b67c731f3234c45b differ
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/cc/628ccd10742baea8241c5924df992b5c019f71 b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/cc/628ccd10742baea8241c5924df992b5c019f71
new file mode 100644
index 000000000..6b011038d
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/cc/628ccd10742baea8241c5924df992b5c019f71 differ
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/ce/013625030ba8dba906f756967f9e9ca394464a b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/ce/013625030ba8dba906f756967f9e9ca394464a
new file mode 100644
index 000000000..6802d4949
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/objects/ce/013625030ba8dba906f756967f9e9ca394464a differ
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/refs/heads/master b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/refs/heads/master
new file mode 100644
index 000000000..2ed6cd9fa
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/dot_git/refs/heads/master
@@ -0,0 +1 @@
+872129051d644790636b416d1ef1ec830c5f6b90
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/hello.txt b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/hello.txt
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/hello.txt
@@ -0,0 +1 @@
+Hello
diff --git a/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/world.txt b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/world.txt
new file mode 100644
index 000000000..216e97ce0
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/packbuilder_testrepo_wd/world.txt
@@ -0,0 +1 @@
+World
diff --git a/LibGit2Sharp.Tests/Resources/submodule_small_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/submodule_small_wd/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_small_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/HEAD
deleted file mode 100644
index 0ecd1113f..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 6b31c659545507c381e9cd34ec508f16c04e149e Russell Belfer 1342559662 -0700 commit (initial): Initial commit
-6b31c659545507c381e9cd34ec508f16c04e149e 41bd4bc3df978de695f67ace64c560913da11653 Russell Belfer 1342559709 -0700 commit: Adding test file
-41bd4bc3df978de695f67ace64c560913da11653 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559726 -0700 commit: Updating test file
-5e4963595a9774b90524d35a807169049de8ccad 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342559925 -0700 commit: One more update
diff --git a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index 0ecd1113f..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_target_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 6b31c659545507c381e9cd34ec508f16c04e149e Russell Belfer 1342559662 -0700 commit (initial): Initial commit
-6b31c659545507c381e9cd34ec508f16c04e149e 41bd4bc3df978de695f67ace64c560913da11653 Russell Belfer 1342559709 -0700 commit: Adding test file
-41bd4bc3df978de695f67ace64c560913da11653 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559726 -0700 commit: Updating test file
-5e4963595a9774b90524d35a807169049de8ccad 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342559925 -0700 commit: One more update
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/config
index d8535d3ac..7eada4ff5 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/config
@@ -18,3 +18,5 @@
url = ../submodule_target_wd
[submodule "sm_added_and_uncommited"]
url = ../submodule_target_wd
+[submodule "sm_branch_only"]
+ url = ../submodule_target_wd
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/HEAD
deleted file mode 100644
index 2cf2ca74d..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/HEAD
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 14fe9ccf104058df25e0a08361c4494e167ef243 Russell Belfer 1342559771 -0700 commit (initial): Initial commit
-14fe9ccf104058df25e0a08361c4494e167ef243 a9104bf89e911387244ef499413960ba472066d9 Russell Belfer 1342559831 -0700 commit: Adding a submodule
-a9104bf89e911387244ef499413960ba472066d9 5901da4f1c67756eeadc5121d206bec2431f253b Russell Belfer 1342560036 -0700 commit: Updating submodule
-5901da4f1c67756eeadc5121d206bec2431f253b 7484482eb8db738cafa696993664607500a3f2b9 Russell Belfer 1342560288 -0700 commit: Adding a bunch more test content
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/refs/heads/master
deleted file mode 100644
index 2cf2ca74d..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1,4 +0,0 @@
-0000000000000000000000000000000000000000 14fe9ccf104058df25e0a08361c4494e167ef243 Russell Belfer 1342559771 -0700 commit (initial): Initial commit
-14fe9ccf104058df25e0a08361c4494e167ef243 a9104bf89e911387244ef499413960ba472066d9 Russell Belfer 1342559831 -0700 commit: Adding a submodule
-a9104bf89e911387244ef499413960ba472066d9 5901da4f1c67756eeadc5121d206bec2431f253b Russell Belfer 1342560036 -0700 commit: Updating submodule
-5901da4f1c67756eeadc5121d206bec2431f253b 7484482eb8db738cafa696993664607500a3f2b9 Russell Belfer 1342560288 -0700 commit: Adding a bunch more test content
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/config
index 2d0583e99..e37936d26 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/HEAD
deleted file mode 100644
index 53753e7dd..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/heads/master
deleted file mode 100644
index 53753e7dd..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index 53753e7dd..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/config
new file mode 100644
index 000000000..d00ee8884
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/config
@@ -0,0 +1,16 @@
+[core]
+ repositoryformatversion = 0
+ filemode = false
+ bare = false
+ logallrefupdates = true
+ worktree = ../../../sm_branch_only
+ symlinks = false
+ ignorecase = true
+ hideDotFiles = dotGitOnly
+[remote "origin"]
+ url = ../../../../submodule_target_wd
+ fetch = +refs/heads/*:refs/remotes/origin/*
+[branch "master"]
+ remote = origin
+ merge = refs/heads/master
+ rebase = true
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/index b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/index
new file mode 100644
index 000000000..a30232ec4
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/index differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1
new file mode 100644
index 000000000..f4b7094c5
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484
new file mode 100644
index 000000000..56c845e49
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5
new file mode 100644
index 000000000..bd179b5f5
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/41/bd4bc3df978de695f67ace64c560913da11653
new file mode 100644
index 000000000..ccf49bd15
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/41/bd4bc3df978de695f67ace64c560913da11653 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/48/0095882d281ed676fe5b863569520e54a7d5c0
new file mode 100644
index 000000000..53029069a
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/5e/4963595a9774b90524d35a807169049de8ccad b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/5e/4963595a9774b90524d35a807169049de8ccad
new file mode 100644
index 000000000..38c791eba
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/5e/4963595a9774b90524d35a807169049de8ccad differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/6b/31c659545507c381e9cd34ec508f16c04e149e b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/6b/31c659545507c381e9cd34ec508f16c04e149e
new file mode 100644
index 000000000..a26d29993
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/6b/31c659545507c381e9cd34ec508f16c04e149e
@@ -0,0 +1,2 @@
+xQ
+!Evoy*_@g#hOh^9wSòf1*[Ic ԤpkΑ\S߇l@.^QpF(:D5zr~ en8
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/73/ba924a80437097795ae839e66e187c55d3babf b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/73/ba924a80437097795ae839e66e187c55d3babf
new file mode 100644
index 000000000..83d1ba481
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/73/ba924a80437097795ae839e66e187c55d3babf differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a
new file mode 100644
index 000000000..6d27af8a8
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a
@@ -0,0 +1,2 @@
+x-10Fa0p(N-ӡғq]>ks*? |mi@mV'`).-1x
+uxt(+
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/9efbdadaa4a582778d4584385495559ea0994b
new file mode 100644
index 000000000..17458840b
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/78/9efbdadaa4a582778d4584385495559ea0994b
@@ -0,0 +1,2 @@
+x
0)?=
NlOkj8&r
+qJW7B<fK8#Q1C-"e̫>'@
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e
new file mode 100644
index 000000000..83cc29fb1
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5
new file mode 100644
index 000000000..55bda40ef
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/packed-refs b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/packed-refs
new file mode 100644
index 000000000..def303a5f
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/packed-refs
@@ -0,0 +1,2 @@
+# pack-refs with: peeled fully-peeled
+480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/heads/master
new file mode 100644
index 000000000..e12c44d7a
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/heads/master
@@ -0,0 +1 @@
+480095882d281ed676fe5b863569520e54a7d5c0
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/remotes/origin/HEAD
new file mode 100644
index 000000000..6efe28fff
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_branch_only/refs/remotes/origin/HEAD
@@ -0,0 +1 @@
+ref: refs/remotes/origin/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/config
index 10cc2508e..9812c64b3 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/HEAD
deleted file mode 100644
index e5cb63f8d..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/heads/master
deleted file mode 100644
index e5cb63f8d..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index e5cb63f8d..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_file/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/COMMIT_EDITMSG b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/COMMIT_EDITMSG
deleted file mode 100644
index 6b8d1e3fc..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/COMMIT_EDITMSG
+++ /dev/null
@@ -1 +0,0 @@
-Making a change in a submodule
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/config
index 7d002536a..6d46e37ac 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/HEAD
deleted file mode 100644
index cabdeb2b5..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/HEAD
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
-480095882d281ed676fe5b863569520e54a7d5c0 3d9386c507f6b093471a3e324085657a3c2b4247 Russell Belfer 1342560431 -0700 commit: Making a change in a submodule
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/heads/master
deleted file mode 100644
index cabdeb2b5..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/heads/master
+++ /dev/null
@@ -1,2 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
-480095882d281ed676fe5b863569520e54a7d5c0 3d9386c507f6b093471a3e324085657a3c2b4247 Russell Belfer 1342560431 -0700 commit: Making a change in a submodule
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index 257ca21d1..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_head/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/config
index 0274ff7e3..94490e330 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/HEAD
deleted file mode 100644
index 80eb54102..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/heads/master
deleted file mode 100644
index 80eb54102..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index 80eb54102..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_index/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/config
index 7f2584476..e5ff0780a 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/HEAD
deleted file mode 100644
index d1beafbd6..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/heads/master
deleted file mode 100644
index d1beafbd6..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index d1beafbd6..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/config
index 45fbb30cf..376a475b5 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/HEAD
deleted file mode 100644
index ee08c9706..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/heads/master
deleted file mode 100644
index ee08c9706..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index ee08c9706..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/config b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/config
index fc706c9dd..ea79f0e26 100644
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/config
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/config
@@ -7,7 +7,7 @@
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
- url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target
+ url = ../../../../submodule_target_wd
[branch "master"]
remote = origin
merge = refs/heads/master
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/description b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/info/exclude b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/info/exclude
deleted file mode 100644
index a5196d1be..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/info/exclude
+++ /dev/null
@@ -1,6 +0,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/HEAD
deleted file mode 100644
index 72653286a..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/heads/master
deleted file mode 100644
index 72653286a..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/remotes/origin/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/remotes/origin/HEAD
deleted file mode 100644
index 72653286a..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/modules/sm_unchanged/logs/refs/remotes/origin/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/13/921096a46cb66610badba272f8211346eaf8f3 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/13/921096a46cb66610badba272f8211346eaf8f3
new file mode 100644
index 000000000..6f03cbf00
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/13/921096a46cb66610badba272f8211346eaf8f3 differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/6b/94d06e586d4ed904d8c00a9de7d0afe0fc9c3c b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/6b/94d06e586d4ed904d8c00a9de7d0afe0fc9c3c
new file mode 100644
index 000000000..21bbe6d2b
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/6b/94d06e586d4ed904d8c00a9de7d0afe0fc9c3c differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/87/aa3a079302a662a9226af3c6e7f444815e3faf b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/87/aa3a079302a662a9226af3c6e7f444815e3faf
new file mode 100644
index 000000000..666341811
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/87/aa3a079302a662a9226af3c6e7f444815e3faf differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/a4/aab482be687d2facec638781ded4aa1a92687a b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/a4/aab482be687d2facec638781ded4aa1a92687a
new file mode 100644
index 000000000..34675b82e
Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/a4/aab482be687d2facec638781ded4aa1a92687a differ
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/cf/27c0500009f6d12fd82d841ecf6a17b18ff812 b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/cf/27c0500009f6d12fd82d841ecf6a17b18ff812
new file mode 100644
index 000000000..d620874b9
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/objects/cf/27c0500009f6d12fd82d841ecf6a17b18ff812
@@ -0,0 +1,2 @@
+xK `)HPCz{jS-?fHCf]\ jJ8'4ǝQJxG{U2&mr֙t׃挦x\-|4Yf
+Mmej dНчNY4ڠ)c6"܍\9l}2X;7N?Y h
\ No newline at end of file
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/refs/heads/dev b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/refs/heads/dev
new file mode 100644
index 000000000..9cbe3f817
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/submodule_wd/dot_git/refs/heads/dev
@@ -0,0 +1 @@
+6b94d06e586d4ed904d8c00a9de7d0afe0fc9c3c
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/description b/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/description
deleted file mode 100644
index 498b267a8..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/HEAD b/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/HEAD
deleted file mode 100644
index 1749e7dff..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/HEAD
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 68e92c611b80ee1ed8f38314ff9577f0d15b2444 Russell Belfer 1342560358 -0700 commit (initial): Initial commit
diff --git a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/refs/heads/master b/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/refs/heads/master
deleted file mode 100644
index 1749e7dff..000000000
--- a/LibGit2Sharp.Tests/Resources/submodule_wd/not_submodule/dot_git/logs/refs/heads/master
+++ /dev/null
@@ -1 +0,0 @@
-0000000000000000000000000000000000000000 68e92c611b80ee1ed8f38314ff9577f0d15b2444 Russell Belfer 1342560358 -0700 commit (initial): Initial commit
diff --git a/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/description b/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/description
deleted file mode 100644
index 893e5cad2..000000000
--- a/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/description
+++ /dev/null
@@ -1 +0,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
diff --git a/LibGit2Sharp.Tests/RevertFixture.cs b/LibGit2Sharp.Tests/RevertFixture.cs
index 5c52cc6c7..b57728764 100644
--- a/LibGit2Sharp.Tests/RevertFixture.cs
+++ b/LibGit2Sharp.Tests/RevertFixture.cs
@@ -1,9 +1,9 @@
+using System;
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
-using System;
namespace LibGit2Sharp.Tests
{
@@ -67,8 +67,6 @@ public void CanRevertAndNotCommit()
string path = SandboxRevertTestRepo();
using (var repo = new Repository(path))
{
- string modifiedFileFullPath = Path.Combine(repo.Info.WorkingDirectory, revertedFile);
-
// Checkout the revert branch.
Branch branch = repo.Checkout(revertBranchName);
Assert.NotNull(branch);
@@ -83,7 +81,7 @@ public void CanRevertAndNotCommit()
// Verify workspace is dirty.
FileStatus fileStatus = repo.RetrieveStatus(revertedFile);
- Assert.Equal(FileStatus.Staged, fileStatus);
+ Assert.Equal(FileStatus.ModifiedInIndex, fileStatus);
// This is the ID of the blob containing the expected content.
Blob expectedBlob = repo.Lookup("bc90ea420cf6c5ae3db7dcdffa0d79df567f219b");
@@ -131,8 +129,8 @@ public void RevertWithConflictDoesNotCommit()
Assert.NotNull(repo.Index.Conflicts["a.txt"]);
// Verify the non-conflicting paths are staged.
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("b.txt"));
- Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("c.txt"));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus("b.txt"));
+ Assert.Equal(FileStatus.ModifiedInIndex, repo.RetrieveStatus("c.txt"));
}
}
@@ -160,6 +158,7 @@ public void RevertWithFileConflictStrategyOption(CheckoutFileConflictStrategy co
};
RevertResult result = repo.Revert(repo.Head.Tip.Parents.First(), Constants.Signature, options);
+ Assert.Equal(RevertStatus.Conflicts, result.Status);
// Verify there is a conflict.
Assert.False(repo.Index.IsFullyMerged);
@@ -242,6 +241,7 @@ public void RevertReportsCheckoutNotification()
repo.Revert(repo.Head.Tip, Constants.Signature, options);
Assert.True(wasCalled);
+ Assert.Equal(CheckoutNotifyFlags.Updated, actualNotifyFlags);
}
}
diff --git a/LibGit2Sharp.Tests/SetErrorFixture.cs b/LibGit2Sharp.Tests/SetErrorFixture.cs
new file mode 100644
index 000000000..b10a54108
--- /dev/null
+++ b/LibGit2Sharp.Tests/SetErrorFixture.cs
@@ -0,0 +1,182 @@
+using System;
+using System.IO;
+using System.Text;
+using LibGit2Sharp.Tests.TestHelpers;
+using Xunit;
+
+namespace LibGit2Sharp.Tests
+{
+ public class SetErrorFixture : BaseFixture
+ {
+
+ private const string simpleExceptionMessage = "This is a simple exception message.";
+ private const string aggregateExceptionMessage = "This is aggregate exception.";
+ private const string outerExceptionMessage = "This is an outer exception.";
+ private const string innerExceptionMessage = "This is an inner exception.";
+ private const string innerExceptionMessage2 = "This is inner exception #2.";
+
+ private const string expectedInnerExceptionHeaderText = "Inner Exception:";
+ private const string expectedAggregateExceptionHeaderText = "Contained Exception:";
+ private const string expectedAggregateExceptionsHeaderText = "Contained Exceptions:";
+
+ [Fact]
+ public void FormatSimpleException()
+ {
+ Exception exceptionToThrow = new Exception(simpleExceptionMessage);
+ string expectedMessage = simpleExceptionMessage;
+
+ AssertExpectedExceptionMessage(expectedMessage, exceptionToThrow);
+ }
+
+ [Fact]
+ public void FormatExceptionWithInnerException()
+ {
+ Exception exceptionToThrow = new Exception(outerExceptionMessage, new Exception(innerExceptionMessage));
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(outerExceptionMessage);
+ sb.AppendLine();
+ AppendIndentedLine(sb, expectedInnerExceptionHeaderText, 0);
+ AppendIndentedText(sb, innerExceptionMessage, 1);
+ string expectedMessage = sb.ToString();
+
+ AssertExpectedExceptionMessage(expectedMessage, exceptionToThrow);
+ }
+
+ [Fact]
+ public void FormatAggregateException()
+ {
+ Exception exceptionToThrow = new AggregateException(aggregateExceptionMessage, new Exception(innerExceptionMessage), new Exception(innerExceptionMessage2));
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(aggregateExceptionMessage);
+ sb.AppendLine();
+
+ AppendIndentedLine(sb, expectedAggregateExceptionsHeaderText, 0);
+
+ AppendIndentedLine(sb, innerExceptionMessage, 1);
+ sb.AppendLine();
+
+ AppendIndentedText(sb, innerExceptionMessage2, 1);
+
+ string expectedMessage = sb.ToString();
+
+ AssertExpectedExceptionMessage(expectedMessage, exceptionToThrow);
+ }
+
+ private void AssertExpectedExceptionMessage(string expectedMessage, Exception exceptionToThrow)
+ {
+ Exception thrownException = null;
+
+ ObjectId id = new ObjectId("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+
+ string repoPath = InitNewRepository();
+ using (var repo = new Repository(repoPath))
+ {
+ repo.ObjectDatabase.AddBackend(new ThrowingOdbBackend(exceptionToThrow), priority: 1);
+
+ try
+ {
+ repo.Lookup(id);
+ }
+ catch (Exception ex)
+ {
+ thrownException = ex;
+ }
+ }
+
+ Assert.NotNull(thrownException);
+ Assert.Equal(expectedMessage, thrownException.Message);
+ }
+
+ private void AppendIndentedText(StringBuilder sb, string text, int indentLevel)
+ {
+ sb.AppendFormat("{0}{1}", IndentString(indentLevel), text);
+ }
+
+ private void AppendIndentedLine(StringBuilder sb, string text, int indentLevel)
+ {
+ sb.AppendFormat("{0}{1}{2}", IndentString(indentLevel), text, Environment.NewLine);
+ }
+
+ private string IndentString(int level)
+ {
+ return new string(' ', level * 4);
+ }
+
+ #region ThrowingOdbBackend
+
+ private class ThrowingOdbBackend : OdbBackend
+ {
+ private Exception exceptionToThrow;
+
+ public ThrowingOdbBackend(Exception exceptionToThrow)
+ {
+ this.exceptionToThrow = exceptionToThrow;
+ }
+
+ protected override OdbBackendOperations SupportedOperations
+ {
+ get
+ {
+ return OdbBackendOperations.Read |
+ OdbBackendOperations.ReadPrefix |
+ OdbBackendOperations.Write |
+ OdbBackendOperations.WriteStream |
+ OdbBackendOperations.Exists |
+ OdbBackendOperations.ExistsPrefix |
+ OdbBackendOperations.ForEach |
+ OdbBackendOperations.ReadHeader;
+ }
+ }
+
+ public override int Read(ObjectId oid, out UnmanagedMemoryStream data, out ObjectType objectType)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int ReadPrefix(string shortSha, out ObjectId id, out UnmanagedMemoryStream data, out ObjectType objectType)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int Write(ObjectId oid, Stream dataStream, long length, ObjectType objectType)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int WriteStream(long length, ObjectType objectType, out OdbBackendStream stream)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override bool Exists(ObjectId oid)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int ExistsPrefix(string shortSha, out ObjectId found)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int ReadHeader(ObjectId oid, out int length, out ObjectType objectType)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int ReadStream(ObjectId oid, out OdbBackendStream stream)
+ {
+ throw this.exceptionToThrow;
+ }
+
+ public override int ForEach(ForEachCallback callback)
+ {
+ throw this.exceptionToThrow;
+ }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/LibGit2Sharp.Tests/ShadowCopyFixture.cs b/LibGit2Sharp.Tests/ShadowCopyFixture.cs
index 5eaf4dced..f394e987e 100644
--- a/LibGit2Sharp.Tests/ShadowCopyFixture.cs
+++ b/LibGit2Sharp.Tests/ShadowCopyFixture.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Reflection;
using System.Security;
@@ -17,7 +17,7 @@ public void CanProbeForNativeBinariesFromAShadowCopiedAssembly()
Assembly assembly = type.Assembly;
// Build a new domain which will shadow copy assemblies
- string cachePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ string cachePath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName());
Directory.CreateDirectory(cachePath);
var setup = new AppDomainSetup
@@ -51,18 +51,13 @@ public void CanProbeForNativeBinariesFromAShadowCopiedAssembly()
// ...but are currently loaded from different locations...
string cachedAssemblyLocation = wrapper.AssemblyLocation;
- if (cachedAssemblyLocation.StartsWith("/private"))
- {
- // On OS X, sometimes you get /private/var/… instead of /var/…, but they map to the same place.
- cachedAssemblyLocation = cachedAssemblyLocation.Substring("/private".Length);
- }
Assert.NotEqual(sourceAssembly.Location, cachedAssemblyLocation);
// ...that the assembly in the other domain is stored in the shadow copy cache...
string cachedAssembliesPath = Path.Combine(setup.CachePath, setup.ApplicationName);
Assert.True(cachedAssemblyLocation.StartsWith(cachedAssembliesPath));
- if (!IsRunningOnLinux())
+ if (!Constants.IsRunningOnUnix)
{
// ...that this cache doesn't contain the `NativeBinaries` folder
string cachedAssemblyParentPath = Path.GetDirectoryName(cachedAssemblyLocation);
diff --git a/LibGit2Sharp.Tests/SmartSubtransportFixture.cs b/LibGit2Sharp.Tests/SmartSubtransportFixture.cs
index 50f19ecc0..6d4e0fe40 100644
--- a/LibGit2Sharp.Tests/SmartSubtransportFixture.cs
+++ b/LibGit2Sharp.Tests/SmartSubtransportFixture.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Security;
using LibGit2Sharp.Tests.TestHelpers;
+using LibGit2Sharp.Core;
using Xunit;
using Xunit.Extensions;
@@ -39,7 +39,7 @@ public void CustomSmartSubtransportTest(string scheme, string url)
registration = GlobalSettings.RegisterSmartSubtransport(scheme);
Assert.NotNull(registration);
- using (var repo = new Repository(scd.DirectoryPath))
+ using (var repo = new Repository(repoPath))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);
@@ -77,6 +77,58 @@ public void CustomSmartSubtransportTest(string scheme, string url)
}
}
+ [Theory]
+ [InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
+ public void CanUseCredentials(string scheme, string url, string user, string pass)
+ {
+ string remoteName = "testRemote";
+
+ var scd = BuildSelfCleaningDirectory();
+ var repoPath = Repository.Init(scd.RootedDirectoryPath);
+
+ SmartSubtransportRegistration registration = null;
+
+ try
+ {
+ // Disable server certificate validation for testing.
+ // Do *NOT* enable this in production.
+ ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback;
+
+ registration = GlobalSettings.RegisterSmartSubtransport(scheme);
+ Assert.NotNull(registration);
+
+ using (var repo = new Repository(scd.DirectoryPath))
+ {
+ Remote remote = repo.Network.Remotes.Add(remoteName, url);
+
+ // Set up structures for the expected results
+ // and verifying the RemoteUpdateTips callback.
+ TestRemoteInfo expectedResults = TestRemoteInfo.TestRemoteInstance;
+ ExpectedFetchState expectedFetchState = new ExpectedFetchState(remoteName);
+
+ // Add expected branch objects
+ foreach (KeyValuePair kvp in expectedResults.BranchTips)
+ {
+ expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
+ }
+
+ // Perform the actual fetch
+ repo.Network.Fetch(remote, new FetchOptions { OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler, TagFetchMode = TagFetchMode.Auto,
+ CredentialsProvider = (_user, _valid, _hostname) => new UsernamePasswordCredentials() { Username = "libgit3", Password = "libgit3" },
+ });
+
+ // Verify the expected
+ expectedFetchState.CheckUpdatedReferences(repo);
+ }
+ }
+ finally
+ {
+ GlobalSettings.UnregisterSmartSubtransport(registration);
+
+ ServicePointManager.ServerCertificateValidationCallback -= certificateValidationCallback;
+ }
+ }
+
[Fact]
public void CannotReregisterScheme()
{
@@ -235,7 +287,31 @@ private HttpWebResponse GetResponseWithRedirects()
}
}
- response = (HttpWebResponse)request.GetResponse();
+ try
+ {
+ response = (HttpWebResponse)request.GetResponse();
+ }
+ catch (WebException ex)
+ {
+ response = ex.Response as HttpWebResponse;
+ if (response.StatusCode == HttpStatusCode.Unauthorized)
+ {
+ Credentials cred;
+ int ret = SmartTransport.AcquireCredentials(out cred, null, typeof(UsernamePasswordCredentials));
+ if (ret != 0)
+ {
+ throw new InvalidOperationException("dunno");
+ }
+
+ request = CreateWebRequest(EndpointUrl, IsPost, ContentType);
+ UsernamePasswordCredentials userpass = (UsernamePasswordCredentials)cred;
+ request.Credentials = new NetworkCredential(userpass.Username, userpass.Password);
+ continue;
+ }
+
+ // rethrow if it's not 401
+ throw ex;
+ }
if (response.StatusCode == HttpStatusCode.Moved || response.StatusCode == HttpStatusCode.Redirect)
{
@@ -243,6 +319,7 @@ private HttpWebResponse GetResponseWithRedirects()
continue;
}
+
break;
}
diff --git a/LibGit2Sharp.Tests/StageFixture.cs b/LibGit2Sharp.Tests/StageFixture.cs
index 679f20486..9a6c6248a 100644
--- a/LibGit2Sharp.Tests/StageFixture.cs
+++ b/LibGit2Sharp.Tests/StageFixture.cs
@@ -11,11 +11,11 @@ public class StageFixture : BaseFixture
[Theory]
[InlineData("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
[InlineData("README", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
- [InlineData("deleted_unstaged_file.txt", FileStatus.Missing, true, FileStatus.Removed, false, -1)]
- [InlineData("modified_unstaged_file.txt", FileStatus.Modified, true, FileStatus.Staged, true, 0)]
- [InlineData("new_untracked_file.txt", FileStatus.Untracked, false, FileStatus.Added, true, 1)]
- [InlineData("modified_staged_file.txt", FileStatus.Staged, true, FileStatus.Staged, true, 0)]
- [InlineData("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Added, true, 0)]
+ [InlineData("deleted_unstaged_file.txt", FileStatus.DeletedFromWorkdir, true, FileStatus.DeletedFromIndex, false, -1)]
+ [InlineData("modified_unstaged_file.txt", FileStatus.ModifiedInWorkdir, true, FileStatus.ModifiedInIndex, true, 0)]
+ [InlineData("new_untracked_file.txt", FileStatus.NewInWorkdir, false, FileStatus.NewInIndex, true, 1)]
+ [InlineData("modified_staged_file.txt", FileStatus.ModifiedInIndex, true, FileStatus.ModifiedInIndex, true, 0)]
+ [InlineData("new_tracked_file.txt", FileStatus.NewInIndex, true, FileStatus.NewInIndex, true, 0)]
public void CanStage(string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation)
{
string path = SandboxStandardTestRepo();
@@ -43,23 +43,23 @@ public void CanStageTheUpdationOfAStagedFile()
const string filename = "new_tracked_file.txt";
IndexEntry blob = repo.Index[filename];
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
Touch(repo.Info.WorkingDirectory, filename, "brand new content");
- Assert.Equal(FileStatus.Added | FileStatus.Modified, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex | FileStatus.ModifiedInWorkdir, repo.RetrieveStatus(filename));
repo.Stage(filename);
IndexEntry newBlob = repo.Index[filename];
Assert.Equal(count, repo.Index.Count);
Assert.NotEqual(newBlob.Id, blob.Id);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
}
}
[Theory]
[InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
- [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
+ [InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex)]
public void StagingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileStatus status)
{
var path = SandboxStandardTestRepoGitDir();
@@ -74,7 +74,7 @@ public void StagingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileSt
[Theory]
[InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
- [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
+ [InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex)]
public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus status)
{
var path = SandboxStandardTestRepoGitDir();
@@ -92,7 +92,7 @@ public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string
[Theory]
[InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
- [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
+ [InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex)]
public void StagingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(string relativePath, FileStatus status)
{
var path = SandboxStandardTestRepoGitDir();
@@ -116,10 +116,10 @@ public void CanStageTheRemovalOfAStagedFile()
const string filename = "new_tracked_file.txt";
Assert.NotNull(repo.Index[filename]);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
File.Delete(Path.Combine(repo.Info.WorkingDirectory, filename));
- Assert.Equal(FileStatus.Added | FileStatus.Missing, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex | FileStatus.DeletedFromWorkdir, repo.RetrieveStatus(filename));
repo.Stage(filename);
Assert.Null(repo.Index[filename]);
@@ -142,18 +142,18 @@ public void CanStageANewFileInAPersistentManner(string filename)
Assert.Null(repo.Index[filename]);
Touch(repo.Info.WorkingDirectory, filename, "some contents");
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(filename));
Assert.Null(repo.Index[filename]);
repo.Stage(filename);
Assert.NotNull(repo.Index[filename]);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
}
using (var repo = new Repository(path))
{
Assert.NotNull(repo.Index[filename]);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
}
}
@@ -194,9 +194,9 @@ private static void AssertStage(bool? ignorecase, IRepository repo, string path)
try
{
repo.Stage(path);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(path));
- repo.Reset();
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(path));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(path));
+ repo.Index.Replace(repo.Head.Tip);
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(path));
}
catch (ArgumentException)
{
@@ -331,7 +331,65 @@ public void CanStageIgnoredPaths(string path)
Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path));
repo.Stage(path, new StageOptions { IncludeIgnored = true });
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(path));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(path));
+ }
+ }
+
+ [Theory]
+ [InlineData("new_untracked_file.txt", FileStatus.Ignored)]
+ [InlineData("modified_unstaged_file.txt", FileStatus.ModifiedInIndex)]
+ public void IgnoredFilesAreOnlyStagedIfTheyreInTheRepo(string filename, FileStatus expected)
+ {
+ var path = SandboxStandardTestRepoGitDir();
+ using (var repo = new Repository(path))
+ {
+ File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, ".gitignore"),
+ String.Format("{0}\n", filename));
+
+ repo.Stage(filename);
+ Assert.Equal(expected, repo.RetrieveStatus(filename));
+ }
+ }
+
+ [Theory]
+ [InlineData("ancestor-and-ours.txt", FileStatus.Unaltered)]
+ [InlineData("ancestor-and-theirs.txt", FileStatus.NewInIndex)]
+ [InlineData("ancestor-only.txt", FileStatus.Nonexistent)]
+ [InlineData("conflicts-one.txt", FileStatus.ModifiedInIndex)]
+ [InlineData("conflicts-two.txt", FileStatus.ModifiedInIndex)]
+ [InlineData("ours-only.txt", FileStatus.Unaltered)]
+ [InlineData("ours-and-theirs.txt", FileStatus.ModifiedInIndex)]
+ [InlineData("theirs-only.txt", FileStatus.NewInIndex)]
+ public void CanStageConflictedIgnoredFiles(string filename, FileStatus expected)
+ {
+ var path = SandboxMergedTestRepo();
+ using (var repo = new Repository(path))
+ {
+ File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, ".gitignore"),
+ String.Format("{0}\n", filename));
+
+ repo.Stage(filename);
+ Assert.Equal(expected, repo.RetrieveStatus(filename));
+ }
+ }
+
+ [Fact]
+ public void CanSuccessfullyStageTheContentOfAModifiedFileOfTheSameSizeWithinTheSameSecond()
+ {
+ string repoPath = InitNewRepository();
+
+ using (var repo = new Repository(repoPath))
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ Touch(repo.Info.WorkingDirectory, "test.txt",
+ Guid.NewGuid().ToString());
+
+ repo.Stage("test.txt");
+
+ Assert.DoesNotThrow(() => repo.Commit(
+ "Commit", Constants.Signature, Constants.Signature));
+ }
}
}
}
diff --git a/LibGit2Sharp.Tests/StashFixture.cs b/LibGit2Sharp.Tests/StashFixture.cs
index c9f94064f..369ac0994 100644
--- a/LibGit2Sharp.Tests/StashFixture.cs
+++ b/LibGit2Sharp.Tests/StashFixture.cs
@@ -150,7 +150,7 @@ public void CanStashWithoutOptions()
Assert.NotNull(stash.Index[staged]);
//It should leave untracked files untracked
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(untracked));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus(untracked));
Assert.Null(stash.Untracked);
}
}
@@ -171,7 +171,7 @@ public void CanStashAndKeepIndex()
Assert.NotNull(stash);
Assert.NotNull(stash.Index[filename]);
- Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
Assert.Null(stash.Untracked);
}
}
@@ -204,6 +204,156 @@ public void CanStashIgnoredFiles()
}
}
+ [Fact]
+ public void CanStashAndApplyWithOptions()
+ {
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var stasher = Constants.Signature;
+
+ const string filename = "staged_file_path.txt";
+ Touch(repo.Info.WorkingDirectory, filename, "I'm staged\n");
+ repo.Stage(filename);
+
+ repo.Stashes.Add(stasher, "This stash with default options");
+ Assert.Equal(StashApplyStatus.Applied, repo.Stashes.Apply(0));
+
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
+ Assert.Equal(1, repo.Stashes.Count());
+
+ repo.Stage(filename);
+
+ repo.Stashes.Add(stasher, "This stash with default options");
+ Assert.Equal(StashApplyStatus.Applied, repo.Stashes.Apply(
+ 0,
+ new StashApplyOptions
+ {
+ ApplyModifiers = StashApplyModifiers.ReinstateIndex,
+ }));
+
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
+ Assert.Equal(2, repo.Stashes.Count());
+ }
+ }
+
+ [Fact]
+ public void CanStashAndPop()
+ {
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var stasher = Constants.Signature;
+
+ Assert.Equal(0, repo.Stashes.Count());
+
+ const string filename = "staged_file_path.txt";
+ const string contents = "I'm staged";
+ Touch(repo.Info.WorkingDirectory, filename, contents);
+ repo.Stage(filename);
+
+ repo.Stashes.Add(stasher, "This stash with default options");
+ Assert.Equal(1, repo.Stashes.Count());
+
+ Assert.Equal(StashApplyStatus.Applied, repo.Stashes.Pop(0));
+ Assert.Equal(0, repo.Stashes.Count());
+
+ Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(filename));
+ Assert.Equal(contents, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename)));
+ }
+ }
+
+ [Fact]
+ public void StashFailsWithUncommittedChangesIntheIndex()
+ {
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var stasher = Constants.Signature;
+
+ const string filename = "staged_file_path.txt";
+ const string originalContents = "I'm pre-stash.";
+ const string filename2 = "unstaged_file_path.txt";
+ const string newContents = "I'm post-stash.";
+
+ Touch(repo.Info.WorkingDirectory, filename, originalContents);
+ repo.Stage(filename);
+ Touch(repo.Info.WorkingDirectory, filename2, originalContents);
+
+ repo.Stashes.Add(stasher, "This stash with default options");
+
+ Touch(repo.Info.WorkingDirectory, filename, newContents);
+ repo.Stage(filename);
+ Touch(repo.Info.WorkingDirectory, filename2, newContents);
+
+ Assert.Equal(StashApplyStatus.UncommittedChanges, repo.Stashes.Pop(0, new StashApplyOptions
+ {
+ ApplyModifiers = StashApplyModifiers.ReinstateIndex,
+ }));
+ Assert.Equal(1, repo.Stashes.Count());
+ Assert.Equal(newContents, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename)));
+ Assert.Equal(newContents, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename2)));
+ }
+ }
+
+ [Fact]
+ public void StashCallsTheCallback()
+ {
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var stasher = Constants.Signature;
+ bool called;
+
+ const string filename = "staged_file_path.txt";
+ const string filename2 = "unstaged_file_path.txt";
+ const string originalContents = "I'm pre-stash.";
+
+ Touch(repo.Info.WorkingDirectory, filename, originalContents);
+ repo.Stage(filename);
+ Touch(repo.Info.WorkingDirectory, filename2, originalContents);
+
+ repo.Stashes.Add(stasher, "This stash with default options");
+
+ called = false;
+ repo.Stashes.Apply(0, new StashApplyOptions
+ {
+ ProgressHandler = (progress) => { called = true; return true; }
+ });
+
+ Assert.Equal(true, called);
+
+ repo.Reset(ResetMode.Hard);
+
+ called = false;
+ repo.Stashes.Pop(0, new StashApplyOptions
+ {
+ ProgressHandler = (progress) => { called = true; return true; }
+ });
+
+ Assert.Equal(true, called);
+ }
+ }
+
+ [Fact]
+ public void StashApplyReportsNotFound()
+ {
+ string path = SandboxStandardTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var stasher = Constants.Signature;
+
+ const string filename = "unstaged_file_path.txt";
+ Touch(repo.Info.WorkingDirectory, filename, "I'm unstaged\n");
+
+ repo.Stashes.Add(stasher, "This stash with default options", StashModifiers.IncludeUntracked);
+ Touch(repo.Info.WorkingDirectory, filename, "I'm another unstaged\n");
+
+ Assert.Equal(StashApplyStatus.NotFound, repo.Stashes.Pop(1));
+ Assert.Throws(() => repo.Stashes.Pop(-1));
+ }
+ }
+
[Theory]
[InlineData(-1)]
[InlineData(-42)]
diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs
index e8f9d7314..3c9bc0023 100644
--- a/LibGit2Sharp.Tests/StatusFixture.cs
+++ b/LibGit2Sharp.Tests/StatusFixture.cs
@@ -17,13 +17,13 @@ public void CanRetrieveTheStatusOfAFile()
using (var repo = new Repository(path))
{
FileStatus status = repo.RetrieveStatus("new_tracked_file.txt");
- Assert.Equal(FileStatus.Added, status);
+ Assert.Equal(FileStatus.NewInIndex, status);
}
}
[Theory]
- [InlineData(StatusShowOption.IndexAndWorkDir, FileStatus.Untracked)]
- [InlineData(StatusShowOption.WorkDirOnly, FileStatus.Untracked)]
+ [InlineData(StatusShowOption.IndexAndWorkDir, FileStatus.NewInWorkdir)]
+ [InlineData(StatusShowOption.WorkDirOnly, FileStatus.NewInWorkdir)]
[InlineData(StatusShowOption.IndexOnly, FileStatus.Nonexistent)]
public void CanLimitStatusToWorkDirOnly(StatusShowOption show, FileStatus expected)
{
@@ -39,9 +39,9 @@ public void CanLimitStatusToWorkDirOnly(StatusShowOption show, FileStatus expect
}
[Theory]
- [InlineData(StatusShowOption.IndexAndWorkDir, FileStatus.Added)]
+ [InlineData(StatusShowOption.IndexAndWorkDir, FileStatus.NewInIndex)]
[InlineData(StatusShowOption.WorkDirOnly, FileStatus.Nonexistent)]
- [InlineData(StatusShowOption.IndexOnly, FileStatus.Added)]
+ [InlineData(StatusShowOption.IndexOnly, FileStatus.NewInIndex)]
public void CanLimitStatusToIndexOnly(StatusShowOption show, FileStatus expected)
{
var clone = SandboxStandardTestRepo();
@@ -89,7 +89,7 @@ public void CanRetrieveTheStatusOfAnUntrackedFile(string filePath)
Touch(repo.Info.WorkingDirectory, filePath, "content");
FileStatus status = repo.RetrieveStatus(filePath);
- Assert.Equal(FileStatus.Untracked, status);
+ Assert.Equal(FileStatus.NewInWorkdir, status);
}
}
@@ -99,24 +99,26 @@ public void RetrievingTheStatusOfADirectoryThrows()
var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path))
{
- Assert.Throws(() => { FileStatus status = repo.RetrieveStatus("1"); });
+ Assert.Throws(() => { repo.RetrieveStatus("1"); });
}
}
- [Fact]
- public void CanRetrieveTheStatusOfTheWholeWorkingDirectory()
+ [Theory]
+ [InlineData(false, 0)]
+ [InlineData(true, 5)]
+ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory(bool includeUnaltered, int unalteredCount)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
const string file = "modified_staged_file.txt";
- RepositoryStatus status = repo.RetrieveStatus();
+ RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = includeUnaltered });
- Assert.Equal(FileStatus.Staged, status[file].State);
+ Assert.Equal(FileStatus.ModifiedInIndex, status[file].State);
Assert.NotNull(status);
- Assert.Equal(6, status.Count());
+ Assert.Equal(6 + unalteredCount, status.Count());
Assert.True(status.IsDirty);
Assert.Equal("new_untracked_file.txt", status.Untracked.Select(s => s.FilePath).Single());
@@ -129,13 +131,13 @@ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory()
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, file),
"Tclem's favorite commit message: boom");
- Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.RetrieveStatus(file));
+ Assert.Equal(FileStatus.ModifiedInIndex | FileStatus.ModifiedInWorkdir, repo.RetrieveStatus(file));
- RepositoryStatus status2 = repo.RetrieveStatus();
- Assert.Equal(FileStatus.Staged | FileStatus.Modified, status2[file].State);
+ RepositoryStatus status2 = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = includeUnaltered });
+ Assert.Equal(FileStatus.ModifiedInIndex | FileStatus.ModifiedInWorkdir, status2[file].State);
Assert.NotNull(status2);
- Assert.Equal(6, status2.Count());
+ Assert.Equal(6 + unalteredCount, status2.Count());
Assert.True(status2.IsDirty);
Assert.Equal("new_untracked_file.txt", status2.Untracked.Select(s => s.FilePath).Single());
@@ -171,7 +173,7 @@ public void CanRetrieveTheStatusOfRenamedFilesInWorkDir()
DetectRenamesInWorkDir = true
});
- Assert.Equal(FileStatus.Added | FileStatus.RenamedInWorkDir, status["rename_target.txt"].State);
+ Assert.Equal(FileStatus.NewInIndex | FileStatus.RenamedInWorkdir, status["rename_target.txt"].State);
Assert.Equal(100, status["rename_target.txt"].IndexToWorkDirRenameDetails.Similarity);
}
}
@@ -223,7 +225,7 @@ public void CanDetectedVariousKindsOfRenaming()
RepositoryStatus status = repo.RetrieveStatus(opts);
// This passes as expected
- Assert.Equal(FileStatus.RenamedInWorkDir, status.Single().State);
+ Assert.Equal(FileStatus.RenamedInWorkdir, status.Single().State);
repo.Stage("file.txt");
repo.Stage("renamed.txt");
@@ -237,19 +239,21 @@ public void CanDetectedVariousKindsOfRenaming()
status = repo.RetrieveStatus(opts);
- Assert.Equal(FileStatus.RenamedInWorkDir | FileStatus.RenamedInIndex,
+ Assert.Equal(FileStatus.RenamedInWorkdir | FileStatus.RenamedInIndex,
status.Single().State);
}
}
- [Fact]
- public void CanRetrieveTheStatusOfANewRepository()
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public void CanRetrieveTheStatusOfANewRepository(bool includeUnaltered)
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
{
- RepositoryStatus status = repo.RetrieveStatus();
+ RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = includeUnaltered });
Assert.NotNull(status);
Assert.Equal(0, status.Count());
Assert.False(status.IsDirty);
@@ -405,7 +409,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
[Theory]
[InlineData(true, FileStatus.Unaltered, FileStatus.Unaltered)]
- [InlineData(false, FileStatus.Missing, FileStatus.Untracked)]
+ [InlineData(false, FileStatus.DeletedFromWorkdir, FileStatus.NewInWorkdir)]
public void RetrievingTheStatusOfAFilePathHonorsTheIgnoreCaseConfigurationSetting(
bool shouldIgnoreCase,
FileStatus expectedlowerCasedFileStatus,
@@ -480,7 +484,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug
Touch(repo.Info.WorkingDirectory, gitIgnore, sb.ToString());
Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus("bin/look-ma.txt"));
- Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("bin/what-about-me.txt"));
+ Assert.Equal(FileStatus.NewInWorkdir, repo.RetrieveStatus("bin/what-about-me.txt"));
newStatus = repo.RetrieveStatus();
@@ -592,5 +596,43 @@ public void RetrievingTheStatusHonorsAssumedUnchangedMarkedIndexEntries()
Assert.Equal("hello.txt", status.Modified.Single().FilePath);
}
}
+
+ [Fact]
+ public void CanIncludeStatusOfUnalteredFiles()
+ {
+ var path = SandboxStandardTestRepo();
+ string[] unalteredPaths = {
+ "1.txt",
+ "1" + Path.DirectorySeparatorChar + "branch_file.txt",
+ "branch_file.txt",
+ "new.txt",
+ "README",
+ };
+
+ using (var repo = new Repository(path))
+ {
+ RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = true });
+
+ Assert.Equal(unalteredPaths.Length, status.Unaltered.Count());
+ Assert.Equal(unalteredPaths, status.Unaltered.OrderBy(s => s.FilePath).Select(s => s.FilePath).ToArray());
+ }
+ }
+
+ [Fact]
+ public void UnalteredFilesDontMarkIndexAsDirty()
+ {
+ var path = SandboxStandardTestRepo();
+
+ using (var repo = new Repository(path))
+ {
+ repo.Reset(ResetMode.Hard);
+ repo.RemoveUntrackedFiles();
+
+ RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = true });
+
+ Assert.Equal(false, status.IsDirty);
+ Assert.Equal(9, status.Count());
+ }
+ }
}
}
diff --git a/LibGit2Sharp.Tests/SubmoduleFixture.cs b/LibGit2Sharp.Tests/SubmoduleFixture.cs
index d60e61f3e..58c8a830a 100644
--- a/LibGit2Sharp.Tests/SubmoduleFixture.cs
+++ b/LibGit2Sharp.Tests/SubmoduleFixture.cs
@@ -20,6 +20,26 @@ public void RetrievingSubmoduleForNormalDirectoryReturnsNull()
}
}
+ [Fact]
+ public void RetrievingSubmoduleInBranchShouldWork()
+ {
+ var path = SandboxSubmoduleTestRepo();
+ using (var repo = new Repository(path))
+ {
+ var submodule = repo.Submodules["sm_branch_only"];
+ Assert.Null(submodule);
+
+ repo.Checkout("dev", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
+ submodule = repo.Submodules["sm_branch_only"];
+ Assert.NotNull(submodule);
+ Assert.NotEqual(SubmoduleStatus.Unmodified, submodule.RetrieveStatus());
+
+ repo.Checkout("master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
+ submodule = repo.Submodules["sm_branch_only"];
+ Assert.Null(submodule);
+ }
+ }
+
[Theory]
[InlineData("sm_added_and_uncommited", SubmoduleStatus.InConfig | SubmoduleStatus.InIndex | SubmoduleStatus.InWorkDir | SubmoduleStatus.IndexAdded)]
[InlineData("sm_changed_file", SubmoduleStatus.InConfig | SubmoduleStatus.InHead | SubmoduleStatus.InIndex | SubmoduleStatus.InWorkDir | SubmoduleStatus.WorkDirFilesModified)]
@@ -29,12 +49,20 @@ public void RetrievingSubmoduleForNormalDirectoryReturnsNull()
[InlineData("sm_gitmodules_only", SubmoduleStatus.InConfig)]
[InlineData("sm_missing_commits", SubmoduleStatus.InConfig | SubmoduleStatus.InHead | SubmoduleStatus.InIndex | SubmoduleStatus.InWorkDir | SubmoduleStatus.WorkDirModified)]
[InlineData("sm_unchanged", SubmoduleStatus.InConfig | SubmoduleStatus.InHead | SubmoduleStatus.InIndex | SubmoduleStatus.InWorkDir)]
- public void CanRetrieveTheStatusOfASubmodule(string name, SubmoduleStatus expectedStatus)
+ [InlineData("sm_branch_only", null)]
+ public void CanRetrieveTheStatusOfASubmodule(string name, SubmoduleStatus? expectedStatus)
{
var path = SandboxSubmoduleTestRepo();
using (var repo = new Repository(path))
{
var submodule = repo.Submodules[name];
+
+ if (expectedStatus == null)
+ {
+ Assert.Null(submodule);
+ return;
+ }
+
Assert.NotNull(submodule);
Assert.Equal(name, submodule.Name);
Assert.Equal(name, submodule.Path);
diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs
index 2291a1266..48284a021 100644
--- a/LibGit2Sharp.Tests/TagFixture.cs
+++ b/LibGit2Sharp.Tests/TagFixture.cs
@@ -4,6 +4,7 @@
using LibGit2Sharp.Core;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
@@ -105,7 +106,7 @@ public void CanAddATagWithNameContainingASlash()
Assert.NotNull(lwTag);
Assert.False(lwTag.IsAnnotated);
Assert.Equal(commitE90810BSha, lwTag.Target.Sha);
- Assert.Equal(lwTagName, lwTag.Name);
+ Assert.Equal(lwTagName, lwTag.FriendlyName);
const string anTagName = lwTagName + "_as_well";
Tag anTag = repo.Tags.Add(anTagName, commitE90810BSha, signatureNtk, "a nice message");
@@ -113,7 +114,7 @@ public void CanAddATagWithNameContainingASlash()
Assert.True(anTag.IsAnnotated);
Assert.Equal(commitE90810BSha, anTag.Target.Sha);
Assert.Equal(anTag.Target, anTag.Annotation.Target);
- Assert.Equal(anTagName, anTag.Name);
+ Assert.Equal(anTagName, anTag.FriendlyName);
}
}
@@ -370,7 +371,7 @@ public void CanAddATagPointingToATree()
Assert.Equal(tree.Id, tag.Target.Id);
Assert.Equal(tree, repo.Lookup(tag.Target.Id));
- Assert.Equal(tag, repo.Tags[tag.Name]);
+ Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}
@@ -408,7 +409,7 @@ public void CanAddATagPointingToABlob()
Assert.Equal(blob.Id, tag.Target.Id);
Assert.Equal(blob, repo.Lookup(tag.Target.Id));
- Assert.Equal(tag, repo.Tags[tag.Name]);
+ Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}
@@ -428,7 +429,7 @@ public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedT
Assert.Equal(annotation, tag.Annotation);
Assert.Equal(annotation, repo.Lookup(tag.Annotation.Id));
- Assert.Equal(tag, repo.Tags[tag.Name]);
+ Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}
@@ -447,7 +448,7 @@ public void CanAddAnAnnotatedTagPointingToATagAnnotation()
Assert.Equal(annotation.Id, tag.Annotation.Target.Id);
Assert.NotEqual(annotation, tag.Annotation);
- Assert.Equal(tag, repo.Tags[tag.Name]);
+ Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}
@@ -604,12 +605,12 @@ public void RemovingATagDecreasesTheTagsCount()
{
const string tagName = "e90810b";
- List tags = repo.Tags.Select(r => r.Name).ToList();
+ List tags = repo.Tags.Select(r => r.FriendlyName).ToList();
Assert.True(tags.Contains(tagName));
repo.Tags.Remove(tagName);
- List tags2 = repo.Tags.Select(r => r.Name).ToList();
+ List