mirror of
https://github.com/git/git.git
synced 2026-04-01 20:40:08 +02:00
core.hidedotfiles: only hide '.git' dir by default
At least for cross-platform projects, it makes sense to hide the files starting with a dot, as this is the behavior on Unix/MacOSX. However, at least Eclipse has problems interpreting the hidden flag correctly, so the default is to hide only the .git/ directory. The config setting core.hideDotFiles therefore supports not only 'true' and 'false', but also 'dotGitOnly'. [jes: clarified the commit message, made git init respect the setting by marking the .git/ directory only after reading the config, and added documentation] Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
71d1688300
commit
f1d8529445
@@ -136,6 +136,8 @@ core.fileMode::
|
||||
core.hideDotFiles::
|
||||
(Windows-only) If true (which is the default), mark newly-created
|
||||
directories and files whose name starts with a dot as hidden.
|
||||
If 'dotGitOnly', only the .git/ directory is hidden, but no other
|
||||
files starting with a dot.
|
||||
|
||||
core.ignoreCygwinFSTricks::
|
||||
This option is only used by Cygwin implementation of Git. If false,
|
||||
|
||||
@@ -298,6 +298,7 @@ int init_db(const char *template_dir, unsigned int flags)
|
||||
check_repository_format();
|
||||
|
||||
reinit = create_default_files(template_dir);
|
||||
mark_as_git_dir(get_git_dir());
|
||||
|
||||
sha1_dir = get_object_directory();
|
||||
len = strlen(sha1_dir);
|
||||
|
||||
8
cache.h
8
cache.h
@@ -525,7 +525,13 @@ extern int auto_crlf;
|
||||
extern int read_replace_refs;
|
||||
extern int fsync_object_files;
|
||||
extern int core_preload_index;
|
||||
extern int hide_dotfiles;
|
||||
|
||||
enum hide_dotfiles_type {
|
||||
HIDE_DOTFILES_FALSE = 0,
|
||||
HIDE_DOTFILES_TRUE,
|
||||
HIDE_DOTFILES_DOTGITONLY,
|
||||
};
|
||||
extern enum hide_dotfiles_type hide_dotfiles;
|
||||
|
||||
enum safe_crlf {
|
||||
SAFE_CRLF_FALSE = 0,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <winioctl.h>
|
||||
#include <shellapi.h>
|
||||
#include "../strbuf.h"
|
||||
#include "../cache.h"
|
||||
|
||||
extern int hide_dotfiles;
|
||||
unsigned int _CRT_fmode = _O_BINARY;
|
||||
|
||||
static int err_win_to_posix(DWORD winerr)
|
||||
@@ -130,11 +130,17 @@ static int make_hidden(const char *path)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void mingw_mark_as_git_dir(const char *dir)
|
||||
{
|
||||
if (hide_dotfiles != HIDE_DOTFILES_FALSE && make_hidden(dir))
|
||||
warning("Failed to make '%s' hidden", dir);
|
||||
}
|
||||
|
||||
#undef mkdir
|
||||
int mingw_mkdir(const char *path, int mode)
|
||||
{
|
||||
int ret = mkdir(path);
|
||||
if (!ret && hide_dotfiles) {
|
||||
if (!ret && hide_dotfiles == HIDE_DOTFILES_TRUE) {
|
||||
/*
|
||||
* In Windows a file or dir starting with a dot is not
|
||||
* automatically hidden. So lets mark it as hidden when
|
||||
@@ -168,7 +174,8 @@ 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) {
|
||||
if ((oflags & O_CREAT) && fd >= 0 &&
|
||||
hide_dotfiles == HIDE_DOTFILES_TRUE) {
|
||||
/*
|
||||
* In Windows a file or dir starting with a dot is not
|
||||
* automatically hidden. So lets mark it as hidden when
|
||||
@@ -186,7 +193,8 @@ FILE *mingw_fopen (const char *filename, const char *mode)
|
||||
{
|
||||
int hide = 0;
|
||||
FILE *file;
|
||||
if (hide_dotfiles && basename((char*)filename)[0] == '.')
|
||||
if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
|
||||
basename((char*)filename)[0] == '.')
|
||||
hide = access(filename, F_OK);
|
||||
|
||||
file = fopen(filename, mode);
|
||||
|
||||
@@ -231,6 +231,9 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
|
||||
void mingw_open_html(const char *path);
|
||||
#define open_html mingw_open_html
|
||||
|
||||
void mingw_mark_as_git_dir(const char *dir);
|
||||
#define mark_as_git_dir mingw_mark_as_git_dir
|
||||
|
||||
/*
|
||||
* helpers
|
||||
*/
|
||||
|
||||
4
config.c
4
config.c
@@ -504,6 +504,10 @@ static int git_default_core_config(const char *var, const char *value)
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.hidedotfiles")) {
|
||||
if (value && !strcasecmp(value, "dotgitonly")) {
|
||||
hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
return 0;
|
||||
}
|
||||
hide_dotfiles = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
|
||||
#endif
|
||||
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
|
||||
int grafts_replace_parents = 1;
|
||||
int hide_dotfiles = 1;
|
||||
enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
|
||||
/* Parallel index stat data preload? */
|
||||
int core_preload_index = 0;
|
||||
|
||||
@@ -464,4 +464,8 @@ void git_qsort(void *base, size_t nmemb, size_t size,
|
||||
*/
|
||||
int unlink_or_warn(const char *path);
|
||||
|
||||
#ifndef mark_as_git_dir
|
||||
#define mark_as_git_dir(x) /* noop */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user