On Thu, 17 Jan 2008, Jeff King wrote:Ok, here's the ugliest idea *ever*: We could actually use POSIX extended attributes (or whatever system-specific version of it a particular filesystem supports) for people who *really* don't want to pollute their file structure. I know, I know, it's horrible. It's one of those things that would actually be reqlly convenient (and probably even pretty easy to implement), but is also going to be *really* subtle when it breaks. But I bet some people would like it. I personally tend to hate extended attributes (they tend to have serious problems with anything that moves things around or backs them up - especially across filesystem boundaries), but there is no question that they can't be convenient to hide information. Anyway, here's a really stupid patch. It kind of works, but it has no way to turn this off. On at least Linux, with this you can do something like .. start off with a git directory .. mv .git /external/git/location setfattr -n user.git-dir -v /external/git/location . and now that "user.git-dir" thing acts as a kind of invisible "symlink" to the external git directory. Not exactly heavily tested, and I don't know how portable the whole xattr thing is (ie I know OS X has file attributes, I just don't know if the interface is at all similar). I don't like extended attributes myself, but this patch really is pretty simple and perhaps useful. Linus --- setup.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/setup.c b/setup.c index adede16..97865f4 100644 --- a/setup.c +++ b/setup.c @@ -1,5 +1,6 @@ #include "cache.h" #include "dir.h" +#include <attr/xattr.h> static int inside_git_dir = -1; static int inside_work_tree = -1; @@ -302,6 +303,9 @@ const char *setup_git_directory_gently(int *nongit_ok) */ offset = len = strlen(cwd); for (;;) { + int attr_len; + static char git_dir[PATH_MAX]; + if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT)) break; if (is_git_directory(".")) { @@ -312,6 +316,14 @@ const char *setup_git_directory_gently(int *nongit_ok) check_repository_format_gently(nongit_ok); return NULL; } + attr_len = getxattr(".", "user.git-dir", git_dir, sizeof(git_dir)-1); + if (attr_len > 0) { + git_dir[attr_len] = 0; + if (is_git_directory(git_dir)) { + setenv(GIT_DIR_ENVIRONMENT, git_dir, 1); + break; + } + } chdir(".."); do { if (!offset) { - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Greg Kroah-Hartman | [PATCH 005/196] Chinese: add translation of SubmittingDrivers |
| majkls | sys_chroot+sys_fchdir Fix |
| Paul Mackerras | Re: [linux-pm] [PATCH] Remove process freezer from suspend to RAM pathway |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
