2 * GIT - The information manager from hell
4 * Copyright (C) Eric Biederman, 2005
9 static const char var_usage[] = "git var [-l | <variable>]";
11 static const char *editor(int flag)
13 const char *pgm = git_editor();
15 if (!pgm && flag & IDENT_ERROR_ON_NO_NAME)
16 die("Terminal is dumb, but EDITOR unset");
21 static const char *pager(int flag)
23 const char *pgm = git_pager();
32 const char *(*read)(int);
34 static struct git_var git_vars[] = {
35 { "GIT_COMMITTER_IDENT", git_committer_info },
36 { "GIT_AUTHOR_IDENT", git_author_info },
37 { "GIT_EDITOR", editor },
38 { "GIT_PAGER", pager },
42 static void list_vars(void)
47 for (ptr = git_vars; ptr->read; ptr++)
48 if ((val = ptr->read(0)))
49 printf("%s=%s\n", ptr->name, val);
52 static const char *read_var(const char *var)
57 for (ptr = git_vars; ptr->read; ptr++) {
58 if (strcmp(var, ptr->name) == 0) {
59 val = ptr->read(IDENT_ERROR_ON_NO_NAME);
66 static int show_config(const char *var, const char *value, void *cb)
69 printf("%s=%s\n", var, value);
72 return git_default_config(var, value, cb);
75 int main(int argc, char **argv)
83 git_extract_argv0_path(argv[0]);
85 setup_git_directory_gently(&nongit);
88 if (strcmp(argv[1], "-l") == 0) {
89 git_config(show_config, NULL);
93 git_config(git_default_config, NULL);
94 val = read_var(argv[1]);