Skip to content

Commit d0bfd02

Browse files
author
Junio C Hamano
committed
Add basic infrastructure to assign attributes to paths
This adds the basic infrastructure to assign attributes to paths, in a way similar to what the exclusion mechanism does based on $GIT_DIR/info/exclude and .gitignore files. An attribute is just a simple string that does not contain any whitespace. They can be specified in $GIT_DIR/info/attributes file, and .gitattributes file in each directory. Each line in these files defines a pattern matching rule. Similar to the exclusion mechanism, a later match overrides an earlier match in the same file, and entries from .gitattributes file in the same directory takes precedence over the ones from parent directories. Lines in $GIT_DIR/info/attributes file are used as the lowest precedence default rules. A line is either a comment (an empty line, or a line that begins with a '#'), or a rule, which is a whitespace separated list of tokens. The first token on the line is a shell glob pattern. The rest are names of attributes, each of which can optionally be prefixed with '!'. Such a line means "if a path matches this glob, this attribute is set (or unset -- if the attribute name is prefixed with '!'). For glob matching, the same "if the pattern does not have a slash in it, the basename of the path is matched with fnmatch(3) against the pattern, otherwise, the path is matched with the pattern with FNM_PATHNAME" rule as the exclusion mechanism is used. This does not define what an attribute means. Tying an attribute to various effects it has on git operation for paths that have it will be specified separately. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent edb4fd7 commit d0bfd02

File tree

8 files changed

+453
-2
lines changed

8 files changed

+453
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git-blame
1616
git-branch
1717
git-bundle
1818
git-cat-file
19+
git-check-attr
1920
git-check-ref-format
2021
git-checkout
2122
git-checkout-index

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ LIB_H = \
283283
diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
284284
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
285285
tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
286-
utf8.h reflog-walk.h patch-ids.h
286+
utf8.h reflog-walk.h attr.h
287287

288288
DIFF_OBJS = \
289289
diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -305,7 +305,7 @@ LIB_OBJS = \
305305
write_or_die.o trace.o list-objects.o grep.o match-trees.o \
306306
alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
307307
color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
308-
convert.o
308+
convert.o attr.o
309309

310310
BUILTIN_OBJS = \
311311
builtin-add.o \
@@ -316,6 +316,7 @@ BUILTIN_OBJS = \
316316
builtin-branch.o \
317317
builtin-bundle.o \
318318
builtin-cat-file.o \
319+
builtin-check-attr.o \
319320
builtin-checkout-index.o \
320321
builtin-check-ref-format.o \
321322
builtin-commit-tree.o \

0 commit comments

Comments
 (0)