Skip to content

Commit 79010d0

Browse files
committed
Merge pull request libgit2#3015 from ethomson/maint/v0.22
Additional backports
2 parents 53fc54d + 1f25fe9 commit 79010d0

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

src/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static int checkout_verify_paths(
11901190

11911191
if (action & ~CHECKOUT_ACTION__REMOVE) {
11921192
if (!git_path_isvalid(repo, delta->new_file.path, flags)) {
1193-
giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->old_file.path);
1193+
giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->new_file.path);
11941194
return -1;
11951195
}
11961196
}

src/repository.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ const char *git_repository__8dot3_name(git_repository *repo)
808808

809809
/* We anticipate the 8.3 name is "GIT~1", so use a static for
810810
* easy testing in the common case */
811-
if (strcasecmp(repo->name_8dot3, git_repository__8dot3_default) == 0)
811+
if (repo->name_8dot3 &&
812+
strcasecmp(repo->name_8dot3, git_repository__8dot3_default) == 0)
812813
repo->has_8dot3_default = 1;
813814
}
814815
#endif

tests/checkout/nasty.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ void test_checkout_nasty__git_tilde1(void)
217217
void test_checkout_nasty__git_custom_shortname(void)
218218
{
219219
#ifdef GIT_WIN32
220+
if (!cl_sandbox_supports_8dot3())
221+
clar__skip();
222+
220223
cl_must_pass(p_rename("nasty/.git", "nasty/_temp"));
221224
cl_git_write2file("nasty/git~1", "", 0, O_RDWR|O_CREAT, 0666);
222225
cl_must_pass(p_rename("nasty/_temp", "nasty/.git"));

tests/clar_libgit2.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,25 @@ void cl_sandbox_set_search_path_defaults(void)
533533
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, sandbox_path);
534534
}
535535

536+
#ifdef GIT_WIN32
537+
bool cl_sandbox_supports_8dot3(void)
538+
{
539+
git_buf longpath = GIT_BUF_INIT;
540+
char *shortname;
541+
bool supported;
542+
543+
cl_git_pass(
544+
git_buf_joinpath(&longpath, clar_sandbox_path(), "longer_than_8dot3"));
545+
546+
cl_git_write2file(longpath.ptr, "", 0, O_RDWR|O_CREAT, 0666);
547+
shortname = git_win32_path_8dot3_name(longpath.ptr);
548+
549+
supported = (shortname != NULL);
550+
551+
git__free(shortname);
552+
git_buf_free(&longpath);
553+
554+
return supported;
555+
}
556+
#endif
557+

tests/clar_libgit2.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ void cl_fake_home_cleanup(void *);
160160

161161
void cl_sandbox_set_search_path_defaults(void);
162162

163+
#ifdef GIT_WIN32
164+
bool cl_sandbox_supports_8dot3(void);
165+
#endif
166+
163167
#endif

tests/path/win32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ void test_path_win32__8dot3_name(void)
194194
#ifdef GIT_WIN32
195195
char *shortname;
196196

197+
if (!cl_sandbox_supports_8dot3())
198+
clar__skip();
199+
197200
/* Some guaranteed short names */
198201
cl_assert_equal_s("PROGRA~1", (shortname = git_win32_path_8dot3_name("C:\\Program Files")));
199202
git__free(shortname);

0 commit comments

Comments
 (0)