mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
vim-patch:8.2.0272: ":helptags ALL" gives error for some directories
Problem: ":helptags ALL" gives error for directories without write
permission. (Matěj Cepl)
Solution: Ignore errors for ":helptags ALL". (Ken Takata, closes vim/vim#5026,
closes vim/vim#5652)
414b796627
Cherry-pick Test_helptag_cmd() from patch v8.2.0203.
This commit is contained in:
@@ -5248,8 +5248,10 @@ void ex_viusage(exarg_T *eap)
|
||||
/// @param tagname Name of the tags file ("tags" for English, "tags-fr" for
|
||||
/// French)
|
||||
/// @param add_help_tags Whether to add the "help-tags" tag
|
||||
static void helptags_one(char_u *const dir, const char_u *const ext,
|
||||
const char_u *const tagfname, const bool add_help_tags)
|
||||
/// @param ignore_writeerr ignore write error
|
||||
static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
bool add_help_tags, bool ignore_writeerr)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
garray_T ga;
|
||||
int filecount;
|
||||
@@ -5293,7 +5295,9 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
||||
|
||||
FILE *const fd_tags = os_fopen((char *)NameBuff, "w");
|
||||
if (fd_tags == NULL) {
|
||||
EMSG2(_("E152: Cannot open %s for writing"), NameBuff);
|
||||
if (!ignore_writeerr) {
|
||||
EMSG2(_("E152: Cannot open %s for writing"), NameBuff);
|
||||
}
|
||||
FreeWild(filecount, files);
|
||||
return;
|
||||
}
|
||||
@@ -5441,7 +5445,9 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
||||
}
|
||||
|
||||
/// Generate tags in one help directory, taking care of translations.
|
||||
static void do_helptags(char_u *dirname, bool add_help_tags)
|
||||
static void do_helptags(char_u *dirname, bool add_help_tags,
|
||||
bool ignore_writeerr)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int len;
|
||||
garray_T ga;
|
||||
@@ -5523,17 +5529,17 @@ static void do_helptags(char_u *dirname, bool add_help_tags)
|
||||
ext[1] = fname[5];
|
||||
ext[2] = fname[6];
|
||||
}
|
||||
helptags_one(dirname, ext, fname, add_help_tags);
|
||||
helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr);
|
||||
}
|
||||
|
||||
ga_clear(&ga);
|
||||
FreeWild(filecount, files);
|
||||
}
|
||||
|
||||
static void
|
||||
helptags_cb(char_u *fname, void *cookie)
|
||||
static void helptags_cb(char_u *fname, void *cookie)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
do_helptags(fname, *(bool *)cookie);
|
||||
do_helptags(fname, *(bool *)cookie, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5562,7 +5568,7 @@ void ex_helptags(exarg_T *eap)
|
||||
if (dirname == NULL || !os_isdir(dirname)) {
|
||||
EMSG2(_("E150: Not a directory: %s"), eap->arg);
|
||||
} else {
|
||||
do_helptags(dirname, add_help_tags);
|
||||
do_helptags(dirname, add_help_tags, false);
|
||||
}
|
||||
xfree(dirname);
|
||||
}
|
||||
|
@@ -56,3 +56,49 @@ func Test_help_local_additions()
|
||||
call delete('Xruntime', 'rf')
|
||||
let &rtp = rtp_save
|
||||
endfunc
|
||||
|
||||
" Test for the :helptags command
|
||||
func Test_helptag_cmd()
|
||||
call mkdir('Xdir/a/doc', 'p')
|
||||
|
||||
" No help file to process in the directory
|
||||
call assert_fails('helptags Xdir', 'E151:')
|
||||
|
||||
call writefile([], 'Xdir/a/doc/sample.txt')
|
||||
|
||||
" Test for ++t argument
|
||||
helptags ++t Xdir
|
||||
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
||||
call delete('Xdir/tags')
|
||||
|
||||
" The following tests fail on FreeBSD for some reason
|
||||
if has('unix') && !has('bsd')
|
||||
" Read-only tags file
|
||||
call mkdir('Xdir/doc', 'p')
|
||||
call writefile([''], 'Xdir/doc/tags')
|
||||
call writefile([], 'Xdir/doc/sample.txt')
|
||||
call setfperm('Xdir/doc/tags', 'r-xr--r--')
|
||||
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
|
||||
|
||||
let rtp = &rtp
|
||||
let &rtp = 'Xdir'
|
||||
helptags ALL
|
||||
let &rtp = rtp
|
||||
|
||||
call delete('Xdir/doc/tags')
|
||||
|
||||
" No permission to read the help file
|
||||
call setfperm('Xdir/a/doc/sample.txt', '-w-------')
|
||||
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt'))
|
||||
call delete('Xdir/a/doc/sample.txt')
|
||||
call delete('Xdir/tags')
|
||||
endif
|
||||
|
||||
" Duplicate tags in the help file
|
||||
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
||||
call assert_fails('helptags Xdir', 'E154:')
|
||||
|
||||
call delete('Xdir', 'rf')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user