summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d42453a)
raw | patch | inline | side by side (parent: d42453a)
author | Michael Haggerty <mhagger@alum.mit.edu> | |
Thu, 4 Aug 2011 04:36:14 +0000 (06:36 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 4 Aug 2011 22:53:15 +0000 (15:53 -0700) |
Previously, it was possible to have a line like "file.txt =foo" in a
.gitattribute file, after which an invocation like "git check-attr ''
-- file.txt" would succeed. This patch disallows both constructs.
Please note that any existing .gitattributes file that tries to set an
empty attribute will now trigger the error message "error: : not a
valid attribute name" whereas previously the nonsense was allowed
through.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.gitattribute file, after which an invocation like "git check-attr ''
-- file.txt" would succeed. This patch disallows both constructs.
Please note that any existing .gitattributes file that tries to set an
empty attribute will now trigger the error message "error: : not a
valid attribute name" whereas previously the nonsense was allowed
through.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr.c | patch | blob | history | |
t/t0003-attributes.sh | patch | blob | history |
index 4a1244f9a9b7ec30df5dcfee5257ea22d708fa78..b1d1d6d791687afc98e273db983b8f8727fcd424 100644 (file)
--- a/attr.c
+++ b/attr.c
* Attribute name cannot begin with '-' and must consist of
* characters from [-A-Za-z0-9_.].
*/
- if (*name == '-')
+ if (namelen <= 0 || *name == '-')
return -1;
while (namelen--) {
char ch = *name++;
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index ebbc7554a7d4dce4c2ed33a79f5d4feb3a520f05..8c76b79bb0b9c188763c62824bb9db085cdfa98a 100755 (executable)
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
'
+test_expect_success 'command line checks' '
+
+ test_must_fail git check-attr "" -- f
+
+'
+
test_expect_success 'attribute test' '
attr_check f f &&