summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 39eb860)
raw | patch | inline | side by side (parent: 39eb860)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 9 Feb 2009 00:49:32 +0000 (01:49 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 9 Feb 2009 00:49:32 +0000 (01:49 +0100) |
tig.c | patch | blob | history |
index c9370d04c69a072d9909743bb2ca05ad226822db..b1804aa41e47874a803b818ef9f87067b76cd6b4 100644 (file)
--- a/tig.c
+++ b/tig.c
return run_io_load(ls_remote_argv, "\t", read_ref);
}
+static void
+set_remote_branch(const char *name, const char *value, size_t valuelen)
+{
+ if (!strcmp(name, ".remote")) {
+ string_ncopy(opt_remote, value, valuelen);
+
+ } else if (*opt_remote && !strcmp(name, ".merge")) {
+ size_t from = strlen(opt_remote);
+
+ if (!prefixcmp(value, "refs/heads/"))
+ value += STRING_SIZE("refs/heads/");
+
+ if (!string_format_from(opt_remote, &from, "/%s", value))
+ opt_remote[0] = 0;
+ }
+}
+
static void
set_repo_config_option(char *name, char *value, int (*cmd)(int, const char **))
{
@@ -6711,27 +6728,9 @@ read_repo_config_option(char *name, size_t namelen, char *value, size_t valuelen
else if (!prefixcmp(name, "tig."))
set_repo_config_option(name + 4, value, option_set_command);
- /* branch.<head>.remote */
- if (*opt_head &&
- !strncmp(name, "branch.", 7) &&
- !strncmp(name + 7, opt_head, strlen(opt_head)) &&
- !strcmp(name + 7 + strlen(opt_head), ".remote"))
- string_ncopy(opt_remote, value, valuelen);
-
- if (*opt_head && *opt_remote &&
- !strncmp(name, "branch.", 7) &&
- !strncmp(name + 7, opt_head, strlen(opt_head)) &&
- !strcmp(name + 7 + strlen(opt_head), ".merge")) {
- size_t from = strlen(opt_remote);
-
- if (!prefixcmp(value, "refs/heads/")) {
- value += STRING_SIZE("refs/heads/");
- valuelen -= STRING_SIZE("refs/heads/");
- }
-
- if (!string_format_from(opt_remote, &from, "/%s", value))
- opt_remote[0] = 0;
- }
+ else if (*opt_head && !prefixcmp(name, "branch.") &&
+ !strncmp(name + 7, opt_head, strlen(opt_head)))
+ set_remote_branch(name + 7 + strlen(opt_head), value, valuelen);
return OK;
}