Unable to access string value in config file with ggit_config_get_string
@cedlemo
Submitted by cedlemo Link to original bug (#782593)
Description
I am trying to read a configuration file that looks like:
[user] name = jeanclaude email = jeanclaude@gmx.com [core] excludesfile = gitignore autocrlf = input [alias] unstage = reset HEAD -- last = log -1 HEAD [diff] tool = vimdiff
And it fails with the following message :
Get string failed with get_string called on a live config object
Here is a simple example :
#include <stdio.h> #include "libgit2-glib/ggit.h"
/* pkg-config --libs --cflags libgit2-glib-1.0 */
int main(int argc, char **argv) { const char *file_name = "/home/cedlemo/Projets/Ruby/ggit/test/gitconfig"; GFile *file = NULL; GgitConfig *conf = NULL; GError *error = NULL; const char *val = NULL;
file = g_file_new_for_path (file_name); if(!file) return 1;
ggit_init ();
conf = ggit_config_new_from_file (file, &error); if(error) { printf ("New conf failed with %s\n", error->message); return 1; }
val = ggit_config_get_string (conf, "user.name", &error); if(error) { printf ("Get string failed with %s\n", error->message); return 1; }
printf ("User name is %s\n", val);
g_object_unref (file); return 0; }
Any idea what is wrong ?
Version: git master
Resolution: RESOLVED FIXED