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>
Junio C Hamano committed
Jan 10, 2012 at 12:27 UTC
909ca7b9ac11711478aaa5dd4ab17a0d1dabe075
1 file changed
+31
-30
attr.c
+31
-30
@@ -488,48 +488,49 @@ static int git_attr_config(const char *var, const char *value, void *dummy)
488
489
static void bootstrap_attr_stack(void)
490
{
491
- if (!attr_stack) {
492
- struct attr_stack *elem;
491
+ struct attr_stack *elem;
492
494
- elem = read_attr_from_array(builtin_attr);
495
- elem->origin = NULL;
496
- elem->prev = attr_stack;
497
- attr_stack = elem;
493
+ if (attr_stack)
494
+ return;
495
499
- if (git_attr_system()) {
500
- elem = read_attr_from_file(git_etc_gitattributes(), 1);
501
- if (elem) {
502
- elem->origin = NULL;
503
- elem->prev = attr_stack;
504
- attr_stack = elem;
505
- }
506
- }
496
+ elem = read_attr_from_array(builtin_attr);
497
+ elem->origin = NULL;
498
+ elem->prev = attr_stack;
499
+ attr_stack = elem;
500
508
- git_config(git_attr_config, NULL);
509
- if (attributes_file) {
510
- elem = read_attr_from_file(attributes_file, 1);
511
- if (elem) {
512
- elem->origin = NULL;
513
- elem->prev = attr_stack;
514
- attr_stack = elem;
515
- }
501
+ if (git_attr_system()) {
502
+ elem = read_attr_from_file(git_etc_gitattributes(), 1);
503
+ if (elem) {
504
+ elem->origin = NULL;
505
+ elem->prev = attr_stack;
506
+ attr_stack = elem;
507
}
508
+ }
509
518
- if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
519
- elem = read_attr(GITATTRIBUTES_FILE, 1);
520
- elem->origin = strdup("");
510
+ git_config(git_attr_config, NULL);
511
+ if (attributes_file) {
512
+ elem = read_attr_from_file(attributes_file, 1);
513
+ if (elem) {
514
+ elem->origin = NULL;
515
elem->prev = attr_stack;
516
attr_stack = elem;
523
- debug_push(elem);
517
}
518
+ }
519
526
- elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
527
- if (!elem)
528
- elem = xcalloc(1, sizeof(*elem));
529
- elem->origin = NULL;
520
+ if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
521
+ elem = read_attr(GITATTRIBUTES_FILE, 1);
522
+ elem->origin = strdup("");
523
elem->prev = attr_stack;
524
attr_stack = elem;
525
+ debug_push(elem);
526
}
527
+
528
+ elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
529
+ if (!elem)
530
+ elem = xcalloc(1, sizeof(*elem));
531
+ elem->origin = NULL;
532
+ elem->prev = attr_stack;
533
+ attr_stack = elem;
534
}
535
536
static void prepare_attr_stack(const char *path, int dirlen)