Skip to content

Commit 9af8d53

Browse files
committed
Introduce blame options for rename tracking
1 parent 083361d commit 9af8d53

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

LibGit2Sharp/BlameOptions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public enum BlameStrategy
77
{
88
/// <summary>
9-
/// Track renames of the file, but no block movement.
9+
/// Track renames of the file using diff rename detection, but no block movement.
1010
/// </summary>
1111
Default,
1212

@@ -21,6 +21,16 @@ public enum BlameStrategy
2121

2222
// Track copies across all files in all commits. (NOT SUPPORTED IN LIBGIT2 YET)
2323
//TrackCopiesAnyCommitCopies
24+
25+
/// <summary>
26+
/// Track renames of the file using only exact renames.
27+
/// </summary>
28+
FollowExactRenames = (1 << 5),
29+
30+
/// <summary>
31+
/// Don't track renames of the file.
32+
/// </summary>
33+
DontFollowRenames = (1 << 6),
2434
}
2535

2636
/// <summary>

LibGit2Sharp/Core/GitBlame.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ internal enum GitBlameOptionFlags
3838
/// following only the first parents.
3939
/// </summary>
4040
GIT_BLAME_FIRST_PARENT = (1<<4),
41+
42+
/// <summary>
43+
/// Take less time to generate blame by only following exact matches.
44+
/// </summary>
45+
GIT_BLAME_FOLLOW_EXACT_RENAMES = (1<<5),
46+
47+
/// <summary>
48+
/// Take less time to generate blame by not checking for renames
49+
/// </summary>
50+
GIT_BLAME_DONT_FOLLOW_RENAMES = (1<<6),
4151
}
4252

4353
[StructLayout(LayoutKind.Sequential)]
@@ -78,6 +88,12 @@ public static GitBlameOptionFlags ToGitBlameOptionFlags(this BlameStrategy strat
7888
case BlameStrategy.Default:
7989
return GitBlameOptionFlags.GIT_BLAME_NORMAL;
8090

91+
case BlameStrategy.FollowExactRenames:
92+
return GitBlameOptionFlags.GIT_BLAME_FOLLOW_EXACT_RENAMES;
93+
94+
case BlameStrategy.DontFollowRenames:
95+
return GitBlameOptionFlags.GIT_BLAME_DONT_FOLLOW_RENAMES;
96+
8197
default:
8298
throw new NotSupportedException(
8399
string.Format(CultureInfo.InvariantCulture, "{0} is not supported at this time", strategy));

0 commit comments

Comments
 (0)