fork of go-git with some jj specific features

examples: add config example. Fixes #523

* previously an example existed for working with `config.Config`, but changes in implementation made the example not usable. (see #75)
* this mostly puts back the original example with some modifications to
make it work with current implementation

authored by Christian Miller and committed by Paulo Gomes 6f5cab2f b83447a4

Changed files
+40
_examples
config
+40
_examples/config/main.go
··· 1 + package main 2 + 3 + import ( 4 + "github.com/go-git/go-git/v5" 5 + . "github.com/go-git/go-git/v5/_examples" 6 + 7 + "github.com/go-git/go-git/v5/config" 8 + ) 9 + 10 + // Example of how to: 11 + // - Access basic local (i.e. ./.git/config) configuration params 12 + // - Set basic local config params 13 + 14 + func main() { 15 + Info("git init") 16 + r, err := git.PlainInit(".", false) 17 + CheckIfError(err) 18 + 19 + // Load the configuration 20 + cfg, err := r.Config() 21 + CheckIfError(err) 22 + 23 + Info("worktree is %s", cfg.Core.Worktree) 24 + 25 + // Set basic local config params 26 + cfg.Remotes["origin"] = &config.RemoteConfig{ 27 + Name: "origin", 28 + URLs: []string{"https://github.com/git-fixtures/basic.git"}, 29 + } 30 + 31 + Info("origin remote: %+v", cfg.Remotes["origin"]) 32 + 33 + cfg.User.Name = "Local name" 34 + 35 + Info("custom.name is %s", cfg.User.Name) 36 + 37 + // In order to save the config file, you need to call SetConfig 38 + // After calling this go to .git/config and see the custom.name added and the changes to the remote 39 + r.Storer.SetConfig(cfg) 40 + }