diff options
author | Keith Dahlby <dahlbyk@gmail.com> | 2013-04-25 00:04:17 +0400 |
---|---|---|
committer | Keith Dahlby <dahlbyk@gmail.com> | 2013-04-25 00:08:49 +0400 |
commit | 00580411f2fe376bb4c0e721ca1b832a7de0044b (patch) | |
tree | b1dead37d2265844450581b72b12f21a5ed3037c /LibGit2Sharp/TreeDefinition.cs | |
parent | 6d5efba33b2d2df022f0e7e158ed4fc5e1b584d2 (diff) |
Add TreeDefinition.AddGitLink()
Diffstat (limited to 'LibGit2Sharp/TreeDefinition.cs')
-rw-r--r-- | LibGit2Sharp/TreeDefinition.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/LibGit2Sharp/TreeDefinition.cs b/LibGit2Sharp/TreeDefinition.cs index f312a9a2..950e286b 100644 --- a/LibGit2Sharp/TreeDefinition.cs +++ b/LibGit2Sharp/TreeDefinition.cs @@ -174,6 +174,23 @@ namespace LibGit2Sharp return Add(targetTreeEntryPath, ted); } + /// <summary> + /// Adds or replaces a gitlink <see cref="TreeEntryDefinition"/>, + /// referencing the commit identified by <paramref name="objectId"/>, + /// at the specified <paramref name="targetTreeEntryPath"/> location. + /// </summary> + /// <param name="targetTreeEntryPath">The path within this <see cref="TreeDefinition"/>.</param> + /// <param name="objectId">The <see cref="ObjectId"/> of the commit to be linked at the described location.</param> + /// <returns>The current <see cref="TreeDefinition"/>.</returns> + public virtual TreeDefinition AddGitLink(string targetTreeEntryPath, ObjectId objectId) + { + Ensure.ArgumentNotNull(objectId, "objectId"); + + var ted = TreeEntryDefinition.From(objectId); + + return Add(targetTreeEntryPath, ted); + } + private TreeDefinition RetrieveOrBuildTreeDefinition(string treeName, bool shouldOverWrite) { TreeDefinition td; @@ -195,6 +212,7 @@ namespace LibGit2Sharp break; case GitObjectType.Blob: + case GitObjectType.Commit: if (shouldOverWrite) { td = new TreeDefinition(); |