Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
97fade4f
Commit
97fade4f
authored
Feb 08, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs_path: use new mktmp to query unicode support
parent
53063e77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
src/fs_path.c
+20
-17
No files found.
src/fs_path.c
View file @
97fade4f
...
@@ -1040,8 +1040,8 @@ fail:
...
@@ -1040,8 +1040,8 @@ fail:
return
-
1
;
return
-
1
;
}
}
static
const
char
*
nfc_file
=
"
\xC3\x85\x73\x74\x72\xC3\xB6\x6D
.XXXXXX
"
;
static
const
char
*
nfc_file
=
"
\xC3\x85\x73\x74\x72\xC3\xB6\x6D
"
;
static
const
char
*
nfd_file
=
"
\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D
.XXXXXX
"
;
static
const
char
*
nfd_file
=
"
\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D
"
;
/* Check if the platform is decomposing unicode data for us. We will
/* Check if the platform is decomposing unicode data for us. We will
* emulate core Git and prefer to use precomposed unicode data internally
* emulate core Git and prefer to use precomposed unicode data internally
...
@@ -1054,39 +1054,42 @@ static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
...
@@ -1054,39 +1054,42 @@ static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
*/
*/
bool
git_fs_path_does_decompose_unicode
(
const
char
*
root
)
bool
git_fs_path_does_decompose_unicode
(
const
char
*
root
)
{
{
git_str
path
=
GIT_STR_INIT
;
git_str
nfc_path
=
GIT_STR_INIT
;
git_str
nfd_path
=
GIT_STR_INIT
;
int
fd
;
int
fd
;
bool
found_decomposed
=
false
;
bool
found_decomposed
=
false
;
char
tmp
[
6
];
size_t
orig_len
;
const
char
*
trailer
;
/* Create a file using a precomposed path and then try to find it
/* Create a file using a precomposed path and then try to find it
* using the decomposed name. If the lookup fails, then we will mark
* using the decomposed name. If the lookup fails, then we will mark
* that we should precompose unicode for this repository.
* that we should precompose unicode for this repository.
*/
*/
if
(
git_str_joinpath
(
&
path
,
root
,
nfc_file
)
<
0
||
if
(
git_str_joinpath
(
&
nfc_path
,
root
,
nfc_file
)
<
0
)
(
fd
=
p_mkstemp
(
path
.
ptr
))
<
0
)
goto
done
;
/* record original path length before trailer */
orig_len
=
nfc_path
.
size
;
if
((
fd
=
git_futils_mktmp
(
&
nfc_path
,
nfc_path
.
ptr
,
0666
))
<
0
)
goto
done
;
goto
done
;
p_close
(
fd
);
p_close
(
fd
);
/* record trailing digits generated by mkstemp */
trailer
=
nfc_path
.
ptr
+
orig_len
;
memcpy
(
tmp
,
path
.
ptr
+
path
.
size
-
sizeof
(
tmp
),
sizeof
(
tmp
));
/* try to look up as NFD path */
/* try to look up as NFD path */
if
(
git_str_joinpath
(
&
path
,
root
,
nfd_file
)
<
0
)
if
(
git_str_joinpath
(
&
nfd_path
,
root
,
nfd_file
)
<
0
||
git_str_puts
(
&
nfd_path
,
trailer
)
<
0
)
goto
done
;
goto
done
;
memcpy
(
path
.
ptr
+
path
.
size
-
sizeof
(
tmp
),
tmp
,
sizeof
(
tmp
));
found_decomposed
=
git_fs_path_exists
(
path
.
ptr
);
found_decomposed
=
git_fs_path_exists
(
nfd_
path
.
ptr
);
/* remove temporary file (using original precomposed path) */
/* remove temporary file (using original precomposed path) */
if
(
git_str_joinpath
(
&
path
,
root
,
nfc_file
)
<
0
)
(
void
)
p_unlink
(
nfc_path
.
ptr
);
goto
done
;
memcpy
(
path
.
ptr
+
path
.
size
-
sizeof
(
tmp
),
tmp
,
sizeof
(
tmp
));
(
void
)
p_unlink
(
path
.
ptr
);
done:
done:
git_str_dispose
(
&
path
);
git_str_dispose
(
&
nfc_path
);
git_str_dispose
(
&
nfd_path
);
return
found_decomposed
;
return
found_decomposed
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment