summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-01-10 12:27:37 -0800
committerJunio C Hamano <gitster@pobox.com>2012-01-10 12:27:37 -0800
commit909ca7b9ac11711478aaa5dd4ab17a0d1dabe075 (patch)
tree788e8cd4b6c513722457199c40bea9e4ac2f2a76
parent77f7f822889411bfede0507dd60aebf11edb2849 (diff)
downloadgit-909ca7b9ac11711478aaa5dd4ab17a0d1dabe075.tar.gz
attr.c: make bootstrap_attr_stack() leave early
Thas would de-dent the body of a function that has grown rather large over time, making it a bit easier to read. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--attr.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/attr.c b/attr.c
index ad7eb9cd31..a6e6523d29 100644
--- a/attr.c
+++ b/attr.c
@@ -488,48 +488,49 @@ static int git_attr_config(const char *var, const char *value, void *dummy)
static void bootstrap_attr_stack(void)
{
- if (!attr_stack) {
- struct attr_stack *elem;
+ struct attr_stack *elem;
- elem = read_attr_from_array(builtin_attr);
- elem->origin = NULL;
- elem->prev = attr_stack;
- attr_stack = elem;
+ if (attr_stack)
+ return;
- if (git_attr_system()) {
- elem = read_attr_from_file(git_etc_gitattributes(), 1);
- if (elem) {
- elem->origin = NULL;
- elem->prev = attr_stack;
- attr_stack = elem;
- }
- }
+ elem = read_attr_from_array(builtin_attr);
+ elem->origin = NULL;
+ elem->prev = attr_stack;
+ attr_stack = elem;
- git_config(git_attr_config, NULL);
- if (attributes_file) {
- elem = read_attr_from_file(attributes_file, 1);
- if (elem) {
- elem->origin = NULL;
- elem->prev = attr_stack;
- attr_stack = elem;
- }
+ if (git_attr_system()) {
+ elem = read_attr_from_file(git_etc_gitattributes(), 1);
+ if (elem) {
+ elem->origin = NULL;
+ elem->prev = attr_stack;
+ attr_stack = elem;
}
+ }
- if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
- elem = read_attr(GITATTRIBUTES_FILE, 1);
- elem->origin = strdup("");
+ git_config(git_attr_config, NULL);
+ if (attributes_file) {
+ elem = read_attr_from_file(attributes_file, 1);
+ if (elem) {
+ elem->origin = NULL;
elem->prev = attr_stack;
attr_stack = elem;
- debug_push(elem);
}
+ }
- elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
- if (!elem)
- elem = xcalloc(1, sizeof(*elem));
- elem->origin = NULL;
+ if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
+ elem = read_attr(GITATTRIBUTES_FILE, 1);
+ elem->origin = strdup("");
elem->prev = attr_stack;
attr_stack = elem;
+ debug_push(elem);
}
+
+ elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
+ if (!elem)
+ elem = xcalloc(1, sizeof(*elem));
+ elem->origin = NULL;
+ elem->prev = attr_stack;
+ attr_stack = elem;
}
static void prepare_attr_stack(const char *path, int dirlen)