summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-04-16 21:33:31 -0700
committerJunio C Hamano <junkio@cox.net>2007-04-17 01:04:59 -0700
commit515106fa1335462393c08fa8712dddd767dc147a (patch)
tree4655f5942a377ce8d6fa99ec2c6044071abcac36 /convert.c
parentb568a503def81f49704ba94f5a822d523022102a (diff)
downloadgit-515106fa1335462393c08fa8712dddd767dc147a.tar.gz
Allow more than true/false to attributes.
This allows you to define three values (and possibly more) to each attribute: true, false, and unset. Typically the handlers that notice and act on attribute values treat "unset" attribute to mean "do your default thing" (e.g. crlf that is unset would trigger "guess from contents"), so being able to override a setting to an unset state is actually useful. - If you want to set the attribute value to true, have an entry in .gitattributes file that mentions the attribute name; e.g. *.o binary - If you want to set the attribute value explicitly to false, use '-'; e.g. *.a -diff - If you want to make the attribute value _unset_, perhaps to override an earlier entry, use '!'; e.g. *.a -diff c.i.a !diff This also allows string values to attributes, with the natural syntax: attrname=attrvalue but you cannot use it, as nobody takes notice and acts on it yet. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/convert.c b/convert.c
index d0d4b81871..68bb70f12f 100644
--- a/convert.c
+++ b/convert.c
@@ -225,9 +225,19 @@ static int git_path_check_crlf(const char *path)
setup_crlf_check(&attr_crlf_check);
- if (git_checkattr(path, 1, &attr_crlf_check))
- return -1;
- return attr_crlf_check.isset;
+ if (!git_checkattr(path, 1, &attr_crlf_check)) {
+ void *value = attr_crlf_check.value;
+ if (ATTR_TRUE(value))
+ return 1;
+ else if (ATTR_FALSE(value))
+ return 0;
+ else if (ATTR_UNSET(value))
+ ;
+ else
+ die("unknown value %s given to 'crlf' attribute",
+ (char *)value);
+ }
+ return -1;
}
int convert_to_git(const char *path, char **bufp, unsigned long *sizep)