libgit2sharp: how to set multiple values with same key


how do I set multiple values for a config-key? Some sections supports multiple values:

[remote "origin"]
   url =
   fetch = +refs/heads/master:refs/remotes/origin/master
   fetch = +refs/heads/qa/*:refs/remotes/origin/qa/*

Something like this is not working in gitLib2Sharp:

string[] refSpecs = {"+refs/heads/master:refs/remotes/origin/master", "+refs/heads/qa/*:refs/remotes/origin/qa/*"};
repo.Config.Set( @"remote.origin.fetch", refSpec );   

1 Answer: 

How do I set multiple values for a config-key

This is indeed a currently missing feature in LibGit2Sharp. An issue has just been opened to track this.

However, if what you're after is setting/updating the default refspecs of a remote, the repo.Network.Remotes.Update() method may already fit that need without having to wait for the issue to be fixed.

  • Pull request #567 recently enhanced the Remotes.Update() method to make it cope with refspecs updation. As such, your example could be fulfilled with the following code.
    var fetchSpecs = new string[]

    using (var repo = new Repository(path))
        var remote = repo.Network.Remotes["origin"];
        repo.Network.Remotes.Update(remote, r => r.FetchRefSpecs = fetchSpecs);
  • More or less related, pull request #553 introduced an easy way to enumerate all the refspecs of a remote

More Articles

Access remote git repo via ssh, using libgit2sharp

I'm trying to get a simple working example for cloning or accessing a remote git repository via ssh. After adding nuget package LibGit2Sharp-SSH v1.0.22, got a .Net Framework v4.6.1 console application like this:using LibGit2Sharp;using System;using System.IO;class Program{ static void Main(strin

javascript - onDelete not being called when deleting a node in Cloud Functions for Firebase

I am trying to build triggers for a firebase app around following and followers. Below is a snippet of my cloud code. I want to increase a counter when a user follows. For this I use oncreate (for when the user gains their first follower due the structure not existing until this point) and then I

php - mcrypt module open function is missing in php7.2.7

In PHP5 I was able to use mcrypt_module_open and now in PHP7.2.7 (which I just upgrade to) the function is missing and while searching, I discovered that it has been replaced by OpenSSL. My question is this: What is the equivalent of mcrypt_module_open in OPenSSL?

android - How to return different code and error with MockRestAdapter

I use MockRestAdapter to return mock data in my tests, but I'd also like to test errors (401, 503, UnknownHostException, etc)For SocketTimeoutException, there's an API, but how about different response code?I've tried MockWebServer but no matter what I enqueue, I always get a 200 with the mock data

rust - How do I move multiple values out of a boxed value without calling clone?

This question already has an answer here: How to bind multiple fields of a boxed struct without getting “use moved value” error? 2 answers

r - split string at every character

I want to split every character in a string and output it as comma or tab separated characters:I need to use file_in and file_out since I have very many lines.inputTTTGGCTTTGTGCAATGG........outputT,T,T,G,G,CT,T,T,GT,G,C,A,A,T,G,GI have used this, but it prints every character vertically: /usr/bin/p

java - gRPC: Generate certificateChainFile and privateKeyFile to make TLS/SSL work

I want to make tls/ssl connection between client and server(Not mutual, one way). This is my setup:Server: Server server = ServerBuilder.forPort(8443) // Enable TLS .useTransportSecurity(certChainFile, privateKeyFile) .addService(new GreetingServiceImpl()) .build();Cli

python - Heap that supports modification of its elements?

Here is my scenario. I want to implement A* (in Python) without having to resort to linear-time min or in operations. I need a heap to be able to efficiently get the lowest weight item. My immediate response was 'Easy! I'll use heapq!' Then I discovered that life is rarely as simple as we would like

java - Location mocking - google map detects the movement but my own application not triggering location change

I am facing a strange issue. I modified official mock provider source code provided by google to mock some route for my application.Using this code. mockLocation.setElapsedRealtimeNanos(elapsedTimeNanos); mockLocation.setTime(currentTime); // Set the loc

android - Can't find class [org/drinkless/td/libcore/telegram/TdApi$Object]

I am getting this error "Can't find class [org/drinkless/td/libcore/telegram/TdApi$Object]" but I haven't used this class anywhere in my project.I haven't used that class anywhere.But i am getting the above errorCan anyone please let me know how to solve the above error.