File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ function teardown {
216216 [ " ${lines[1]} " = " $SUPER_SECRET_CONTENT_ENC " ]
217217}
218218
219- @test " contexts: git ls-crypt lists encrypted file for all contexts" {
219+ @test " contexts: git ls-crypt lists encrypted files for all contexts" {
220220 encrypt_named_file sensitive_file " $SECRET_CONTENT "
221221 encrypt_named_file super_sensitive_file " $SECRET_CONTENT " " super-secret"
222222
@@ -226,14 +226,14 @@ function teardown {
226226 [ " ${lines[1]} " = " super_sensitive_file" ]
227227}
228228
229- @test " contexts: git ls-crypt-default lists encrypted file for only 'default' context " {
229+ @test " contexts: git ls-crypt-default lists encrypted files for all contexts " {
230230 encrypt_named_file sensitive_file " $SECRET_CONTENT "
231231 encrypt_named_file super_sensitive_file " $SECRET_CONTENT " " super-secret"
232232
233233 run git ls-crypt-default
234234 [ " $status " -eq 0 ]
235235 [ " ${lines[0]} " = " sensitive_file" ]
236- [ " ${lines[1]} " = " " ]
236+ [ " ${lines[1]} " = " super_sensitive_file " ]
237237}
238238
239239@test " contexts: git ls-crypt-super-secret lists encrypted file for only 'super-secret' context" {
Original file line number Diff line number Diff line change @@ -167,6 +167,8 @@ derive_context_config_group() {
167167# characters. We must avoid quoting of filenames to support names containing
168168# double quotes. #173
169169_list_encrypted_files () {
170+ local strict_context=${1:- }
171+
170172 IFS=$' \n '
171173 # List files with -z option to disable quoting of filenames, then
172174 # immediately convert NUL-delimited filenames to be newline-delimited to be
@@ -176,8 +178,13 @@ _list_encrypted_files() {
176178 local check
177179 check=$( git check-attr filter " $file " 2> /dev/null)
178180
179- # Only output names of encrypted files
180- if [[ " $check " == * " crypt${CONTEXT_CRYPT_SUFFIX:- } " ]]; then
181+ # Only output names of encrypted files matching the context, either
182+ # strictly (if $1 = "true") or loosely (if $1 is false or unset)
183+ if [[ " $strict_context " == " true" ]] && \
184+ [[ " $check " == " ${file} : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } " ]]
185+ then
186+ echo " $file "
187+ elif [[ " $check " == " ${file} : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } " * ]]; then
181188 echo " $file "
182189 fi
183190 done
@@ -986,7 +993,7 @@ upgrade_transcrypt() {
986993list_files () {
987994 if [[ $IS_BARE == ' false' ]]; then
988995 cd " $REPO " > /dev/null || die 1 ' could not change into the "%s" directory' " $REPO "
989- _list_encrypted_files
996+ _list_encrypted_files true
990997 fi
991998}
992999
You can’t perform that action at this time.
0 commit comments