* Unix root dir as a work tree
@ 2010-02-08 1:31 João Carlos Mendes Luís
2010-02-08 2:03 ` Nguyen Thai Ngoc Duy
2010-02-08 2:18 ` Nguyen Thai Ngoc Duy
0 siblings, 2 replies; 4+ messages in thread
From: João Carlos Mendes Luís @ 2010-02-08 1:31 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
Hi,
Sorry if this is a FAQ, but I could not find any reference.
I have been using CVS as a version control system for unix
configuration files for a long time. I know it has some limitations,
and I know git also has its. But I expect to work around all of them
using etckeeper.
The problem is that etckeeper was created with /etc only in mind,
and I want to keep track of important files everywhere, not only below
/etc (think /opt, /usr/local). The obvious solution appear to create
the repository at the system root, and not at /etc, but it did not
work. I think, because of a bug.
Now, I have a patch that appears to work, but since I am a beginner
to git, I don't know if this is the best way to implement it, if it has
any side effects, or even if it works for other operating systems
(probably they don't even have the bug). Would any git wizard care to
look at it, check if it is ok, and maybe commit in HEAD or give me any
advice against my patch?
Please, don't give me any answers like "don't use your root as a
repo". I am a system admin for a long time, and I know what I want and
what are the risks and benefits involved.
Thanks in advance,
Jonny
[-- Attachment #2: git-1.5.5.6-setup-work_dir-root.patch --]
[-- Type: text/x-patch, Size: 465 bytes --]
--- a/setup.c 2010-02-07 22:50:40.000000000 -0200
+++ b/setup.c 2010-02-07 22:51:56.000000000 -0200
@@ -413,7 +413,12 @@
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
- git_work_tree_cfg = xstrndup(cwd, offset);
+ if ( cwd[0] == '/' && offset == 0 ) {
+ git_work_tree_cfg = xstrndup(cwd, 1);
+ }
+ else {
+ git_work_tree_cfg = xstrndup(cwd, offset);
+ }
if (check_repository_format_gently(nongit_ok))
return NULL;
if (offset == len)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Unix root dir as a work tree
2010-02-08 1:31 Unix root dir as a work tree João Carlos Mendes Luís
@ 2010-02-08 2:03 ` Nguyen Thai Ngoc Duy
2010-02-08 12:17 ` João Carlos Mendes Luís
2010-02-08 2:18 ` Nguyen Thai Ngoc Duy
1 sibling, 1 reply; 4+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-02-08 2:03 UTC (permalink / raw)
To: João Carlos Mendes Luís; +Cc: git
2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:
> Hi,
>
> Sorry if this is a FAQ, but I could not find any reference.
>
> I have been using CVS as a version control system for unix configuration
> files for a long time. I know it has some limitations, and I know git also
> has its. But I expect to work around all of them using etckeeper.
>
> The problem is that etckeeper was created with /etc only in mind, and I
> want to keep track of important files everywhere, not only below /etc (think
> /opt, /usr/local). The obvious solution appear to create the repository at
> the system root, and not at /etc, but it did not work. I think, because of
> a bug.
>
> Now, I have a patch that appears to work, but since I am a beginner to git,
> I don't know if this is the best way to implement it, if it has any side
> effects, or even if it works for other operating systems (probably they
> don't even have the bug). Would any git wizard care to look at it, check if
> it is ok, and maybe commit in HEAD or give me any advice against my patch?
How did you set GIT_DIR and GIT_WORK_TREE? What command failed?
--
Duy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Unix root dir as a work tree
2010-02-08 2:03 ` Nguyen Thai Ngoc Duy
@ 2010-02-08 12:17 ` João Carlos Mendes Luís
0 siblings, 0 replies; 4+ messages in thread
From: João Carlos Mendes Luís @ 2010-02-08 12:17 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
Nguyen Thai Ngoc Duy wrote:
> 2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:
>
>> Hi,
>>
>> Sorry if this is a FAQ, but I could not find any reference.
>>
>> I have been using CVS as a version control system for unix configuration
>> files for a long time. I know it has some limitations, and I know git also
>> has its. But I expect to work around all of them using etckeeper.
>>
>> The problem is that etckeeper was created with /etc only in mind, and I
>> want to keep track of important files everywhere, not only below /etc (think
>> /opt, /usr/local). The obvious solution appear to create the repository at
>> the system root, and not at /etc, but it did not work. I think, because of
>> a bug.
>>
>> Now, I have a patch that appears to work, but since I am a beginner to git,
>> I don't know if this is the best way to implement it, if it has any side
>> effects, or even if it works for other operating systems (probably they
>> don't even have the bug). Would any git wizard care to look at it, check if
>> it is ok, and maybe commit in HEAD or give me any advice against my patch?
>>
>
> How did you set GIT_DIR and GIT_WORK_TREE? What command failed?
>
Did not set any env special variable. I expect git to find those
automatically.
Any command which needs a work tree fails. git-add, git-status, etc.
It thinks that its root is "/.git", instead of "/". Easy to repeat.
cd /
git init
git add etc/motd # this works
cd etc
git add resolv.conf # this does not work without my patch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Unix root dir as a work tree
2010-02-08 1:31 Unix root dir as a work tree João Carlos Mendes Luís
2010-02-08 2:03 ` Nguyen Thai Ngoc Duy
@ 2010-02-08 2:18 ` Nguyen Thai Ngoc Duy
1 sibling, 0 replies; 4+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-02-08 2:18 UTC (permalink / raw)
To: João Carlos Mendes Luís; +Cc: git
2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:
> Now, I have a patch that appears to work, but since I am a beginner to git,
> I don't know if this is the best way to implement it, if it has any side
> effects, or even if it works for other operating systems (probably they
> don't even have the bug). Would any git wizard care to look at it, check if
> it is ok, and maybe commit in HEAD or give me any advice against my patch?
Hmm.. I guess you put .git at root directory so you needed your patch.
I haven't tried it yet because I don't have root access here.
Anyway you may also need the below patch. Please report back if any
Git operation that does not work under your setup.
diff --git a/setup.c b/setup.c
index 710e2f3..d31dcb8 100644
--- a/setup.c
+++ b/setup.c
@@ -25,7 +25,7 @@ const char *prefix_path(const char *prefix, int len,
const char *path)
len = strlen(work_tree);
total = strlen(sanitized) + 1;
if (strncmp(sanitized, work_tree, len) ||
- (sanitized[len] != '\0' && sanitized[len] != '/')) {
+ (len > 1 && sanitized[len] != '\0' && sanitized[len] != '/')) {
error_out:
die("'%s' is outside repository", orig);
}
--
Duy
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-08 12:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-08 1:31 Unix root dir as a work tree João Carlos Mendes Luís
2010-02-08 2:03 ` Nguyen Thai Ngoc Duy
2010-02-08 12:17 ` João Carlos Mendes Luís
2010-02-08 2:18 ` Nguyen Thai Ngoc Duy
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).