Skip to content

Commit 15780bb

Browse files
bk2204gitster
authored andcommitted
attr: expose and rename accessor functions
Right now, the functions which determine the current system and global gitattributes files are not exposed. We'd like to use them in a future commit, but they're not ideally named. Rename them to something more suitable as a public interface, expose them, and document them. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdd489e commit 15780bb

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

attr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -870,23 +870,23 @@ static struct attr_stack *read_attr(struct index_state *istate,
870870
return res;
871871
}
872872

873-
static const char *git_etc_gitattributes(void)
873+
const char *git_attr_system_file(void)
874874
{
875875
static const char *system_wide;
876876
if (!system_wide)
877877
system_wide = system_path(ETC_GITATTRIBUTES);
878878
return system_wide;
879879
}
880880

881-
static const char *get_home_gitattributes(void)
881+
const char *git_attr_global_file(void)
882882
{
883883
if (!git_attributes_file)
884884
git_attributes_file = xdg_config_home("attributes");
885885

886886
return git_attributes_file;
887887
}
888888

889-
static int git_attr_system(void)
889+
int git_attr_system_is_enabled(void)
890890
{
891891
return !git_env_bool("GIT_ATTR_NOSYSTEM", 0);
892892
}
@@ -920,14 +920,14 @@ static void bootstrap_attr_stack(struct index_state *istate,
920920
push_stack(stack, e, NULL, 0);
921921

922922
/* system-wide frame */
923-
if (git_attr_system()) {
924-
e = read_attr_from_file(git_etc_gitattributes(), flags);
923+
if (git_attr_system_is_enabled()) {
924+
e = read_attr_from_file(git_attr_system_file(), flags);
925925
push_stack(stack, e, NULL, 0);
926926
}
927927

928928
/* home directory */
929-
if (get_home_gitattributes()) {
930-
e = read_attr_from_file(get_home_gitattributes(), flags);
929+
if (git_attr_global_file()) {
930+
e = read_attr_from_file(git_attr_global_file(), flags);
931931
push_stack(stack, e, NULL, 0);
932932
}
933933

attr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,13 @@ void git_attr_set_direction(enum git_attr_direction new_direction);
227227

228228
void attr_start(void);
229229

230+
/* Return the system gitattributes file. */
231+
const char *git_attr_system_file(void);
232+
233+
/* Return the global gitattributes file, if any. */
234+
const char *git_attr_global_file(void);
235+
236+
/* Return whether the system gitattributes file is enabled and should be used. */
237+
int git_attr_system_is_enabled(void);
238+
230239
#endif /* ATTR_H */

0 commit comments

Comments
 (0)