summaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-06-08 17:16:11 +0200
committerJunio C Hamano <gitster@pobox.com>2008-06-09 15:08:26 -0700
commit2d35d556e27cd3e7f3d2eea04a7f0d7ee8513f8e (patch)
treee2892612e2806116ba0a3a0290d94c1b80bac4b4 /attr.c
parent457bb452919887ff5e8007d02e93f443fdb6f1e9 (diff)
downloadgit-2d35d556e27cd3e7f3d2eea04a7f0d7ee8513f8e.tar.gz
Ignore .gitattributes in bare repositories
Attributes can be specified at three different places: the internal table of default values, the file $GIT_DIR/info/attributes and files named .gitattributes in the work tree. Since bare repositories don't have a work tree, git should ignore any .gitattributes files there. This patch makes git do that, so the only way left for a user to specify attributes in a bare repository is the file info/attributes (in addition to changing the defaults and recompiling). In addition, git-check-attr is now allowed to run without a work tree. Like any user of the code in attr.c, it ignores the .gitattributes files when run in a bare repository. It can still read from info/attributes. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/attr.c b/attr.c
index 1a15fad294..0fb47d3434 100644
--- a/attr.c
+++ b/attr.c
@@ -438,11 +438,13 @@ static void bootstrap_attr_stack(void)
elem->prev = attr_stack;
attr_stack = elem;
- elem = read_attr(GITATTRIBUTES_FILE, 1);
- elem->origin = strdup("");
- elem->prev = attr_stack;
- attr_stack = elem;
- debug_push(elem);
+ if (!is_bare_repository()) {
+ 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)
@@ -501,22 +503,24 @@ static void prepare_attr_stack(const char *path, int dirlen)
/*
* Read from parent directories and push them down
*/
- while (1) {
- char *cp;
-
- len = strlen(attr_stack->origin);
- if (dirlen <= len)
- break;
- memcpy(pathbuf, path, dirlen);
- memcpy(pathbuf + dirlen, "/", 2);
- cp = strchr(pathbuf + len + 1, '/');
- strcpy(cp + 1, GITATTRIBUTES_FILE);
- elem = read_attr(pathbuf, 0);
- *cp = '\0';
- elem->origin = strdup(pathbuf);
- elem->prev = attr_stack;
- attr_stack = elem;
- debug_push(elem);
+ if (!is_bare_repository()) {
+ while (1) {
+ char *cp;
+
+ len = strlen(attr_stack->origin);
+ if (dirlen <= len)
+ break;
+ memcpy(pathbuf, path, dirlen);
+ memcpy(pathbuf + dirlen, "/", 2);
+ cp = strchr(pathbuf + len + 1, '/');
+ strcpy(cp + 1, GITATTRIBUTES_FILE);
+ elem = read_attr(pathbuf, 0);
+ *cp = '\0';
+ elem->origin = strdup(pathbuf);
+ elem->prev = attr_stack;
+ attr_stack = elem;
+ debug_push(elem);
+ }
}
/*