Class: Rugged::Settings

Inherits:
Object
  • Object
show all
Defined in:
ext/rugged/rugged_settings.c

Class Method Summary collapse

Class Method Details

.[](option) ⇒ Object

Gets the value of a libgit2 library option.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'ext/rugged/rugged_settings.c', line 107

static VALUE rb_git_get_option(VALUE self, VALUE option)
{
	const char *opt;

	Check_Type(option, T_STRING);
	opt = StringValueCStr(option);

	if (strcmp(opt, "mwindow_size") == 0) {
		size_t val;
		git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &val);
		return SIZET2NUM(val);
	}

	else if (strcmp(opt, "mwindow_mapped_limit") == 0) {
		size_t val;
		git_libgit2_opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, &val);
		return SIZET2NUM(val);
	}

	else if (strcmp(opt, "search_path_global") == 0) {
		return get_search_path(GIT_CONFIG_LEVEL_GLOBAL);
	}

	else if (strcmp(opt, "search_path_xdg") == 0) {
		return get_search_path(GIT_CONFIG_LEVEL_XDG);
	}

	else if (strcmp(opt, "search_path_system") == 0) {
		return get_search_path(GIT_CONFIG_LEVEL_SYSTEM);
	}

	else {
		rb_raise(rb_eArgError, "Unknown option specified");
	}
}

.[]=(option) ⇒ Object

Sets a libgit2 library option.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'ext/rugged/rugged_settings.c', line 51

static VALUE rb_git_set_option(VALUE self, VALUE option, VALUE value)
{
	const char *opt;

	Check_Type(option, T_STRING);
	opt = StringValueCStr(option);

	if (strcmp(opt, "mwindow_size") == 0) {
		size_t val;
		Check_Type(value, T_FIXNUM);
		val = NUM2SIZET(value);
		git_libgit2_opts(GIT_OPT_SET_MWINDOW_SIZE, val);
	}

	else if (strcmp(opt, "mwindow_mapped_limit") == 0) {
		size_t val;
		Check_Type(value, T_FIXNUM);
		val = NUM2SIZET(value);
		git_libgit2_opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, val);
	}

	else if (strcmp(opt, "search_path_global") == 0) {
		set_search_path(GIT_CONFIG_LEVEL_GLOBAL, value);
	}

	else if (strcmp(opt, "search_path_xdg") == 0) {
		set_search_path(GIT_CONFIG_LEVEL_XDG, value);
	}

	else if (strcmp(opt, "search_path_system") == 0) {
		set_search_path(GIT_CONFIG_LEVEL_SYSTEM, value);
	}

	else if (strcmp(opt, "strict_object_creation") == 0) {
		int strict = RTEST(value) ? 1 : 0;
		git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, strict);
	}

	else if (strcmp(opt, "fsync_gitdir") == 0) {
		int fsync = RTEST(value) ? 1 : 0;
		git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, fsync);
	}

	else {
		rb_raise(rb_eArgError, "Unknown option specified");
	}

	return Qnil;
}

.Rugged::Settings.max_cache_sizeObject

Returns the maximum amount of memory the cache will consume.



149
150
151
152
153
154
# File 'ext/rugged/rugged_settings.c', line 149

static VALUE rb_git_get_max_cache_size(VALUE mod) {
    size_t val;
    size_t max;
    git_libgit2_opts(GIT_OPT_GET_CACHED_MEMORY, &val, &max);
    return SIZET2NUM(max);
}

.Rugged::Settings.used_cache_sizeObject

Returns the amount of memory the cache is currently consuming.



162
163
164
165
166
167
# File 'ext/rugged/rugged_settings.c', line 162

static VALUE rb_git_get_used_cache_size(VALUE mod) {
    size_t val;
    size_t max;
    git_libgit2_opts(GIT_OPT_GET_CACHED_MEMORY, &val, &max);
    return SIZET2NUM(val);
}