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
9dcc4a36
Commit
9dcc4a36
authored
Jan 28, 2015
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test failures when 8.3 is disabled
parent
1ac5acdc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
src/repository.c
+1
-1
tests/checkout/nasty.c
+23
-1
tests/path/win32.c
+17
-3
No files found.
src/repository.c
View file @
9dcc4a36
...
...
@@ -808,7 +808,7 @@ const char *git_repository__8dot3_name(git_repository *repo)
/* We anticipate the 8.3 name is "GIT~1", so use a static for
* easy testing in the common case */
if
(
strcasecmp
(
repo
->
name_8dot3
,
git_repository__8dot3_default
)
==
0
)
if
(
repo
->
name_8dot3
&&
strcasecmp
(
repo
->
name_8dot3
,
git_repository__8dot3_default
)
==
0
)
repo
->
has_8dot3_default
=
1
;
}
#endif
...
...
tests/checkout/nasty.c
View file @
9dcc4a36
...
...
@@ -10,6 +10,25 @@ static const char *repo_name = "nasty";
static
git_repository
*
repo
;
static
git_checkout_options
checkout_opts
;
#ifdef GIT_WIN32
static
bool
is_8dot3_disabled
(
void
)
{
#define IS_8DOT3_BUF_SIZE (MAX_PATH + 20)
char
src
[
IS_8DOT3_BUF_SIZE
];
wchar_t
dest
[
IS_8DOT3_BUF_SIZE
],
shortPath
[
IS_8DOT3_BUF_SIZE
];
FILE
*
fp
;
strcpy_s
(
src
,
IS_8DOT3_BUF_SIZE
,
clar_sandbox_path
());
strcat_s
(
src
,
IS_8DOT3_BUF_SIZE
,
"/longer_than_8dot3"
);
git__utf8_to_16
(
dest
,
IS_8DOT3_BUF_SIZE
,
src
);
fp
=
_wfopen
(
dest
,
L"w"
);
cl_assert
(
fp
);
fclose
(
fp
);
cl_assert
(
GetShortPathNameW
(
dest
,
shortPath
,
IS_8DOT3_BUF_SIZE
)
>
0
);
DeleteFileW
(
dest
);
return
!
wcscmp
(
dest
,
shortPath
);
}
#endif
void
test_checkout_nasty__initialize
(
void
)
{
repo
=
cl_git_sandbox_init
(
repo_name
);
...
...
@@ -220,7 +239,10 @@ void test_checkout_nasty__git_custom_shortname(void)
cl_must_pass
(
p_rename
(
"nasty/.git"
,
"nasty/_temp"
));
cl_git_write2file
(
"nasty/git~1"
,
""
,
0
,
O_RDWR
|
O_CREAT
,
0666
);
cl_must_pass
(
p_rename
(
"nasty/_temp"
,
"nasty/.git"
));
test_checkout_fails
(
"refs/heads/git_tilde2"
,
".git/foobar"
);
if
(
is_8dot3_disabled
())
test_checkout_passes
(
"refs/heads/git_tilde2"
,
".git/foobar"
);
else
test_checkout_fails
(
"refs/heads/git_tilde2"
,
".git/foobar"
);
#endif
}
...
...
tests/path/win32.c
View file @
9dcc4a36
...
...
@@ -4,6 +4,18 @@
#ifdef GIT_WIN32
#include "win32/path_w32.h"
static
bool
is_8dot3_disabled
(
void
)
{
wchar_t
shortPath
[
MAX_PATH
];
wchar_t
*
dest
=
L"longer_than_8dot3"
;
FILE
*
fp
=
_wfopen
(
dest
,
L"w"
);
cl_assert
(
fp
);
fclose
(
fp
);
cl_assert
(
GetShortPathNameW
(
dest
,
shortPath
,
MAX_PATH
)
>
0
);
DeleteFileW
(
dest
);
return
!
wcscmp
(
dest
,
shortPath
);
}
#endif
void
test_utf8_to_utf16
(
const
char
*
utf8_in
,
const
wchar_t
*
utf16_expected
)
...
...
@@ -193,9 +205,11 @@ void test_path_win32__8dot3_name(void)
{
#ifdef GIT_WIN32
char
*
shortname
;
bool
disable8dot3
=
is_8dot3_disabled
();
/* Some guaranteed short names */
cl_assert_equal_s
(
"PROGRA~1"
,
(
shortname
=
git_win32_path_8dot3_name
(
"C:
\\
Program Files"
)));
shortname
=
git_win32_path_8dot3_name
(
"C:
\\
Program Files"
);
cl_assert
(
!
shortname
||
!
strcmp
(
shortname
,
"PROGRA~1"
));
// null when 8.3 stripped, otherwise in 8.3 format
git__free
(
shortname
);
cl_assert_equal_s
(
"WINDOWS"
,
(
shortname
=
git_win32_path_8dot3_name
(
"C:
\\
WINDOWS"
)));
...
...
@@ -203,12 +217,12 @@ void test_path_win32__8dot3_name(void)
/* Create some predictible short names */
cl_must_pass
(
p_mkdir
(
".foo"
,
0777
));
cl_assert_equal_s
(
"FOO~1"
,
(
shortname
=
git_win32_path_8dot3_name
(
".foo"
)));
cl_assert_equal_s
(
disable8dot3
?
".foo"
:
"FOO~1"
,
(
shortname
=
git_win32_path_8dot3_name
(
".foo"
)));
git__free
(
shortname
);
cl_git_write2file
(
"bar~1"
,
"foobar
\n
"
,
7
,
O_RDWR
|
O_CREAT
,
0666
);
cl_must_pass
(
p_mkdir
(
".bar"
,
0777
));
cl_assert_equal_s
(
"BAR~2"
,
(
shortname
=
git_win32_path_8dot3_name
(
".bar"
)));
cl_assert_equal_s
(
disable8dot3
?
".bar"
:
"BAR~2"
,
(
shortname
=
git_win32_path_8dot3_name
(
".bar"
)));
git__free
(
shortname
);
#endif
}
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