Search code examples
gitlibgit2libgit2sharp

What is the purpose of the `logMessage` parameter in a fetch command?


One of the parameters of the Fetch command is the logMessage. Taking an example from the wiki, it passes in an empty string.

string logMessage = "";
using (var repo = new Repository("path/to/your/repo"))
{
    var remote = repo.Network.Remotes["origin"];
    var refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
    Commands.Fetch(repo, remote.Name, refSpecs, null, logMessage);
    //                                                ^^^^^^^^^^---- this
}
Console.WriteLine(logMessage);

What exactly is this for anyway?

As far as I know in git, you don't need to provide a message when fetching from a remote. The parameter descriptions says:

Log message for any ref updates.

But I'm not sure what that means in this context.


Solution

  • The logMessage parameter controls the message that is used in the reflog. So if any commits are fetched, the entry for the affected branch will use that message.