mirror of
https://github.com/git/git.git
synced 2026-04-01 12:30:09 +02:00
Windows: mark newly-created files whose name starts with a dot as hidden
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
@@ -135,7 +135,7 @@ core.fileMode::
|
||||
|
||||
core.hideDotFiles::
|
||||
(Windows-only) If true (which is the default), mark newly-created
|
||||
directories whose name starts with a dot as hidden.
|
||||
directories and files whose name starts with a dot as hidden.
|
||||
|
||||
core.ignoreCygwinFSTricks::
|
||||
This option is only used by Cygwin implementation of Git. If false,
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#include "win32.h"
|
||||
#include <conio.h>
|
||||
#include <winioctl.h>
|
||||
#include <shellapi.h>
|
||||
#include "../strbuf.h"
|
||||
|
||||
#include <shellapi.h>
|
||||
extern int hide_dotfiles;
|
||||
unsigned int _CRT_fmode = _O_BINARY;
|
||||
|
||||
static int err_win_to_posix(DWORD winerr)
|
||||
{
|
||||
@@ -131,7 +133,6 @@ static int make_hidden(const char *path)
|
||||
#undef mkdir
|
||||
int mingw_mkdir(const char *path, int mode)
|
||||
{
|
||||
extern int hide_dotfiles;
|
||||
int ret = mkdir(path);
|
||||
if (!ret && hide_dotfiles) {
|
||||
/*
|
||||
@@ -167,6 +168,16 @@ int mingw_open (const char *filename, int oflags, ...)
|
||||
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
|
||||
errno = EISDIR;
|
||||
}
|
||||
if ((oflags & O_CREAT) && fd >= 0 && hide_dotfiles) {
|
||||
/*
|
||||
* In Windows a file or dir starting with a dot is not
|
||||
* automatically hidden. So lets mark it as hidden when
|
||||
* such a file is created.
|
||||
*/
|
||||
const char *start = basename((char*)filename);
|
||||
if (*start == '.' && make_hidden(filename))
|
||||
warning("Could not mark '%s' as hidden.", filename);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user