From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Ramsay Jones <ramsay@ramsayjones.plus.com>,
Erik Faye-Lund <kusmabite@googlemail.com>,
Pat Thoyts <patthoyts@users.sourceforge.net>
Subject: [PATCH v3 0/2] Support marking .git/ (or all files) as hidden on Windows
Date: Tue, 10 May 2016 13:59:04 +0200 (CEST) [thread overview]
Message-ID: <cover.1462881473.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1462603453.git.johannes.schindelin@gmx.de>
Windows does not share Unix' convention that files and directories whose
names start with a dot are hidden. Hence `.git/`, for example, is in
plain view, and caused quite a bit of trouble: some users wanted to peek
inside and did not understand what it contains, others modified files.
There was a stream of bug reports, until Git for Windows introduced the
(opt-out) option to hide at least the .git/ directory by default. The
option is configured via the config setting core.hideDotFiles, with the
possible values false, true and dotGitOnly (the latter being the
default).
This is a heavily version of patches we carried in Git for Windows for
way too long without submitting them upstream.
This iteration addresses Junio's most recent round of concerns. Oh, and
while at it, it also avoids setting attributes unnecessarily.
Johannes Schindelin (2):
mingw: introduce the 'core.hideDotFiles' setting
mingw: remove unnecessary definition
Documentation/config.txt | 6 ++++
cache.h | 7 +++++
compat/mingw.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
compat/mingw.h | 3 --
config.c | 8 ++++++
environment.c | 1 +
t/t0001-init.sh | 30 ++++++++++++++++++++
t/t5611-clone-config.sh | 20 +++++++++++++
8 files changed, 146 insertions(+), 3 deletions(-)
Published-As: https://github.com/dscho/git/releases/tag/hide-dotgit-v3
Interdiff vs v2:
diff --git a/cache.h b/cache.h
index 743b081..5f72f59 100644
--- a/cache.h
+++ b/cache.h
@@ -704,7 +704,7 @@ extern int auto_comment_line_char;
enum hide_dotfiles_type {
HIDE_DOTFILES_FALSE = 0,
HIDE_DOTFILES_TRUE,
- HIDE_DOTFILES_DOTGITONLY,
+ HIDE_DOTFILES_DOTGITONLY
};
extern enum hide_dotfiles_type hide_dotfiles;
diff --git a/compat/mingw.c b/compat/mingw.c
index 3ecde84..a8218e6 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -318,12 +318,12 @@ static inline int needs_hiding(const char *path)
static int set_hidden_flag(const wchar_t *path, int set)
{
- DWORD attribs = GetFileAttributesW(path);
+ DWORD original = GetFileAttributesW(path), modified;
if (set)
- attribs |= FILE_ATTRIBUTE_HIDDEN;
+ modified = original | FILE_ATTRIBUTE_HIDDEN;
else
- attribs &= ~FILE_ATTRIBUTE_HIDDEN;
- if (SetFileAttributesW(path, attribs))
+ modified = original & ~FILE_ATTRIBUTE_HIDDEN;
+ if (original == modified || SetFileAttributesW(path, modified))
return 0;
errno = err_win_to_posix(GetLastError());
return -1;
@@ -377,7 +377,7 @@ int mingw_open (const char *filename, int oflags, ...)
if (fd < 0 && errno == EACCES)
fd = _wopen(wfilename, oflags & ~O_CREAT, mode);
if (fd >= 0 && set_hidden_flag(wfilename, 1))
- warning("Could not mark '%s' as hidden.", filename);
+ warning("could not mark '%s' as hidden.", filename);
}
return fd;
}
@@ -419,12 +419,12 @@ FILE *mingw_fopen (const char *filename, const char *otype)
xutftowcs(wotype, otype, ARRAY_SIZE(wotype)) < 0)
return NULL;
if (hide && !access(filename, F_OK) && set_hidden_flag(wfilename, 0)) {
- error("Could not unhide %s", filename);
+ error("could not unhide %s", filename);
return NULL;
}
file = _wfopen(wfilename, wotype);
if (file && hide && set_hidden_flag(wfilename, 1))
- warning("Could not mark '%s' as hidden.", filename);
+ warning("could not mark '%s' as hidden.", filename);
return file;
}
@@ -439,12 +439,12 @@ FILE *mingw_freopen (const char *filename, const char *otype, FILE *stream)
xutftowcs(wotype, otype, ARRAY_SIZE(wotype)) < 0)
return NULL;
if (hide && !access(filename, F_OK) && set_hidden_flag(wfilename, 0)) {
- error("Could not unhide %s", filename);
+ error("could not unhide %s", filename);
return NULL;
}
file = _wfreopen(wfilename, wotype, stream);
if (file && hide && set_hidden_flag(wfilename, 1))
- warning("Could not mark '%s' as hidden.", filename);
+ warning("could not mark '%s' as hidden.", filename);
return file;
}
--
2.8.2.463.g99156ee
next prev parent reply other threads:[~2016-05-10 11:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-04 14:40 [PATCH] mingw: introduce the 'core.hideDotFiles' setting Johannes Schindelin
2016-05-04 16:18 ` Ramsay Jones
2016-05-06 12:06 ` Johannes Schindelin
2016-05-04 19:06 ` Junio C Hamano
2016-05-06 15:19 ` Johannes Schindelin
2016-05-06 16:34 ` Junio C Hamano
2016-05-06 17:17 ` Junio C Hamano
2016-05-07 6:01 ` Johannes Schindelin
2016-05-07 6:44 ` Johannes Schindelin
2016-05-07 6:44 ` [PATCH v2 0/2] Support marking .git/ (or all files) as hidden on Windows Johannes Schindelin
2016-05-07 6:45 ` [PATCH v2 1/2] mingw: introduce the 'core.hideDotFiles' setting Johannes Schindelin
2016-05-09 17:23 ` Junio C Hamano
2016-05-10 11:58 ` Johannes Schindelin
2016-05-10 17:19 ` Junio C Hamano
2016-05-11 8:40 ` Johannes Schindelin
2016-05-07 6:45 ` [PATCH v2 2/2] mingw: remove unnecessary definition Johannes Schindelin
2016-05-09 17:01 ` [PATCH v2 0/2] Support marking .git/ (or all files) as hidden on Windows Junio C Hamano
2016-05-10 8:41 ` Johannes Schindelin
2016-05-10 17:22 ` Junio C Hamano
2016-05-11 8:34 ` Johannes Schindelin
2016-05-10 11:59 ` Johannes Schindelin [this message]
2016-05-10 11:59 ` [PATCH v3 1/2] mingw: introduce the 'core.hideDotFiles' setting Johannes Schindelin
2016-05-10 11:59 ` [PATCH v3 2/2] mingw: remove unnecessary definition Johannes Schindelin
2016-05-11 8:40 ` [PATCH v4 0/2] Support marking .git/ (or all files) as hidden on Windows Johannes Schindelin
2016-05-11 8:43 ` Johannes Schindelin
2016-05-11 8:43 ` [PATCH v4 1/2] mingw: introduce the 'core.hideDotFiles' setting Johannes Schindelin
2016-05-11 8:43 ` [PATCH v4 2/2] mingw: remove unnecessary definition Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1462881473.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kusmabite@googlemail.com \
--cc=patthoyts@users.sourceforge.net \
--cc=ramsay@ramsayjones.plus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).