Skip to content

Commit f0a462e

Browse files
committed
Merge branch 'tb/precompose-getcwd'
We forgot to normalize the result of getcwd() to NFC on macOS where all other paths are normalized, which has been corrected. This still does not address the case where core.precomposeUnicode configuration is not defined globally. * tb/precompose-getcwd: macOS: ls-files path fails if path of workdir is NFD
2 parents ffa47b7 + 71fa8d2 commit f0a462e

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int abspath_part_inside_repo(char *path)
4949
size_t wtlen;
5050
char *path0;
5151
int off;
52-
const char *work_tree = get_git_work_tree();
52+
const char *work_tree = precompose_string_if_needed(get_git_work_tree());
5353
struct strbuf realpath = STRBUF_INIT;
5454

5555
if (!work_tree)

t/t3910-mac-os-precompose.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #50 Byte
3737
Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte
3838
Alongc=$Alongc$AEligatu$AEligatu #254 Byte
3939

40+
41+
ls_files_nfc_nfd () {
42+
test_when_finished "git config --global --unset core.precomposeunicode" &&
43+
prglbl=$1
44+
prlocl=$2
45+
aumlcreat=$3
46+
aumllist=$4
47+
git config --global core.precomposeunicode $prglbl &&
48+
(
49+
rm -rf .git &&
50+
mkdir -p "somewhere/$prglbl/$prlocl/$aumlcreat" &&
51+
mypwd=$PWD &&
52+
cd "somewhere/$prglbl/$prlocl/$aumlcreat" &&
53+
git init &&
54+
git config core.precomposeunicode $prlocl &&
55+
git --literal-pathspecs ls-files "$mypwd/somewhere/$prglbl/$prlocl/$aumllist" 2>err &&
56+
>expected &&
57+
test_cmp expected err
58+
)
59+
}
60+
4061
test_expect_success "detect if nfd needed" '
4162
precomposeunicode=$(git config core.precomposeunicode) &&
4263
test "$precomposeunicode" = true &&
@@ -211,13 +232,29 @@ test_expect_success "unicode decomposed: git restore -p . " '
211232
'
212233

213234
# Test if the global core.precomposeunicode stops autosensing
214-
# Must be the last test case
215235
test_expect_success "respect git config --global core.precomposeunicode" '
236+
test_when_finished "git config --global --unset core.precomposeunicode" &&
216237
git config --global core.precomposeunicode true &&
217238
rm -rf .git &&
218239
git init &&
219240
precomposeunicode=$(git config core.precomposeunicode) &&
220241
test "$precomposeunicode" = "true"
221242
'
222243

244+
test_expect_success "ls-files false false nfd nfd" '
245+
ls_files_nfc_nfd false false $Adiarnfd $Adiarnfd
246+
'
247+
248+
test_expect_success "ls-files false true nfd nfd" '
249+
ls_files_nfc_nfd false true $Adiarnfd $Adiarnfd
250+
'
251+
252+
test_expect_success "ls-files true false nfd nfd" '
253+
ls_files_nfc_nfd true false $Adiarnfd $Adiarnfd
254+
'
255+
256+
test_expect_success "ls-files true true nfd nfd" '
257+
ls_files_nfc_nfd true true $Adiarnfd $Adiarnfd
258+
'
259+
223260
test_done

0 commit comments

Comments
 (0)