summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f84f9d2)
raw | patch | inline | side by side (parent: f84f9d2)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 24 May 2006 17:51:11 +0000 (19:51 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Wed, 24 May 2006 17:51:11 +0000 (19:51 +0200) |
Test it by storing i18n.commitencoding, soon to be uesd.
tig.c | patch | blob | history |
index 8c10ba58c4d1c23d791d95f75be2f05c26a69221..cdb20aeee5fd6f5d70ebb591c16f26f3d4c6fba0 100644 (file)
--- a/tig.c
+++ b/tig.c
static int opt_tab_size = TABSIZE;
static enum request opt_request = REQ_VIEW_MAIN;
static char opt_cmd[SIZEOF_CMD] = "";
+static char opt_encoding[20] = "UTF-8";
static FILE *opt_pipe = NULL;
/* Returns the index of log or diff command or -1 to exit. */
return OK;
}
+static int
+load_config(void)
+{
+ FILE *pipe = popen("git repo-config --list", "r");
+ char buffer[BUFSIZ];
+ char *name;
+
+ if (!pipe)
+ return ERR;
+
+ while ((name = fgets(buffer, sizeof(buffer), pipe))) {
+ char *value = strchr(name, '=');
+ int valuelen, namelen;
+
+ /* No boolean options, yet */
+ if (!value)
+ continue;
+
+ namelen = value - name;
+
+ *value++ = 0;
+ valuelen = strlen(value);
+ if (valuelen > 0)
+ value[valuelen - 1] = 0;
+
+ if (!strcmp(name, "i18n.commitencoding")) {
+ string_copy(opt_encoding, value);
+ }
+ }
+
+ if (ferror(pipe))
+ return ERR;
+
+ pclose(pipe);
+
+ return OK;
+}
+
/*
* Main
*/
if (refs_size == 0 && opt_request != REQ_VIEW_PAGER)
die("Not a git repository");
+ if (load_config() == ERR)
+ die("Failed to load repo config.");
+
for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
view->cmd_env = getenv(view->cmd_env);