{"thread":{"id":"7520","subject":"[PATCH] Make it possible to run git archive --remote without a git directory.","startedAt":"2007-04-05T08:12:37Z","lastAt":"2007-04-05T23:21:16Z","messageCount":3,"participants":["Simon Hausmann","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38685","messageId":"200704051012.37361.simon@lst.de","threadId":"7520","inReplyTo":null,"subject":"[PATCH] Make it possible to run git archive --remote without a git directory.","fromName":"Simon Hausmann","fromEmail":"simon@lst.de","sentAt":"2007-04-05T08:12:37Z","receivedAt":"2007-04-05T08:12:37Z","isPatch":true,"sender":{"key":"hausmann@kde.org","avatar":"https://gravatar.com/avatar/bc9aad4fb31dce17eb66e690e7b51fe980c62da3c225c785da35dd806b8da778?d=mp&s=160"},"body":"\nTry a gentle git directory setup for the archive command that remains fatal \nfor the local case but permits operation without a local git repository when \nusing --remote. If in the remote case a git directory is present it will then \nstill be used for proxy settings, but that is optional now.\n\nSigned-off-by: Simon Hausmann <simon@lst.de>\n---\n builtin-archive.c |    6 ++++++\n git.c             |    2 +-\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 2fae885..434fec7 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -243,11 +243,17 @@ int cmd_archive(int argc, const char **argv, const char \n*prefix)\n \tstruct archiver ar;\n \tint tree_idx;\n \tconst char *remote = NULL;\n+\tint nongit = 0;\n+\n+\tprefix = setup_git_directory_gently(&nongit);\n \n \tremote = extract_remote_arg(&argc, argv);\n \tif (remote)\n \t\treturn run_remote_archiver(remote, argc, argv);\n \n+\tif (nongit)\n+\t\tdie(\"Not a git repository\");\n+\n \tsetvbuf(stderr, NULL, _IOLBF, BUFSIZ);\n \n \tmemset(&ar, 0, sizeof(ar));\ndiff --git a/git.c b/git.c\nindex 5b1bc2a..33dd4d3 100644\n--- a/git.c\n+++ b/git.c\n@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char \n**argv, char **envp)\n \t\t{ \"add\", cmd_add, RUN_SETUP | NOT_BARE },\n \t\t{ \"annotate\", cmd_annotate, USE_PAGER },\n \t\t{ \"apply\", cmd_apply },\n-\t\t{ \"archive\", cmd_archive, RUN_SETUP },\n+\t\t{ \"archive\", cmd_archive },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n \t\t{ \"bundle\", cmd_bundle },\n-- \n1.5.1\n"},{"id":"38729","messageId":"200704052147.39255.simon@lst.de","threadId":"7520","inReplyTo":"200704051012.37361.simon@lst.de","subject":"Re: [PATCH] Make it possible to run git archive --remote without a git directory.","fromName":"Simon Hausmann","fromEmail":"simon@lst.de","sentAt":"2007-04-05T19:47:39Z","receivedAt":"2007-04-05T19:47:39Z","isPatch":true,"sender":{"key":"hausmann@kde.org","avatar":"https://gravatar.com/avatar/bc9aad4fb31dce17eb66e690e7b51fe980c62da3c225c785da35dd806b8da778?d=mp&s=160"},"body":"On Thursday 05 April 2007 10:12:37 Simon Hausmann wrote:\n[...]\n\nSorry, for replying to my own mail, but attached is a revised patch that also \nallows --list to work without a git dir, as pointed out by Jeff Garzik.\n\nWould be nice if the patch could be applied to git :)\n\n\nSimon\n\n\nFrom f893a0080d0af6d1f02c05de79d21598f614fa4b Mon Sep 17 00:00:00 2001\nFrom: Simon Hausmann <simon@lst.de>\nDate: Thu, 5 Apr 2007 10:03:19 +0200\nSubject: [PATCH] Make it possible to run git-archive --remote and --list without a git directory.\n\nTry a gentle git directory setup for the archive command that remains fatal for\nthe local case but permits operation without a local git repository when using\n--remote. If in the remote case a git directory is present it will then still be\nused for proxy settings, but that is optional now.\n\nSigned-off-by: Simon Hausmann <simon@lst.de>\n---\n builtin-archive.c |    6 ++++++\n git.c             |    2 +-\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 2fae885..8c2fe49 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -243,6 +243,9 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n \tstruct archiver ar;\n \tint tree_idx;\n \tconst char *remote = NULL;\n+\tint nongit = 0;\n+\n+\tprefix = setup_git_directory_gently(&nongit);\n \n \tremote = extract_remote_arg(&argc, argv);\n \tif (remote)\n@@ -253,6 +256,9 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n \tmemset(&ar, 0, sizeof(ar));\n \ttree_idx = parse_archive_args(argc, argv, &ar);\n \n+\tif (nongit)\n+\t\tdie(\"Not a git repository\");\n+\n \targv += tree_idx;\n \tparse_treeish_arg(argv, &ar.args, prefix);\n \tparse_pathspec_arg(argv + 1, &ar.args);\ndiff --git a/git.c b/git.c\nindex 5b1bc2a..33dd4d3 100644\n--- a/git.c\n+++ b/git.c\n@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)\n \t\t{ \"add\", cmd_add, RUN_SETUP | NOT_BARE },\n \t\t{ \"annotate\", cmd_annotate, USE_PAGER },\n \t\t{ \"apply\", cmd_apply },\n-\t\t{ \"archive\", cmd_archive, RUN_SETUP },\n+\t\t{ \"archive\", cmd_archive },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n \t\t{ \"bundle\", cmd_bundle },\n-- \n1.5.1\n\n"},{"id":"38762","messageId":"4615846C.9020705@lsrfire.ath.cx","threadId":"7520","inReplyTo":"200704052147.39255.simon@lst.de","subject":"Re: [PATCH] Make it possible to run git archive --remote without a git directory.","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2007-04-05T23:21:16Z","receivedAt":"2007-04-05T23:21:16Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Simon Hausmann schrieb:\n> On Thursday 05 April 2007 10:12:37 Simon Hausmann wrote:\n> [...]\n> \n> Sorry, for replying to my own mail, but attached is a revised patch that also \n> allows --list to work without a git dir, as pointed out by Jeff Garzik.\n> \n> Would be nice if the patch could be applied to git :)\n\nOh, saw your patch just now -- of course only _after_ I sent mine.\nStill, I like my patch better because it reverts the code to a known\ngood version and it adds a test case.  And maybe a little bit because\nit's mine. ;-)\n\nI forgot addressing the 'git-archive --remote' case, though.  The code\nis fine (i.e. --remote works outside a repo with the patch applied), but\na test case for that is missing.  Care to provide this missing piece on\ntop of my patch?\n\nThanks,\nRené\n"}]}