1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.internal.storage.file;
12
13 import java.io.File;
14 import java.io.IOException;
15
16 import org.eclipse.jgit.attributes.AttributesNode;
17 import org.eclipse.jgit.lib.CoreConfig;
18 import org.eclipse.jgit.lib.Repository;
19 import org.eclipse.jgit.util.FS;
20
21
22
23
24 public class GlobalAttributesNode extends AttributesNode {
25 final Repository repository;
26
27
28
29
30
31
32
33 public GlobalAttributesNode(Repository repository) {
34 this.repository = repository;
35 }
36
37
38
39
40
41
42
43 public AttributesNode load() throws IOException {
44 AttributesNode r = new AttributesNode();
45
46 FS fs = repository.getFS();
47 String path = repository.getConfig().get(CoreConfig.KEY)
48 .getAttributesFile();
49 if (path != null) {
50 File attributesFile;
51 if (path.startsWith("~/")) {
52 attributesFile = fs.resolve(fs.userHome(),
53 path.substring(2));
54 } else {
55 attributesFile = fs.resolve(null, path);
56 }
57 FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributesFile);
58 }
59 return r.getRules().isEmpty() ? null : r;
60 }
61 }