Skip to content

Config doesn't handle getting and storing all types of attributes #725

@bdunne

Description

@bdunne

Hello, I'm working on transitioning my project over to using rugged. I'm amazed at the performance improvements that we've seen so far. I'm getting down to the last few operations that need to be converted and I'm stuck on this one:

I want to add a second fetch for a remote.

My desired config looks like this:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = [email protected]:ManageIQ/manageiq.git
	fetch = +refs/heads/*:refs/remotes/origin/*
	fetch = +refs/pull/*:refs/prs/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

In order to achieve this, I need to first read the config looking for the fetches, but I get the following which doesn't show the first fetch:

Rugged::Repository.new(my_path).config.get("remote.origin.fetch")
=> "+refs/pull/*:refs/prs/*"

I can work around this with:

Rugged::Repository.new(my_path).remotes.first.fetch_refspecs
=> ["+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/prs/*"]

I can achieve this on the command line with

$ git config --get-all "remote.origin.fetch"
+refs/heads/*:refs/remotes/origin/*
+refs/pull/*:refs/prs/*

Then I want to add the second ref and store it if it doesn't already exist, but store and []= blow up with:

Rugged::Repository.new(my_path).config.store("remote.origin.fetch", "+refs/pull/*:refs/prs/*")
Rugged::ConfigError: multivar incompatible with simple set

I can achieve this on the command line with:

git config --add remote.origin.fetch +refs/pull/*:refs/prs/*

Is there another way to store this in the config?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions