* [PATCH] Make it possible to run git archive --remote without a git directory.
@ 2007-04-05 8:12 Simon Hausmann
2007-04-05 19:47 ` Simon Hausmann
0 siblings, 1 reply; 3+ messages in thread
From: Simon Hausmann @ 2007-04-05 8:12 UTC (permalink / raw)
To: git
Try a gentle git directory setup for the archive command that remains fatal
for the local case but permits operation without a local git repository when
using --remote. If in the remote case a git directory is present it will then
still be used for proxy settings, but that is optional now.
Signed-off-by: Simon Hausmann <simon@lst.de>
---
builtin-archive.c | 6 ++++++
git.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-archive.c b/builtin-archive.c
index 2fae885..434fec7 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -243,11 +243,17 @@ int cmd_archive(int argc, const char **argv, const char
*prefix)
struct archiver ar;
int tree_idx;
const char *remote = NULL;
+ int nongit = 0;
+
+ prefix = setup_git_directory_gently(&nongit);
remote = extract_remote_arg(&argc, argv);
if (remote)
return run_remote_archiver(remote, argc, argv);
+ if (nongit)
+ die("Not a git repository");
+
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
memset(&ar, 0, sizeof(ar));
diff --git a/git.c b/git.c
index 5b1bc2a..33dd4d3 100644
--- a/git.c
+++ b/git.c
@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char
**argv, char **envp)
{ "add", cmd_add, RUN_SETUP | NOT_BARE },
{ "annotate", cmd_annotate, USE_PAGER },
{ "apply", cmd_apply },
- { "archive", cmd_archive, RUN_SETUP },
+ { "archive", cmd_archive },
{ "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
{ "bundle", cmd_bundle },
--
1.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Make it possible to run git archive --remote without a git directory.
2007-04-05 8:12 [PATCH] Make it possible to run git archive --remote without a git directory Simon Hausmann
@ 2007-04-05 19:47 ` Simon Hausmann
2007-04-05 23:21 ` René Scharfe
0 siblings, 1 reply; 3+ messages in thread
From: Simon Hausmann @ 2007-04-05 19:47 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 278 bytes --]
On Thursday 05 April 2007 10:12:37 Simon Hausmann wrote:
[...]
Sorry, for replying to my own mail, but attached is a revised patch that also
allows --list to work without a git dir, as pointed out by Jeff Garzik.
Would be nice if the patch could be applied to git :)
Simon
[-- Attachment #2: 0001-Make-it-possible-to-run-git-archive-remote-and-l.patch --]
[-- Type: text/x-diff, Size: 1970 bytes --]
From f893a0080d0af6d1f02c05de79d21598f614fa4b Mon Sep 17 00:00:00 2001
From: Simon Hausmann <simon@lst.de>
Date: Thu, 5 Apr 2007 10:03:19 +0200
Subject: [PATCH] Make it possible to run git-archive --remote and --list without a git directory.
Try a gentle git directory setup for the archive command that remains fatal for
the local case but permits operation without a local git repository when using
--remote. If in the remote case a git directory is present it will then still be
used for proxy settings, but that is optional now.
Signed-off-by: Simon Hausmann <simon@lst.de>
---
builtin-archive.c | 6 ++++++
git.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-archive.c b/builtin-archive.c
index 2fae885..8c2fe49 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -243,6 +243,9 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
struct archiver ar;
int tree_idx;
const char *remote = NULL;
+ int nongit = 0;
+
+ prefix = setup_git_directory_gently(&nongit);
remote = extract_remote_arg(&argc, argv);
if (remote)
@@ -253,6 +256,9 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
memset(&ar, 0, sizeof(ar));
tree_idx = parse_archive_args(argc, argv, &ar);
+ if (nongit)
+ die("Not a git repository");
+
argv += tree_idx;
parse_treeish_arg(argv, &ar.args, prefix);
parse_pathspec_arg(argv + 1, &ar.args);
diff --git a/git.c b/git.c
index 5b1bc2a..33dd4d3 100644
--- a/git.c
+++ b/git.c
@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "add", cmd_add, RUN_SETUP | NOT_BARE },
{ "annotate", cmd_annotate, USE_PAGER },
{ "apply", cmd_apply },
- { "archive", cmd_archive, RUN_SETUP },
+ { "archive", cmd_archive },
{ "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
{ "bundle", cmd_bundle },
--
1.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Make it possible to run git archive --remote without a git directory.
2007-04-05 19:47 ` Simon Hausmann
@ 2007-04-05 23:21 ` René Scharfe
0 siblings, 0 replies; 3+ messages in thread
From: René Scharfe @ 2007-04-05 23:21 UTC (permalink / raw)
To: Simon Hausmann; +Cc: git, Junio C Hamano
Simon Hausmann schrieb:
> On Thursday 05 April 2007 10:12:37 Simon Hausmann wrote:
> [...]
>
> Sorry, for replying to my own mail, but attached is a revised patch that also
> allows --list to work without a git dir, as pointed out by Jeff Garzik.
>
> Would be nice if the patch could be applied to git :)
Oh, saw your patch just now -- of course only _after_ I sent mine.
Still, I like my patch better because it reverts the code to a known
good version and it adds a test case. And maybe a little bit because
it's mine. ;-)
I forgot addressing the 'git-archive --remote' case, though. The code
is fine (i.e. --remote works outside a repo with the patch applied), but
a test case for that is missing. Care to provide this missing piece on
top of my patch?
Thanks,
René
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-05 23:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-05 8:12 [PATCH] Make it possible to run git archive --remote without a git directory Simon Hausmann
2007-04-05 19:47 ` Simon Hausmann
2007-04-05 23:21 ` René Scharfe
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).