Set "Hidden" attribute for .git directories

30 views
Skip to first unread message

sschu...@gmail.com

unread,
Mar 6, 2008, 6:21:53 AM3/6/08
to msysGit
Hi,

I'd like to propose to set the "Hidden" attribute for .git directories
under Windows, just like CVS and Subversion do for the "CVS" and
".svn" directories. Doing so simplifies browsing / searching the
Working Tree as most tools support to not display / search hidden
files / folders.

Any chance to implement this?

--
Sebastian Schuberth

Johannes Schindelin

unread,
Mar 6, 2008, 6:42:10 AM3/6/08
to sschu...@gmail.com, msysGit
Hi,

Probably. But then it would be harder to edit .git/config directly, no?
Well, I guess you can always use Bash/vi ;-)

Ciao,
Dscho

Sebastian Schuberth

unread,
Mar 6, 2008, 6:47:16 AM3/6/08
to Johannes Schindelin, msysGit

I also believe that someone who edits .git/config directly would be
using vi anyways ;-)

But hiding the directory would not necessarily make editing the config
harder. I've configured my Windows Explorer to show hidden files /
folders, and use the "Hidden" attribute just as a "label" which can be
used to filter out files / folders in searches from time to time.

--
Sebastian Schuberth

Paul Franz

unread,
Mar 6, 2008, 6:48:50 AM3/6/08
to Johannes....@gmx.de, sschu...@gmail.com, msysGit

It depends on how it is hidden. If it using the hidden attribute or just
marking it as system. Depending on how a person has Windows Exploder
they will be able to see not see the directory

Paul Franz

Johannes Schindelin

unread,
Mar 6, 2008, 7:55:10 AM3/6/08
to Sebastian Schuberth, msysGit
Hi,

On Thu, 6 Mar 2008, Sebastian Schuberth wrote:

> > On Thu, 6 Mar 2008, sschu...@gmail.com wrote:
> >
> > > I'd like to propose to set the "Hidden" attribute for .git
> > > directories under Windows, just like CVS and Subversion do for the
> > > "CVS" and ".svn" directories. Doing so simplifies browsing /
> > > searching the Working Tree as most tools support to not display /
> > > search hidden files / folders.
> > >
> > > Any chance to implement this?

diff --git a/git-compat-util.h b/git-compat-util.h
index e0fe165..186dc3b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -552,7 +552,9 @@ static inline int fcntl(int fd, int cmd, long arg)

static inline int mingw_mkdir(const char *path, int mode)
{
- return mkdir(path);
+ return mkdir(path) ||
+ (*path == '.' &&
+ !SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN));
}
#define mkdir mingw_mkdir

For completeness' sake, we'd have to do this in mingw_open(), too, I
guess, and wrap fopen() too...

Ciao,
Dscho

Sebastian Schuberth

unread,
Mar 6, 2008, 8:15:33 AM3/6/08
to Johannes Schindelin, msysGit
> > > > I'd like to propose to set the "Hidden" attribute for .git
> > > > directories under Windows, just like CVS and Subversion do for the
> > > > "CVS" and ".svn" directories. Doing so simplifies browsing /
> > > > searching the Working Tree as most tools support to not display /
> > > > search hidden files / folders.
> > > >
> > > > Any chance to implement this?
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index e0fe165..186dc3b 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -552,7 +552,9 @@ static inline int fcntl(int fd, int cmd, long arg)
>
> static inline int mingw_mkdir(const char *path, int mode)
> {
> - return mkdir(path);
> + return mkdir(path) ||
> + (*path == '.' &&
> + !SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN));
> }
> #define mkdir mingw_mkdir
>
>
> For completeness' sake, we'd have to do this in mingw_open(), too, I
> guess, and wrap fopen() too...

Thanks!

--
Sebastian Schuberth

Peter Harris

unread,
Mar 6, 2008, 9:07:00 AM3/6/08
to Johannes....@gmx.de, sschu...@gmail.com, msysGit
On Thu, Mar 6, 2008 Johannes Schindelin wrote:
>
> On Thu, 6 Mar 2008, sschu...@gmail.com wrote:
>
> > I'd like to propose to set the "Hidden" attribute for .git directories
> > under Windows, just like CVS and Subversion do for the "CVS" and ".svn"
> > directories. Doing so simplifies browsing / searching the Working Tree
> > as most tools support to not display / search hidden files / folders.
>
> Probably. But then it would be harder to edit .git/config directly, no?

Not really. I have my GUI set up to show hidden files and directories
dimmed, not completely hidden. Anyone who wants to edit .git/config
directly could do the same. At least in Windows, showing hidden
files/directories is a checkbox in the options GUI. To make my Mac's
Finder show .files, I would have to set an undocumented flag from the
command line. I'm not sure what the situation is in KDE/GNOME.

At the command line, dir /a shows all files, much like ls -a includes
files that begin with a . (dir /ah shows only hidden files. I suppose
the equivalent would be ls -d .*)

I'm not sure which tools Sebasitan uses to search, but my copy of grep
(native Win32) descends into hidden directories (which is one of the
reasons I switched from svn to git-svn the minute the first msysGit
preview with git-svn support was available).

I do note that my other search tool (Google Desktop) does not search
hidden directories.

> Well, I guess you can always use Bash/vi ;-)

That too.

Peter Harris

Sebastian Schuberth

unread,
Mar 6, 2008, 9:13:27 AM3/6/08
to Peter Harris, Johannes....@gmx.de, msysGit
> I'm not sure which tools Sebasitan uses to search, but my copy of grep
> (native Win32) descends into hidden directories (which is one of the
> reasons I switched from svn to git-svn the minute the first msysGit
> preview with git-svn support was available).

I'm using grepWin :-)

http://tools.tortoisesvn.net/grepWin

--
Sebastian Schuberth

Reply all
Reply to author
Forward
0 new messages