Skip to content

Commit e4eaa4e

Browse files
committed
Update on Command.Pull but it does not work as expected actually.
2 parents 997fbb2 + 12d28e4 commit e4eaa4e

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

Diff for: LibGit2Sharp/Commands/Pull.cs

+19-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ public static partial class Commands
1515
/// <param name="repository">The repository.</param>
1616
/// <param name="merger">The signature to use for the merge.</param>
1717
/// <param name="options">The options for fetch and merging.</param>
18-
public static MergeResult Pull(Repository repository, Signature merger, PullOptions options)
18+
public static MergeResult Pull(Repository repository, Signature merger, PullOptions options = null)
1919
{
2020
Ensure.ArgumentNotNull(repository, "repository");
21-
Ensure.ArgumentNotNull(merger, "merger");
2221

2322

24-
options = options ?? new PullOptions();
2523
Branch currentBranch = repository.Head;
2624

2725
if (!currentBranch.IsTracking)
@@ -34,7 +32,24 @@ public static MergeResult Pull(Repository repository, Signature merger, PullOpti
3432
throw new LibGit2SharpException("No upstream remote for the current branch.");
3533
}
3634

37-
Commands.Fetch(repository, currentBranch.RemoteName, new string[0], options.FetchOptions, null);
35+
return Pull(repository, currentBranch.RemoteName, merger, options);
36+
}
37+
38+
/// <summary>
39+
/// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD.
40+
/// </summary>
41+
/// <param name="repository">The repository.</param>
42+
/// <param name="remoteNameOrPath">The remote name or repository path.</param>
43+
/// <param name="merger">The signature to use for the merge.</param>
44+
/// <param name="options">The options for fetch and merging.</param>
45+
public static MergeResult Pull(Repository repository, string remoteNameOrPath, Signature merger, PullOptions options = null)
46+
{
47+
Ensure.ArgumentNotNull(repository, "repository");
48+
Ensure.ArgumentNotNull(merger, "merger");
49+
50+
51+
options = options ?? new PullOptions();
52+
Commands.Fetch(repository, remoteNameOrPath, new string[0], options.FetchOptions, null);
3853
return repository.MergeFetchedRefs(merger, options.MergeOptions);
3954
}
4055
}

Diff for: LibGit2Sharp/ContentChanges.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,24 @@ private unsafe int LineCallback(git_diff_delta* delta, GitDiffHunk hunk, GitDiff
117117
break;
118118
}
119119

120-
AppendGitDiffLine(line);
120+
AppendGitDiffLine(line, decodedContent);
121121
AppendToPatch(prefix);
122122
AppendToPatch(decodedContent);
123123
return 0;
124124
}
125125

126-
internal void AppendGitDiffLine(GitDiffLine line)
126+
internal void AppendGitDiffLine(GitDiffLine line, string patch)
127127
{
128128
switch (line.lineOrigin)
129129
{
130130
case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION:
131-
AddedLines.Add(new Line(line.NewLineNo, decodedContent));
131+
AddedLines.Add(new Line(line.NewLineNo, patch));
132132
LinesAdded++;
133133
lines.Add(new ContentChangeLine(line));
134134
break;
135135

136136
case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION:
137-
DeletedLines.Add(new Line(line.OldLineNo, decodedContent));
137+
DeletedLines.Add(new Line(line.OldLineNo, patch));
138138
LinesDeleted++;
139139
lines.Add(new ContentChangeLine(line));
140140
break;

Diff for: LibGit2Sharp/Patch.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
8585
break;
8686
}
8787

88-
currentChange.AppendGitDiffLine(line);
88+
currentChange.AppendGitDiffLine(line, patchPart);
8989

9090
string formattedOutput = string.Concat(prefix, patchPart);
9191

0 commit comments

Comments
 (0)