{"thread":{"id":"22562","subject":"Unix root dir as a work tree","startedAt":"2010-02-08T01:31:29Z","lastAt":"2010-02-08T12:17:11Z","messageCount":4,"participants":["João Carlos Mendes Luís","Nguyen Thai Ngoc Duy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133904","messageId":"4B6F6971.6000106@jonny.eng.br","threadId":"22562","inReplyTo":null,"subject":"Unix root dir as a work tree","fromName":"João Carlos Mendes Luís","fromEmail":"jonny@jonny.eng.br","sentAt":"2010-02-08T01:31:29Z","receivedAt":"2010-02-08T01:31:29Z","isPatch":false,"sender":{"key":"jonny@jonny.eng.br","avatar":"https://gravatar.com/avatar/08e8bcb8e66e4b12bd5d62d2ada030ff3bb15f4a4ca230cc47f90d6218121fbe?d=mp&s=160"},"body":"Hi,\n\n    Sorry if this is a FAQ, but I could not find any reference.\n\n    I have been using CVS as a version control system for unix \nconfiguration files for a long time.  I know it has some limitations, \nand I know git also has its.  But I expect to work around all of them \nusing etckeeper.\n\n    The problem is that etckeeper was created with /etc only in mind, \nand I want to keep track of important files everywhere, not only below \n/etc (think /opt, /usr/local).  The obvious solution appear to create \nthe repository at the system root, and not at /etc, but it did not \nwork.  I think, because of a bug.\n\n   Now, I have a patch that appears to work, but since I am a beginner \nto git, I don't know if this is the best way to implement it, if it has \nany side effects, or even if it works for other operating systems \n(probably they don't even have the bug).  Would any git wizard care to \nlook at it, check if it is ok, and maybe commit in HEAD or give me any \nadvice against my patch?\n\n    Please, don't give me any answers like \"don't use your root as a \nrepo\".  I am a system admin for a long time, and I know what I want and \nwhat are the risks and benefits involved.\n\n    Thanks in advance,\n\n       Jonny\n\n\n\n--- a/setup.c\t2010-02-07 22:50:40.000000000 -0200\n+++ b/setup.c\t2010-02-07 22:51:56.000000000 -0200\n@@ -413,7 +413,12 @@\n \tinside_git_dir = 0;\n \tif (!work_tree_env)\n \t\tinside_work_tree = 1;\n-\tgit_work_tree_cfg = xstrndup(cwd, offset);\n+\tif ( cwd[0] == '/' && offset == 0 ) {\n+\t\tgit_work_tree_cfg = xstrndup(cwd, 1);\n+\t}\n+\telse {\n+\t\tgit_work_tree_cfg = xstrndup(cwd, offset);\n+\t}\n \tif (check_repository_format_gently(nongit_ok))\n \t\treturn NULL;\n \tif (offset == len)\n"},{"id":"133905","messageId":"fcaeb9bf1002071803o343bed87u2e1df2ef77db607f@mail.gmail.com","threadId":"22562","inReplyTo":"4B6F6971.6000106@jonny.eng.br","subject":"Re: Unix root dir as a work tree","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-02-08T02:03:03Z","receivedAt":"2010-02-08T02:03:03Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:\n> Hi,\n>\n>   Sorry if this is a FAQ, but I could not find any reference.\n>\n>   I have been using CVS as a version control system for unix configuration\n> files for a long time.  I know it has some limitations, and I know git also\n> has its.  But I expect to work around all of them using etckeeper.\n>\n>   The problem is that etckeeper was created with /etc only in mind, and I\n> want to keep track of important files everywhere, not only below /etc (think\n> /opt, /usr/local).  The obvious solution appear to create the repository at\n> the system root, and not at /etc, but it did not work.  I think, because of\n> a bug.\n>\n>  Now, I have a patch that appears to work, but since I am a beginner to git,\n> I don't know if this is the best way to implement it, if it has any side\n> effects, or even if it works for other operating systems (probably they\n> don't even have the bug).  Would any git wizard care to look at it, check if\n> it is ok, and maybe commit in HEAD or give me any advice against my patch?\n\nHow did you set GIT_DIR and GIT_WORK_TREE? What command failed?\n-- \nDuy\n"},{"id":"133907","messageId":"fcaeb9bf1002071818j29fe919bve0ef2d1c4cac8a79@mail.gmail.com","threadId":"22562","inReplyTo":"4B6F6971.6000106@jonny.eng.br","subject":"Re: Unix root dir as a work tree","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-02-08T02:18:25Z","receivedAt":"2010-02-08T02:18:25Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:\n>  Now, I have a patch that appears to work, but since I am a beginner to git,\n> I don't know if this is the best way to implement it, if it has any side\n> effects, or even if it works for other operating systems (probably they\n> don't even have the bug).  Would any git wizard care to look at it, check if\n> it is ok, and maybe commit in HEAD or give me any advice against my patch?\n\nHmm.. I guess you put .git at root directory so you needed your patch.\nI haven't tried it yet because I don't have root access here.\n\nAnyway you may also need the below patch. Please report back if any\nGit operation that does not work under your setup.\n\ndiff --git a/setup.c b/setup.c\nindex 710e2f3..d31dcb8 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -25,7 +25,7 @@ const char *prefix_path(const char *prefix, int len,\nconst char *path)\n \t\tlen = strlen(work_tree);\n \t\ttotal = strlen(sanitized) + 1;\n \t\tif (strncmp(sanitized, work_tree, len) ||\n-\t\t    (sanitized[len] != '\\0' && sanitized[len] != '/')) {\n+\t\t    (len > 1 && sanitized[len] != '\\0' && sanitized[len] != '/')) {\n \t\terror_out:\n \t\t\tdie(\"'%s' is outside repository\", orig);\n \t\t}\n\n-- \nDuy\n"},{"id":"133920","messageId":"4B7000C7.30507@jonny.eng.br","threadId":"22562","inReplyTo":"fcaeb9bf1002071803o343bed87u2e1df2ef77db607f@mail.gmail.com","subject":"Re: Unix root dir as a work tree","fromName":"João Carlos Mendes Luís","fromEmail":"jonny@jonny.eng.br","sentAt":"2010-02-08T12:17:11Z","receivedAt":"2010-02-08T12:17:11Z","isPatch":false,"sender":{"key":"jonny@jonny.eng.br","avatar":"https://gravatar.com/avatar/08e8bcb8e66e4b12bd5d62d2ada030ff3bb15f4a4ca230cc47f90d6218121fbe?d=mp&s=160"},"body":"\n\nNguyen Thai Ngoc Duy wrote:\n> 2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:\n>   \n>> Hi,\n>>\n>>   Sorry if this is a FAQ, but I could not find any reference.\n>>\n>>   I have been using CVS as a version control system for unix configuration\n>> files for a long time.  I know it has some limitations, and I know git also\n>> has its.  But I expect to work around all of them using etckeeper.\n>>\n>>   The problem is that etckeeper was created with /etc only in mind, and I\n>> want to keep track of important files everywhere, not only below /etc (think\n>> /opt, /usr/local).  The obvious solution appear to create the repository at\n>> the system root, and not at /etc, but it did not work.  I think, because of\n>> a bug.\n>>\n>>  Now, I have a patch that appears to work, but since I am a beginner to git,\n>> I don't know if this is the best way to implement it, if it has any side\n>> effects, or even if it works for other operating systems (probably they\n>> don't even have the bug).  Would any git wizard care to look at it, check if\n>> it is ok, and maybe commit in HEAD or give me any advice against my patch?\n>>     \n>\n> How did you set GIT_DIR and GIT_WORK_TREE? What command failed?\n>   \nDid not set any env special variable.  I expect git to find those \nautomatically.\n\nAny command which needs a work tree fails.  git-add, git-status, etc.\n\nIt thinks that its root is \"/.git\", instead of \"/\".  Easy to repeat.\n\ncd /\ngit init\ngit add etc/motd        # this works\ncd etc\ngit add resolv.conf    # this does not work without my patch\n"}]}