mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.1219: symlink not followed if dirname ends in //
Problem: Symlink not followed if dirname ends in //. Solution: Resolve symlink earlier. (Tomáš Janoušek, closes #6454)
This commit is contained in:
parent
3d48e25dcb
commit
5966ea105e
@ -3287,10 +3287,12 @@ ml_append_buf(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replace line lnum, with buffering, in current buffer.
|
* Replace line "lnum", with buffering, in current buffer.
|
||||||
*
|
*
|
||||||
* If "copy" is TRUE, make a copy of the line, otherwise the line has been
|
* If "copy" is TRUE, make a copy of the line, otherwise the line has been
|
||||||
* copied to allocated memory already.
|
* copied to allocated memory already.
|
||||||
|
* If "copy" is FALSE the "line" may be freed to add text properties!
|
||||||
|
* Do not use it after calling ml_replace().
|
||||||
*
|
*
|
||||||
* Check: The caller of this function should probably also call
|
* Check: The caller of this function should probably also call
|
||||||
* changed_lines(), unless update_screen(NOT_VALID) is used.
|
* changed_lines(), unless update_screen(NOT_VALID) is used.
|
||||||
@ -4366,6 +4368,11 @@ makeswapname(
|
|||||||
char_u *fname_res = fname;
|
char_u *fname_res = fname;
|
||||||
#ifdef HAVE_READLINK
|
#ifdef HAVE_READLINK
|
||||||
char_u fname_buf[MAXPATHL];
|
char_u fname_buf[MAXPATHL];
|
||||||
|
|
||||||
|
// Expand symlink in the file name, so that we put the swap file with the
|
||||||
|
// actual file instead of with the symlink.
|
||||||
|
if (resolve_symlink(fname, fname_buf) == OK)
|
||||||
|
fname_res = fname_buf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UNIX) || defined(MSWIN) // Need _very_ long file names
|
#if defined(UNIX) || defined(MSWIN) // Need _very_ long file names
|
||||||
@ -4375,7 +4382,7 @@ makeswapname(
|
|||||||
if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2])
|
if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2])
|
||||||
{ // Ends with '//', Use Full path
|
{ // Ends with '//', Use Full path
|
||||||
r = NULL;
|
r = NULL;
|
||||||
if ((s = make_percent_swname(dir_name, fname)) != NULL)
|
if ((s = make_percent_swname(dir_name, fname_res)) != NULL)
|
||||||
{
|
{
|
||||||
r = modname(s, (char_u *)".swp", FALSE);
|
r = modname(s, (char_u *)".swp", FALSE);
|
||||||
vim_free(s);
|
vim_free(s);
|
||||||
@ -4384,13 +4391,6 @@ makeswapname(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_READLINK
|
|
||||||
// Expand symlink in the file name, so that we put the swap file with the
|
|
||||||
// actual file instead of with the symlink.
|
|
||||||
if (resolve_symlink(fname, fname_buf) == OK)
|
|
||||||
fname_res = fname_buf;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
r = buf_modname(
|
r = buf_modname(
|
||||||
(buf->b_p_sn || buf->b_shortname),
|
(buf->b_p_sn || buf->b_shortname),
|
||||||
fname_res,
|
fname_res,
|
||||||
|
@ -377,4 +377,34 @@ func Test_swap_prompt_splitwin()
|
|||||||
call delete('Xfile1')
|
call delete('Xfile1')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_swap_symlink()
|
||||||
|
if !has("unix")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call writefile(['text'], 'Xtestfile')
|
||||||
|
silent !ln -s -f Xtestfile Xtestlink
|
||||||
|
|
||||||
|
set dir=.
|
||||||
|
|
||||||
|
" Test that swap file uses the name of the file when editing through a
|
||||||
|
" symbolic link (so that editing the file twice is detected)
|
||||||
|
edit Xtestlink
|
||||||
|
call assert_match('Xtestfile\.swp$', s:swapname())
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call mkdir('Xswapdir')
|
||||||
|
exe 'set dir=' . getcwd() . '/Xswapdir//'
|
||||||
|
|
||||||
|
" Check that this also works when 'directory' ends with '//'
|
||||||
|
edit Xtestlink
|
||||||
|
call assert_match('Xtestfile\.swp$', s:swapname())
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
set dir&
|
||||||
|
call delete('Xtestfile')
|
||||||
|
call delete('Xtestlink')
|
||||||
|
call delete('Xswapdir', 'rf')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1219,
|
||||||
/**/
|
/**/
|
||||||
1218,
|
1218,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user