{"thread":{"id":"4981","subject":"[RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","startedAt":"2006-07-25T17:30:21Z","lastAt":"2006-07-26T07:12:04Z","messageCount":7,"participants":["Johannes Schindelin","Linus Torvalds","Junio C Hamano","Uwe Zeisberger"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24097","messageId":"Pine.LNX.4.63.0607251926190.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4981","inReplyTo":null,"subject":"[RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-25T17:30:21Z","receivedAt":"2006-07-25T17:30:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith this, you can say\n\n\tgit --bare repack -a -d\n\ninside a bare repository, and it will actually work. While at\ndocumenting these options, also document the --paginate option.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\tThis is on top of my \"allow wrapper options in aliases\" patch.\n\n\tI hope I did not fsck up the asciidoc formatting; ATM I cannot \n\ttest that.\n\n\tIf you agree this is a good approach, should I also move the \n\t--version and --exec-path options into handle_options()?\n\n\tIf you do, I will also make this more user-friendly, i.e.\n\tit should not crash when saying \"git --bare\".\n\n Documentation/git.txt |   12 +++++++++++-\n git.c                 |    9 +++++++++\n 2 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex ce30581..b5da5f9 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -8,7 +8,8 @@ git - the stupid content tracker\n \n SYNOPSIS\n --------\n-'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]\n+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]\n+\t[--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]\n \n DESCRIPTION\n -----------\n@@ -41,6 +42,15 @@ OPTIONS\n \tenvironment variable. If no path is given 'git' will print\n \tthe current setting and then exit.\n \n+-p|--paginate::\n+\tPipe all output into 'less' (or if set, $PAGER).\n+\n+--git-path=<path>::\n+\tSet the path to the repository. This can also be controlled by\n+\tsetting the GIT_DIR environment variable.\n+\n+--bare::\n+\tSame as --git-path=`pwd`.\n \n FURTHER DOCUMENTATION\n ---------------------\ndiff --git a/git.c b/git.c\nindex 8d7c644..e048f54 100644\n--- a/git.c\n+++ b/git.c\n@@ -46,6 +46,15 @@ static int handle_options(const char*** \n \n \t\tif (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n \t\t\tsetup_pager();\n+\t\t} else if (!strcmp(cmd, \"--git-dir\") && *argc > 1) {\n+\t\t\tsetenv(\"GIT_DIR\", (*argv)[1], 1);\n+\t\t\t(*argv)++;\n+\t\t\t(*argc)--;\n+\t\t} else if (!strncmp(cmd, \"--git-dir=\", 10)) {\n+\t\t\tsetenv(\"GIT_DIR\", cmd + 10, 1);\n+\t\t} else if (!strcmp(cmd, \"--bare\")) {\n+\t\t\tstatic char git_dir[1024];\n+\t\t\tsetenv(\"GIT_DIR\", getcwd(git_dir, 1024), 1);\n \t\t} else\n \t\t\tdie (\"Unknown option: %s\", cmd);\n \n-- \n1.4.2.rc1.gf725-dirty\n"},{"id":"24098","messageId":"Pine.LNX.4.64.0607251042120.29649@g5.osdl.org","threadId":"4981","inReplyTo":"Pine.LNX.4.63.0607251926190.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-07-25T17:43:53Z","receivedAt":"2006-07-25T17:43:53Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 25 Jul 2006, Johannes Schindelin wrote:\n>  \n>  SYNOPSIS\n>  --------\n> -'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]\n> +'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]\n> +\t[--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]\n\nHere you have \"--git-dir\"\n\n> @@ -41,6 +42,15 @@ OPTIONS\n>  \tenvironment variable. If no path is given 'git' will print\n>  \tthe current setting and then exit.\n>  \n> +-p|--paginate::\n> +\tPipe all output into 'less' (or if set, $PAGER).\n> +\n> +--git-path=<path>::\n> +\tSet the path to the repository. This can also be controlled by\n> +\tsetting the GIT_DIR environment variable.\n\nBut here you have \"--git-path\".\n\n> +\t\t} else if (!strcmp(cmd, \"--git-dir\") && *argc > 1) {\n> +\t\t\tsetenv(\"GIT_DIR\", (*argv)[1], 1);\n> +\t\t\t(*argv)++;\n> +\t\t\t(*argc)--;\n> +\t\t} else if (!strncmp(cmd, \"--git-dir=\", 10)) {\n> +\t\t\tsetenv(\"GIT_DIR\", cmd + 10, 1);\n\nAnd here you have \"--git-dir\" again.\n\nSince \"--git-dir\" makes more sense than \"--git-path\", I'd suggest just \nfixing the OPTIONS section ;)\n\n\t\tLinus\n"},{"id":"24099","messageId":"Pine.LNX.4.63.0607251952000.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4981","inReplyTo":"Pine.LNX.4.64.0607251042120.29649@g5.osdl.org","subject":"Re: [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-25T17:52:22Z","receivedAt":"2006-07-25T17:52:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Jul 2006, Linus Torvalds wrote:\n\n> Since \"--git-dir\" makes more sense than \"--git-path\", I'd suggest just \n> fixing the OPTIONS section ;)\n\nWill do. Thanks.\n\nCiao,\nDscho\n"},{"id":"24100","messageId":"Pine.LNX.4.63.0607252022370.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4981","inReplyTo":"Pine.LNX.4.63.0607251952000.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"[PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-25T18:24:22Z","receivedAt":"2006-07-25T18:24:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith this, you can say\n\n\tgit --bare repack -a -d\n\ninside a bare repository, and it will actually work. While at it,\nalso move the --version, --help and --exec-path options to the\nhandle_options() function.\n\nWhile at documenting the new options, also document the --paginate\noption.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\tThe change in builtin-help.c is not only clean, but is also\n\tnecessary for t0000 on cygwin.\n\n\tI have to run off now, but will answer your comments in\n\tabout three hours.\n\n Documentation/git.txt |   12 ++++++\n builtin-help.c        |    2 +\n git.c                 |   93 +++++++++++++++++++++++++------------------------\n 3 files changed, 60 insertions(+), 47 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex ce30581..29aebe9 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -8,7 +8,8 @@ git - the stupid content tracker\n \n SYNOPSIS\n --------\n-'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]\n+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]\n+\t[--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]\n \n DESCRIPTION\n -----------\n@@ -41,6 +42,15 @@ OPTIONS\n \tenvironment variable. If no path is given 'git' will print\n \tthe current setting and then exit.\n \n+-p|--paginate::\n+\tPipe all output into 'less' (or if set, $PAGER).\n+\n+--git-dir=<path>::\n+\tSet the path to the repository. This can also be controlled by\n+\tsetting the GIT_DIR environment variable.\n+\n+--bare::\n+\tSame as --git-path=`pwd`.\n \n FURTHER DOCUMENTATION\n ---------------------\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 335fe5f..bc1b4da 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -229,7 +229,7 @@ int cmd_version(int argc, const char **a\n \n int cmd_help(int argc, const char **argv, char **envp)\n {\n-\tconst char *help_cmd = argv[1];\n+\tconst char *help_cmd = argc > 1 ? argv[1] : NULL;\n \tif (!help_cmd)\n \t\tcmd_usage(0, git_exec_path(), NULL);\n \telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\"))\ndiff --git a/git.c b/git.c\nindex 8d7c644..e4b2174 100644\n--- a/git.c\n+++ b/git.c\n@@ -44,10 +44,44 @@ static int handle_options(const char*** \n \t\tif (cmd[0] != '-')\n \t\t\tbreak;\n \n-\t\tif (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n+\t\t/*\n+\t\t * For legacy reasons, the \"version\" and \"help\"\n+\t\t * commands can be written with \"--\" prepended\n+\t\t * to make them look like flags.\n+\t\t */\n+\t\tif (!strcmp(cmd, \"--help\") || !strcmp(cmd, \"--version\"))\n+\t\t\tbreak;\n+\n+\t\t/*\n+\t\t * Check remaining flags (which by now must be\n+\t\t * \"--exec-path\", but maybe we will accept\n+\t\t * other arguments some day)\n+\t\t */\n+\t\tif (!strncmp(cmd, \"--exec-path\", 11)) {\n+\t\t\tcmd += 11;\n+\t\t\tif (*cmd == '=')\n+\t\t\t\tgit_set_exec_path(cmd + 1);\n+\t\t\telse {\n+\t\t\t\tputs(git_exec_path());\n+\t\t\t\texit(0);\n+\t\t\t}\n+\t\t} else if (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n \t\t\tsetup_pager();\n-\t\t} else\n-\t\t\tdie (\"Unknown option: %s\", cmd);\n+\t\t} else if (!strcmp(cmd, \"--git-dir\")) {\n+\t\t\tif (*argc < 1)\n+\t\t\t\treturn -1;\n+\t\t\tsetenv(\"GIT_DIR\", (*argv)[1], 1);\n+\t\t\t(*argv)++;\n+\t\t\t(*argc)--;\n+\t\t} else if (!strncmp(cmd, \"--git-dir=\", 10)) {\n+\t\t\tsetenv(\"GIT_DIR\", cmd + 10, 1);\n+\t\t} else if (!strcmp(cmd, \"--bare\")) {\n+\t\t\tstatic char git_dir[1024];\n+\t\t\tsetenv(\"GIT_DIR\", getcwd(git_dir, 1024), 1);\n+\t\t} else {\n+\t\t\tfprintf(stderr, \"Unknown option: %s\\n\", cmd);\n+\t\t\tcmd_usage(0, NULL, NULL);\n+\t\t}\n \n \t\t(*argv)++;\n \t\t(*argc)--;\n@@ -294,50 +328,19 @@ int main(int argc, const char **argv, ch\n \t\tdie(\"cannot handle %s internally\", cmd);\n \t}\n \n-\t/* Default command: \"help\" */\n-\tcmd = \"help\";\n-\n \t/* Look for flags.. */\n-\twhile (argc > 1) {\n-\t\targv++;\n-\t\targc--;\n-\n-\t\thandle_options(&argv, &argc);\n-\t\t\t\n-\t\tcmd = *argv;\n-\n-\t\tif (strncmp(cmd, \"--\", 2))\n-\t\t\tbreak;\n-\n-\t\tcmd += 2;\n-\n-\t\t/*\n-\t\t * For legacy reasons, the \"version\" and \"help\"\n-\t\t * commands can be written with \"--\" prepended\n-\t\t * to make them look like flags.\n-\t\t */\n-\t\tif (!strcmp(cmd, \"help\"))\n-\t\t\tbreak;\n-\t\tif (!strcmp(cmd, \"version\"))\n-\t\t\tbreak;\n-\n-\t\t/*\n-\t\t * Check remaining flags (which by now must be\n-\t\t * \"--exec-path\", but maybe we will accept\n-\t\t * other arguments some day)\n-\t\t */\n-\t\tif (!strncmp(cmd, \"exec-path\", 9)) {\n-\t\t\tcmd += 9;\n-\t\t\tif (*cmd == '=') {\n-\t\t\t\tgit_set_exec_path(cmd + 1);\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tputs(git_exec_path());\n-\t\t\texit(0);\n-\t\t}\n-\t\tcmd_usage(0, NULL, NULL);\n+\targv++;\n+\targc--;\n+\thandle_options(&argv, &argc);\n+\tif (argc > 0) {\n+\t\tif (!strncmp(argv[0], \"--\", 2))\n+\t\t\targv[0] += 2;\n+\t} else {\n+\t\t/* Default command: \"help\" */\n+\t\targv[0] = \"help\";\n+\t\targc = 1;\n \t}\n-\targv[0] = cmd;\n+\tcmd = argv[0];\n \n \t/*\n \t * We search for git commands in the following order:\n-- \n1.4.2.rc1.g8b0c5\n"},{"id":"24104","messageId":"7v4px5e6ux.fsf@assigned-by-dhcp.cox.net","threadId":"4981","inReplyTo":"Pine.LNX.4.63.0607252022370.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-25T21:01:58Z","receivedAt":"2006-07-25T21:01:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> With this, you can say\n>\n> \tgit --bare repack -a -d\n>\n> inside a bare repository, and it will actually work. While at it,\n> also move the --version, --help and --exec-path options to the\n> handle_options() function.\n\nThanks.  Took a liberty cleaning up a few stuff, but will have\nboth alias-p and this patch in \"next\" shortly.\n"},{"id":"24124","messageId":"20060726061825.GA3638@informatik.uni-freiburg.de","threadId":"4981","inReplyTo":"Pine.LNX.4.63.0607251952000.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Uwe Zeisberger","fromEmail":"zeisberg@informatik.uni-freiburg.de","sentAt":"2006-07-26T06:18:25Z","receivedAt":"2006-07-26T06:18:25Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hi,\n\nJohannes Schindelin wrote:\n> > Since \"--git-dir\" makes more sense than \"--git-path\", I'd suggest just \n> > fixing the OPTIONS section ;)\n> \n> Will do. Thanks.\n\nWhen you're at it, you may want to change the Subject, too.\n\nOh, you already sent out a new patch with the old Subject :-)\n\nBest regards\nUwe\n-- \nUwe Zeisberger\n\nhttp://www.google.com/search?q=sin%28pi%2F2%29\n"},{"id":"24125","messageId":"7vfygou9ff.fsf@assigned-by-dhcp.cox.net","threadId":"4981","inReplyTo":"20060726061825.GA3638@informatik.uni-freiburg.de","subject":"Re: [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-26T07:12:04Z","receivedAt":"2006-07-26T07:12:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:\n\n> Johannes Schindelin wrote:\n>> > Since \"--git-dir\" makes more sense than \"--git-path\", I'd suggest just \n>> > fixing the OPTIONS section ;)\n>> \n>> Will do. Thanks.\n>\n> When you're at it, you may want to change the Subject, too.\n>\n> Oh, you already sent out a new patch with the old Subject :-)\n\nI've fixed things up to replace all --git-path with --git-dir, I\nthink.\n"}]}