attr: add builtin objectmode values support
Gives all paths builtin objectmode values based on the paths' modes (one of 100644, 100755, 120000, 040000, 160000). Users may use this feature to filter by file types. For example a pathspec such as ':(attr:builtin_objectmode=160000)' could filter for submodules without needing to have `builtin_objectmode=160000` to be set in .gitattributes for every submodule path. These values are also reflected in `git check-attr` results. If the git_attr_direction is set to GIT_ATTR_INDEX or GIT_ATTR_CHECKIN and a path is not found in the index, the value will be unspecified. This patch also reserves the builtin_* attribute namespace for objectmode and any future builtin attributes. Any user defined attributes using this reserved namespace will result in a warning. This is a breaking change for any existing builtin_* attributes. Pathspecs with some builtin_* attribute name (excluding builtin_objectmode) will behave like any attribute where there are no user specified values. Signed-off-by: Joanna Wang <jojwang@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
cfb8a6e9a9
commit
2232a88ab6
@ -295,4 +295,31 @@ test_expect_success 'reading from .gitattributes in a subdirectory (3)' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success POSIXPERM 'pathspec with builtin_objectmode attr can be used' '
|
||||
>mode_exec_file_1 &&
|
||||
|
||||
git status -s ":(attr:builtin_objectmode=100644)mode_exec_*" >actual &&
|
||||
echo ?? mode_exec_file_1 >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git add mode_exec_file_1 &&
|
||||
chmod +x mode_exec_file_1 &&
|
||||
git status -s ":(attr:builtin_objectmode=100755)mode_exec_*" >actual &&
|
||||
echo AM mode_exec_file_1 >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success POSIXPERM 'builtin_objectmode attr can be excluded' '
|
||||
>mode_1_regular &&
|
||||
>mode_1_exec &&
|
||||
chmod +x mode_1_exec &&
|
||||
git status -s ":(exclude,attr:builtin_objectmode=100644)" "mode_1_*" >actual &&
|
||||
echo ?? mode_1_exec >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git status -s ":(exclude,attr:builtin_objectmode=100755)" "mode_1_*" >actual &&
|
||||
echo ?? mode_1_regular >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user