{"thread":{"id":"16008","subject":"git archive","startedAt":"2008-10-22T08:42:01Z","lastAt":"2008-10-25T19:15:08Z","messageCount":14,"participants":["kenneth johansson","Deskin Miller","Jeff King","Charles Bailey","Nguyen Thai Ngoc Duy","René Scharfe","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"93667","messageId":"gdmp0p$92r$1@ger.gmane.org","threadId":"16008","inReplyTo":null,"subject":"git archive","fromName":"kenneth johansson","fromEmail":"ken@kenjo.org","sentAt":"2008-10-22T08:42:01Z","receivedAt":"2008-10-22T08:42:01Z","isPatch":false,"sender":{"key":"ken@kenjo.org","avatar":null},"body":"I was going to make a tar of the latest stable linux kernel. \nDone it before but now I got a strange problem. \n\n>git archive --format=tar v2.6.27.2\nfatal: Not a valid object name\n\nthis is the output from some other command on the same bare repository.\n\n>git tag | grep 2.6.27.2\nv2.6.27.2\n\n>git cat-file -p v2.6.27.2\nobject 6bcd6d778419101dd96cbbdf03eeab8d779b1d66\ntype commit\ntag v2.6.27.2\ntagger Greg Kroah-Hartman <gregkh@suse.de> Sat Oct 18 10:58:00 2008 -0700\n\nThis is the v2.6.27.2 stable release\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v2.0.9 (GNU/Linux)\n\niEYEABECAAYFAkj6I6sACgkQMUfUDdst+ylcigCg0/e3kQZwAqLp6wPuPqdWl7nL\nX0wAnjuNPJG1OqZfhMiAGccLx0QGvMQz\n=INvo\n-----END PGP SIGNATURE-----\n\n>git cat-file -p 6bcd6d778419101dd96cbbdf03eeab8d779b1d66\ntree a717af81e5a2e8a7ee36f3b80aa077965f570197\nparent 6505670551fa3deeb6e5d7cab6983514384c7220\nauthor Greg Kroah-Hartman <gregkh@suse.de> 1224352642 -0700\ncommitter Greg Kroah-Hartman <gregkh@suse.de> 1224352642 -0700\n\nLinux 2.6.27.2\n\n\n>git archive --format=tar a717af81e5a2e8a7ee36f3b80aa077965f570197\nfatal: not a tree object\n\n>git cat-file -t a717af81e5a2e8a7ee36f3b80aa077965f570197\ntree\n"},{"id":"93682","messageId":"20081022130829.GC2015@riemann.deskinm.fdns.net","threadId":"16008","inReplyTo":"gdmp0p$92r$1@ger.gmane.org","subject":"Re: git archive","fromName":"Deskin Miller","fromEmail":"deskinm@umich.edu","sentAt":"2008-10-22T13:08:29Z","receivedAt":"2008-10-22T13:08:29Z","isPatch":false,"sender":{"key":"deskinm@umich.edu","avatar":"https://gravatar.com/avatar/d340a0e612cdf0a79535c71863c0b4c535e9aba63b42032226ae903e638b64f9?d=mp&s=160"},"body":"On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n> I was going to make a tar of the latest stable linux kernel. \n> Done it before but now I got a strange problem. \n> \n> >git archive --format=tar v2.6.27.2\n> fatal: Not a valid object name\n\nI had the same thing happen to me, while trying to make an archive of Git.\nWere you perchance working in a bare repository, as I was?  I spent some time\nlooking at it and I think git archive sets up the environment in the wrong\norder, though of course I never finished a patch so I'm going from memory:\n\nAfter looking at the code again, I think the issue is that git_config is called\nin builtin-archive.c:cmd_archive before setup_git_directory is called in\narchive.c:write_archive.  The former ends up setting GIT_DIR to be '.git' even\nif you're in a bare repository.  My coding skills weren't up to fixing it\neasily; moving setup_git_directory before git_config in builtin-archive caused\nlast test of t5000 to fail: GIT_DIR=some/nonexistent/path git archive --list\nshould still display the archive formats.\n\nAnother vote for from me for the discussion carried on here:\nhttp://article.gmane.org/gmane.comp.version-control.git/98800\n\nDeskin Miller\n"},{"id":"93704","messageId":"gdnsca$92r$2@ger.gmane.org","threadId":"16008","inReplyTo":"20081022130829.GC2015@riemann.deskinm.fdns.net","subject":"Re: git archive","fromName":"kenneth johansson","fromEmail":"ken@kenjo.org","sentAt":"2008-10-22T18:45:30Z","receivedAt":"2008-10-22T18:45:30Z","isPatch":false,"sender":{"key":"ken@kenjo.org","avatar":null},"body":"On Wed, 22 Oct 2008 09:08:29 -0400, Deskin Miller wrote:\n\n> On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n>> I was going to make a tar of the latest stable linux kernel. Done it\n>> before but now I got a strange problem.\n>> \n>> >git archive --format=tar v2.6.27.2\n>> fatal: Not a valid object name\n> \n> I had the same thing happen to me, while trying to make an archive of\n> Git. Were you perchance working in a bare repository, as I was?  I spent\n> some time looking at it and I think git archive sets up the environment\n> in the wrong order, though of course I never finished a patch so I'm\n> going from memory:\n\nYes it was a bare repository.\n\n> \n> After looking at the code again, I think the issue is that git_config is\n> called in builtin-archive.c:cmd_archive before setup_git_directory is\n> called in archive.c:write_archive.  The former ends up setting GIT_DIR\n> to be '.git' even if you're in a bare repository.  My coding skills\n> weren't up to fixing it easily; moving setup_git_directory before\n> git_config in builtin-archive caused last test of t5000 to fail:\n> GIT_DIR=some/nonexistent/path git archive --list should still display\n> the archive formats.\n\nif I do\nGIT_DIR=. git  archive --format=tar v2.6.27.2\n\nit does work so it looks like you are on the right track.\n"},{"id":"93725","messageId":"20081022203722.GD2015@riemann.deskinm.fdns.net","threadId":"16008","inReplyTo":"gdnsca$92r$2@ger.gmane.org","subject":"[RFC PATCH] archive: fix setup to work in bare repositories","fromName":"Deskin Miller","fromEmail":"deskinm@umich.edu","sentAt":"2008-10-22T20:37:22Z","receivedAt":"2008-10-22T20:37:22Z","isPatch":true,"sender":{"key":"deskinm@umich.edu","avatar":"https://gravatar.com/avatar/d340a0e612cdf0a79535c71863c0b4c535e9aba63b42032226ae903e638b64f9?d=mp&s=160"},"body":"cmd_archive was calling git_config -> setup_git_env prior to\nwrite_archive calling setup_git_directory.  In a bare repository, the\nformer will set git_dir to be '.git' since the latter has not\ndetermined that it's operating in a bare repository yet.\n\nThings are complicated, however, by the fact that git archive --list\nshould work from anywhere, not just in git repositories, so that\nargument needs to be checked for before setup_git_directory is called.\n---\nOn Wed, Oct 22, 2008 at 06:45:30PM +0000, kenneth johansson wrote:\n> On Wed, 22 Oct 2008 09:08:29 -0400, Deskin Miller wrote:\n> \n> > On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n> >> I was going to make a tar of the latest stable linux kernel. Done it\n> >> before but now I got a strange problem.\n> >> \n> >> >git archive --format=tar v2.6.27.2\n> >> fatal: Not a valid object name\n> > \n> > I had the same thing happen to me, while trying to make an archive of\n> > Git. Were you perchance working in a bare repository, as I was?  I spent\n> > some time looking at it and I think git archive sets up the environment\n> > in the wrong order, though of course I never finished a patch so I'm\n> > going from memory:\n> \n> Yes it was a bare repository.\n> \n> > \n> > After looking at the code again, I think the issue is that git_config is\n> > called in builtin-archive.c:cmd_archive before setup_git_directory is\n> > called in archive.c:write_archive.  The former ends up setting GIT_DIR\n> > to be '.git' even if you're in a bare repository.  My coding skills\n> > weren't up to fixing it easily; moving setup_git_directory before\n> > git_config in builtin-archive caused last test of t5000 to fail:\n> > GIT_DIR=some/nonexistent/path git archive --list should still display\n> > the archive formats.\n> \n> if I do\n> GIT_DIR=. git  archive --format=tar v2.6.27.2\n> \n> it does work so it looks like you are on the right track.\n\nLooks like this works, but I think it's really ugly; let me know if you have\nany suggestions for improvement.\n\n archive.c           |   13 +++++++++++++\n archive.h           |    1 +\n builtin-archive.c   |    4 +++-\n t/t5000-tar-tree.sh |    9 +++++++++\n 4 files changed, 26 insertions(+), 1 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex e2280df..d8e4373 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -325,6 +325,19 @@ static int parse_archive_args(int argc, const char **argv,\n \treturn argc;\n }\n \n+int archive_parse_options_early(int argc, const char **argv)\n+{\n+\tint i;\n+\tfor (i = 1; i < argc; ++i) {\n+\t\tif (!strcmp(argv[i], \"--list\")) {\n+\t\t\tfor (i = 0; i < ARRAY_SIZE(archivers); i++)\n+\t\t\t\tprintf(\"%s\\n\", archivers[i].name);\n+\t\t\texit(0);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n int write_archive(int argc, const char **argv, const char *prefix,\n \t\tint setup_prefix)\n {\ndiff --git a/archive.h b/archive.h\nindex 0b15b35..ff5b6cf 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -24,6 +24,7 @@ extern int write_tar_archive(struct archiver_args *);\n extern int write_zip_archive(struct archiver_args *);\n \n extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);\n+extern int archive_parse_options_early(int argc, const char **argv);\n extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix);\n \n #endif\t/* ARCHIVE_H */\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 432ce2a..e518113 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -111,6 +111,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n {\n \tconst char *remote = NULL;\n \n+\tarchive_parse_options_early(argc, argv);\n+\tprefix = setup_git_directory();\n \tgit_config(git_default_config, NULL);\n \n \tremote = extract_remote_arg(&argc, argv);\n@@ -119,5 +121,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n \n \tsetvbuf(stderr, NULL, _IOLBF, BUFSIZ);\n \n-\treturn write_archive(argc, argv, prefix, 1);\n+\treturn write_archive(argc, argv, prefix, 0);\n }\ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex e395ff4..53fe25c 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -192,4 +192,13 @@ test_expect_success \\\n     'git archive --list outside of a git repo' \\\n     'GIT_DIR=some/non-existing/directory git archive --list'\n \n+test_expect_success \\\n+    'git archive inside bare repository' \\\n+    'git clone --bare \"$(pwd)\"/.git trash-bare &&\n+    cd trash-bare &&\n+    git archive --format=tar HEAD >/dev/null &&\n+    cd .. &&\n+    rm -rf trash-bare\n+    '\n+\n test_done\n-- \n1.6.0.2.554.g3041b\n"},{"id":"93727","messageId":"20081022204650.GD4585@coredump.intra.peff.net","threadId":"16008","inReplyTo":"20081022203722.GD2015@riemann.deskinm.fdns.net","subject":"Re: [RFC PATCH] archive: fix setup to work in bare repositories","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-22T20:46:50Z","receivedAt":"2008-10-22T20:46:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 22, 2008 at 04:37:22PM -0400, Deskin Miller wrote:\n\n> cmd_archive was calling git_config -> setup_git_env prior to\n> write_archive calling setup_git_directory.  In a bare repository, the\n> former will set git_dir to be '.git' since the latter has not\n> determined that it's operating in a bare repository yet.\n> \n> Things are complicated, however, by the fact that git archive --list\n> should work from anywhere, not just in git repositories, so that\n> argument needs to be checked for before setup_git_directory is called.\n\nShould you perhaps be able to call setup_git_directory_gently(), and\nthen once you decide that you really do need the setup, call\nsetup_git_directory()?\n\nYou would have to add a \"did we already do run\" flag to\nsetup_git_directory_gently(), but I think it is already an error to call\nit twice, so you wouldn't be hurting anything by that.\n\nNote also that by moving the setup, you are moving the chdir() that\nhappens; you may need to prefix paths to any arguments to accomodate\nthis (I don't think it should matter, since git-archive shouldn't look\nat any paths until after it would have done the setup_git_directory()\nbefore, but I didn't check carefully).\n\n-Peff\n"},{"id":"93728","messageId":"20081022210913.GB22541@hashpling.org","threadId":"16008","inReplyTo":"20081022203722.GD2015@riemann.deskinm.fdns.net","subject":"Re: [RFC PATCH] archive: fix setup to work in bare repositories","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2008-10-22T21:09:13Z","receivedAt":"2008-10-22T21:09:13Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Wed, Oct 22, 2008 at 04:37:22PM -0400, Deskin Miller wrote:\n> cmd_archive was calling git_config -> setup_git_env prior to\n> write_archive calling setup_git_directory.  In a bare repository, the\n> former will set git_dir to be '.git' since the latter has not\n> determined that it's operating in a bare repository yet.\n> \n> Things are complicated, however, by the fact that git archive --list\n> should work from anywhere, not just in git repositories, so that\n> argument needs to be checked for before setup_git_directory is called.\n\nJust for some background, I think that this issue might be an\nunintended consequence of this commit:\n\nb99b5b40cffb5269e4aa38b6b60391b55039e27d\n\nThe only reason that the git_config call has been added is to ensure\nthe correct setting of core.autocrlf before convert_to_working_tree is\ncalled on any blobs.\n\nI haven't looked in detail, but would moving this call later make for\nan cleaner change?\n\n-- \nCharles Bailey\nhttp://ccgi.hashpling.plus.com/blog/\n"},{"id":"93733","messageId":"1224712023-5280-1-git-send-email-charles@hashpling.org","threadId":"16008","inReplyTo":"20081022210913.GB22541@hashpling.org","subject":"[PATCH] Fixed git archive for bare repos","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2008-10-22T21:47:03Z","receivedAt":"2008-10-22T21:47:03Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"This moves the call to git config to a place where it doesn't break the\nlogic for using git archive in a bare repository but retains the fix to\nmake git archive respect core.autocrlf.\n\nSigned-off-by: Charles Bailey <charles@hashpling.org>\n---\n\nOK, I've had a chance to have a quick look at this issue and I have an\naltenative patch.\n\nThis is an alternative fix to the current git archive in a bare\nrepository issue.\n\nIt's been lightly tested and doesn't re-break the zip / autocrlf issue\nthat the previous introduction of git_config was designed to fix.\n\n archive.c         |    2 ++\n builtin-archive.c |    2 --\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 849eed5..9ac455d 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -336,5 +336,7 @@ int write_archive(int argc, const char **argv, const char *prefix,\n \tparse_treeish_arg(argv, &args, prefix);\n \tparse_pathspec_arg(argv + 1, &args);\n \n+\tgit_config(git_default_config, NULL);\n+\n \treturn ar->write_archive(&args);\n }\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 432ce2a..5ceec43 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -111,8 +111,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n {\n \tconst char *remote = NULL;\n \n-\tgit_config(git_default_config, NULL);\n-\n \tremote = extract_remote_arg(&argc, argv);\n \tif (remote)\n \t\treturn run_remote_archiver(remote, argc, argv);\n-- \n1.6.0.2.534.g5ab59\n"},{"id":"93756","messageId":"20081023013703.GE2015@riemann.deskinm.fdns.net","threadId":"16008","inReplyTo":"1224712023-5280-1-git-send-email-charles@hashpling.org","subject":"Re: [PATCH] Fixed git archive for bare repos","fromName":"Deskin Miller","fromEmail":"deskinm@umich.edu","sentAt":"2008-10-23T01:37:03Z","receivedAt":"2008-10-23T01:37:03Z","isPatch":true,"sender":{"key":"deskinm@umich.edu","avatar":"https://gravatar.com/avatar/d340a0e612cdf0a79535c71863c0b4c535e9aba63b42032226ae903e638b64f9?d=mp&s=160"},"body":"On Wed, Oct 22, 2008 at 10:47:03PM +0100, Charles Bailey wrote:\n> OK, I've had a chance to have a quick look at this issue and I have an\n> altenative patch.\n\nThanks for making this much simpler than my version was; it passes the testcase\nI wrote, as well as the rest of the testsuite, so if you want to include my\ntestcase (or an equivalent one) and re-send, consider it\n\nTested-by: Deskin Miller <deskinm@umich.edu>\n"},{"id":"93791","messageId":"fcaeb9bf0810230833i3953a5abt2d2ba6ca1b751754@mail.gmail.com","threadId":"16008","inReplyTo":"20081022130829.GC2015@riemann.deskinm.fdns.net","subject":"Re: git archive","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-10-23T15:33:31Z","receivedAt":"2008-10-23T15:33:31Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 10/22/08, Deskin Miller <deskinm@umich.edu> wrote:\n> On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n>  > I was going to make a tar of the latest stable linux kernel.\n>  > Done it before but now I got a strange problem.\n>  >\n>  > >git archive --format=tar v2.6.27.2\n>  > fatal: Not a valid object name\n>\n>\n> I had the same thing happen to me, while trying to make an archive of Git.\n>  Were you perchance working in a bare repository, as I was?  I spent some time\n>  looking at it and I think git archive sets up the environment in the wrong\n>  order, though of course I never finished a patch so I'm going from memory:\n>\n>  After looking at the code again, I think the issue is that git_config is called\n>  in builtin-archive.c:cmd_archive before setup_git_directory is called in\n>  archive.c:write_archive.  The former ends up setting GIT_DIR to be '.git' even\n>  if you're in a bare repository.  My coding skills weren't up to fixing it\n>  easily; moving setup_git_directory before git_config in builtin-archive caused\n>  last test of t5000 to fail: GIT_DIR=some/nonexistent/path git archive --list\n>  should still display the archive formats.\n\nThe problem affects some other commands as well. I tried the following\npatch, ran \"make test\" and discovered \"git mailinfo\", \"git\nverify-pack\", \"git hash-object\" and \"git unpack-file\". A bandage patch\nis at the end of this mail. Solution is as Jeff suggested: call\nsetup_git_directory_gently() early.\n\n---<---\ndiff --git a/environment.c b/environment.c\nindex 0693cd9..00ed640 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -49,14 +49,18 @@ static char *work_tree;\n\n static const char *git_dir;\n static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;\n+int git_dir_discovered;\n\n static void setup_git_env(void)\n {\n \tgit_dir = getenv(GIT_DIR_ENVIRONMENT);\n \tif (!git_dir)\n \t\tgit_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);\n-\tif (!git_dir)\n+\tif (!git_dir) {\n+\t\tif (!git_dir_discovered)\n+\t\t\tdie(\"Internal error: .git must be relocated at cwd by setup_git_*\");\n \t\tgit_dir = DEFAULT_GIT_DIR_ENVIRONMENT;\n+\t}\n \tgit_object_dir = getenv(DB_ENVIRONMENT);\n \tif (!git_object_dir) {\n \t\tgit_object_dir = xmalloc(strlen(git_dir) + 9);\ndiff --git a/setup.c b/setup.c\nindex 78a8041..d404c21 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -368,6 +368,7 @@ const char *read_gitfile_gently(const char *path)\n  * We cannot decide in this function whether we are in the work tree or\n  * not, since the config can only be read _after_ this function was called.\n  */\n+extern int git_dir_discovered;\n const char *setup_git_directory_gently(int *nongit_ok)\n {\n \tconst char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n@@ -472,6 +473,8 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t}\n \t\tchdir(\"..\");\n \t}\n+\t/* It is safe to call setup_git_env() now */\n+\tgit_dir_discovered = 1;\n\n \tinside_git_dir = 0;\n \tif (!work_tree_env)\n---<---\n\n\nBandage patch:\n\n---<---\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 432ce2a..5ea0a12 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -110,7 +110,9 @@ static const char *extract_remote_arg(int *ac,\nconst char **av)\n int cmd_archive(int argc, const char **argv, const char *prefix)\n {\n \tconst char *remote = NULL;\n+\tint nongit;\n\n+\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_default_config, NULL);\n\n \tremote = extract_remote_arg(&argc, argv);\ndiff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\nindex e890f7a..5d401fb 100644\n--- a/builtin-mailinfo.c\n+++ b/builtin-mailinfo.c\n@@ -916,10 +916,9 @@ static const char mailinfo_usage[] =\n int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n {\n \tconst char *def_charset;\n+\tint nongit;\n\n-\t/* NEEDSWORK: might want to do the optional .git/ directory\n-\t * discovery\n-\t */\n+\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_default_config, NULL);\n\n \tdef_charset = (git_commit_encoding ? git_commit_encoding : \"utf-8\");\ndiff --git a/builtin-verify-pack.c b/builtin-verify-pack.c\nindex 25a29f1..35a4eb2 100644\n--- a/builtin-verify-pack.c\n+++ b/builtin-verify-pack.c\n@@ -115,7 +115,9 @@ int cmd_verify_pack(int argc, const char **argv,\nconst char *prefix)\n \tint verbose = 0;\n \tint no_more_options = 0;\n \tint nothing_done = 1;\n+\tint nongit;\n\n+\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_default_config, NULL);\n \twhile (1 < argc) {\n \t\tif (!no_more_options && argv[1][0] == '-') {\ndiff --git a/hash-object.c b/hash-object.c\nindex 20937ff..a52b6be 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -78,19 +78,20 @@ int main(int argc, const char **argv)\n \tconst char *prefix = NULL;\n \tint prefix_length = -1;\n \tconst char *errstr = NULL;\n+\tint nongit;\n\n \ttype = blob_type;\n\n-\tgit_config(git_default_config, NULL);\n-\n \targc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);\n\n-\tif (write_object) {\n-\t\tprefix = setup_git_directory();\n-\t\tprefix_length = prefix ? strlen(prefix) : 0;\n-\t\tif (vpath && prefix)\n-\t\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n-\t}\n+\tprefix = setup_git_directory_gently(&nongit);\n+\tgit_config(git_default_config, NULL);\n+\tprefix_length = prefix ? strlen(prefix) : 0;\n+\tif (vpath && prefix)\n+\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n+\n+\tif (write_object && nongit)\n+\t\tdie(\"Git repository required\");\n\n \tif (stdin_paths) {\n \t\tif (hashstdin)\ndiff --git a/unpack-file.c b/unpack-file.c\nindex bcdc8bb..1a58d72 100644\n--- a/unpack-file.c\n+++ b/unpack-file.c\n@@ -27,10 +27,10 @@ int main(int argc, char **argv)\n\n \tif (argc != 2)\n \t\tusage(\"git-unpack-file <sha1>\");\n+\tsetup_git_directory();\n \tif (get_sha1(argv[1], sha1))\n \t\tdie(\"Not a valid object name %s\", argv[1]);\n\n-\tsetup_git_directory();\n \tgit_config(git_default_config, NULL);\n\n \tputs(create_temp_file(sha1));\n---<---\n-- \nDuy\n"},{"id":"93796","messageId":"20081023182103.GA8320@euler","threadId":"16008","inReplyTo":"fcaeb9bf0810230833i3953a5abt2d2ba6ca1b751754@mail.gmail.com","subject":"Re: git archive","fromName":"Deskin Miller","fromEmail":"deskinm@umich.edu","sentAt":"2008-10-23T18:21:03Z","receivedAt":"2008-10-23T18:21:03Z","isPatch":false,"sender":{"key":"deskinm@umich.edu","avatar":"https://gravatar.com/avatar/d340a0e612cdf0a79535c71863c0b4c535e9aba63b42032226ae903e638b64f9?d=mp&s=160"},"body":"On Thu, Oct 23, 2008 at 10:33:31PM +0700, Nguyen Thai Ngoc Duy wrote:\n> On 10/22/08, Deskin Miller <deskinm@umich.edu> wrote:\n> > On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n> >  > I was going to make a tar of the latest stable linux kernel.\n> >  > Done it before but now I got a strange problem.\n> >  >\n> >  > >git archive --format=tar v2.6.27.2\n> >  > fatal: Not a valid object name\n> >\n> >\n> > I had the same thing happen to me, while trying to make an archive of Git.\n> >  Were you perchance working in a bare repository, as I was?  I spent some time\n> >  looking at it and I think git archive sets up the environment in the wrong\n> >  order, though of course I never finished a patch so I'm going from memory:\n> >\n> >  After looking at the code again, I think the issue is that git_config is called\n> >  in builtin-archive.c:cmd_archive before setup_git_directory is called in\n> >  archive.c:write_archive.  The former ends up setting GIT_DIR to be '.git' even\n> >  if you're in a bare repository.  My coding skills weren't up to fixing it\n> >  easily; moving setup_git_directory before git_config in builtin-archive caused\n> >  last test of t5000 to fail: GIT_DIR=some/nonexistent/path git archive --list\n> >  should still display the archive formats.\n> \n> The problem affects some other commands as well. I tried the following\n> patch, ran \"make test\" and discovered \"git mailinfo\", \"git\n> verify-pack\", \"git hash-object\" and \"git unpack-file\". A bandage patch\n> is at the end of this mail. Solution is as Jeff suggested: call\n> setup_git_directory_gently() early.\n\nNice work.  The patches look like they're on the right track (to me at least).\nI'm not sure though what you want to ultimately submit as a patch; I'd suggest\nboth, squashed into one, since the check seems like something we'd reasonably\nwant no matter what.\n\nFew comments spread around below; also, can we see some testcases for\nregression?  Or, does the first patch preclude the need for testcases?\n\nDeskin Miller\n \n> ---<---\n> diff --git a/environment.c b/environment.c\n> index 0693cd9..00ed640 100644\n> --- a/environment.c\n> +++ b/environment.c\n> @@ -49,14 +49,18 @@ static char *work_tree;\n> \n>  static const char *git_dir;\n>  static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;\n> +int git_dir_discovered;\n\nShould this be 'int git_dir_discovered = 0;' ?\n \n>  static void setup_git_env(void)\n>  {\n>  \tgit_dir = getenv(GIT_DIR_ENVIRONMENT);\n>  \tif (!git_dir)\n>  \t\tgit_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);\n> -\tif (!git_dir)\n> +\tif (!git_dir) {\n> +\t\tif (!git_dir_discovered)\n> +\t\t\tdie(\"Internal error: .git must be relocated at cwd by setup_git_*\");\n>  \t\tgit_dir = DEFAULT_GIT_DIR_ENVIRONMENT;\n> +\t}\n>  \tgit_object_dir = getenv(DB_ENVIRONMENT);\n>  \tif (!git_object_dir) {\n>  \t\tgit_object_dir = xmalloc(strlen(git_dir) + 9);\n> diff --git a/setup.c b/setup.c\n> index 78a8041..d404c21 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -368,6 +368,7 @@ const char *read_gitfile_gently(const char *path)\n>   * We cannot decide in this function whether we are in the work tree or\n>   * not, since the config can only be read _after_ this function was called.\n>   */\n> +extern int git_dir_discovered;\n>  const char *setup_git_directory_gently(int *nongit_ok)\n>  {\n>  \tconst char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n> @@ -472,6 +473,8 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>  \t\t}\n>  \t\tchdir(\"..\");\n>  \t}\n> +\t/* It is safe to call setup_git_env() now */\n> +\tgit_dir_discovered = 1;\n> \n>  \tinside_git_dir = 0;\n>  \tif (!work_tree_env)\n> ---<---\n> \n> \n> Bandage patch:\n> \n> ---<---\n> diff --git a/builtin-archive.c b/builtin-archive.c\n> index 432ce2a..5ea0a12 100644\n> --- a/builtin-archive.c\n> +++ b/builtin-archive.c\n> @@ -110,7 +110,9 @@ static const char *extract_remote_arg(int *ac,\n> const char **av)\n>  int cmd_archive(int argc, const char **argv, const char *prefix)\n>  {\n>  \tconst char *remote = NULL;\n> +\tint nongit;\n>\n> +\tprefix = setup_git_directory_gently(&nongit);\n\nHere and elsewhere, the 'nongit' variable isn't used.\nsetup_git_directory_gently can be passed a NULL pointer, why not do that?\n\n>  \tgit_config(git_default_config, NULL);\n> \n>  \tremote = extract_remote_arg(&argc, argv);\n> diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\n> index e890f7a..5d401fb 100644\n> --- a/builtin-mailinfo.c\n> +++ b/builtin-mailinfo.c\n> @@ -916,10 +916,9 @@ static const char mailinfo_usage[] =\n>  int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n>  {\n>  \tconst char *def_charset;\n> +\tint nongit;\n> \n> -\t/* NEEDSWORK: might want to do the optional .git/ directory\n> -\t * discovery\n> -\t */\n> +\tprefix = setup_git_directory_gently(&nongit);\n\nSame 'nongit' issue.\n\n>  \tgit_config(git_default_config, NULL);\n> \n>  \tdef_charset = (git_commit_encoding ? git_commit_encoding : \"utf-8\");\n> diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c\n> index 25a29f1..35a4eb2 100644\n> --- a/builtin-verify-pack.c\n> +++ b/builtin-verify-pack.c\n> @@ -115,7 +115,9 @@ int cmd_verify_pack(int argc, const char **argv,\n> const char *prefix)\n>  \tint verbose = 0;\n>  \tint no_more_options = 0;\n>  \tint nothing_done = 1;\n> +\tint nongit;\n> \n> +\tprefix = setup_git_directory_gently(&nongit);\n\nSame 'nongit' issue.\n\n>  \tgit_config(git_default_config, NULL);\n>  \twhile (1 < argc) {\n>  \t\tif (!no_more_options && argv[1][0] == '-') {\n> diff --git a/hash-object.c b/hash-object.c\n> index 20937ff..a52b6be 100644\n> --- a/hash-object.c\n> +++ b/hash-object.c\n> @@ -78,19 +78,20 @@ int main(int argc, const char **argv)\n>  \tconst char *prefix = NULL;\n>  \tint prefix_length = -1;\n>  \tconst char *errstr = NULL;\n> +\tint nongit;\n> \n>  \ttype = blob_type;\n> \n> -\tgit_config(git_default_config, NULL);\n> -\n>  \targc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);\n> \n> -\tif (write_object) {\n> -\t\tprefix = setup_git_directory();\n> -\t\tprefix_length = prefix ? strlen(prefix) : 0;\n> -\t\tif (vpath && prefix)\n> -\t\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n> -\t}\n> +\tprefix = setup_git_directory_gently(&nongit);\n> +\tgit_config(git_default_config, NULL);\n> +\tprefix_length = prefix ? strlen(prefix) : 0;\n> +\tif (vpath && prefix)\n> +\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n> +\n> +\tif (write_object && nongit)\n> +\t\tdie(\"Git repository required\");\n\nI'd move this check up to just after setup_git_directory_gently.\n \n>  \tif (stdin_paths) {\n>  \t\tif (hashstdin)\n> diff --git a/unpack-file.c b/unpack-file.c\n> index bcdc8bb..1a58d72 100644\n> --- a/unpack-file.c\n> +++ b/unpack-file.c\n> @@ -27,10 +27,10 @@ int main(int argc, char **argv)\n> \n>  \tif (argc != 2)\n>  \t\tusage(\"git-unpack-file <sha1>\");\n> +\tsetup_git_directory();\n>  \tif (get_sha1(argv[1], sha1))\n>  \t\tdie(\"Not a valid object name %s\", argv[1]);\n> \n> -\tsetup_git_directory();\n>  \tgit_config(git_default_config, NULL);\n> \n>  \tputs(create_temp_file(sha1));\n> ---<---\n> -- \n> Duy\n"},{"id":"93824","messageId":"fcaeb9bf0810232058j1c52b824rbb51258e65f7a510@mail.gmail.com","threadId":"16008","inReplyTo":"20081023182103.GA8320@euler","subject":"Re: git archive","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-10-24T03:58:53Z","receivedAt":"2008-10-24T03:58:53Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 10/24/08, Deskin Miller <deskinm@umich.edu> wrote:\n> On Thu, Oct 23, 2008 at 10:33:31PM +0700, Nguyen Thai Ngoc Duy wrote:\n>  > On 10/22/08, Deskin Miller <deskinm@umich.edu> wrote:\n>  > > On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:\n>  > >  > I was going to make a tar of the latest stable linux kernel.\n>  > >  > Done it before but now I got a strange problem.\n>  > >  >\n>  > >  > >git archive --format=tar v2.6.27.2\n>  > >  > fatal: Not a valid object name\n>  > >\n>  > >\n>  > > I had the same thing happen to me, while trying to make an archive of Git.\n>  > >  Were you perchance working in a bare repository, as I was?  I spent some time\n>  > >  looking at it and I think git archive sets up the environment in the wrong\n>  > >  order, though of course I never finished a patch so I'm going from memory:\n>  > >\n>  > >  After looking at the code again, I think the issue is that git_config is called\n>  > >  in builtin-archive.c:cmd_archive before setup_git_directory is called in\n>  > >  archive.c:write_archive.  The former ends up setting GIT_DIR to be '.git' even\n>  > >  if you're in a bare repository.  My coding skills weren't up to fixing it\n>  > >  easily; moving setup_git_directory before git_config in builtin-archive caused\n>  > >  last test of t5000 to fail: GIT_DIR=some/nonexistent/path git archive --list\n>  > >  should still display the archive formats.\n>  >\n>  > The problem affects some other commands as well. I tried the following\n>  > patch, ran \"make test\" and discovered \"git mailinfo\", \"git\n>  > verify-pack\", \"git hash-object\" and \"git unpack-file\". A bandage patch\n>  > is at the end of this mail. Solution is as Jeff suggested: call\n>  > setup_git_directory_gently() early.\n>\n>\n> Nice work.  The patches look like they're on the right track (to me at least).\n>  I'm not sure though what you want to ultimately submit as a patch; I'd suggest\n>  both, squashed into one, since the check seems like something we'd reasonably\n>  want no matter what.\n\nNo, the patches are not in good shape and have not been tested well. I\njust wanted to point out the problem in other commands. Ideally the\ncheck in setup_git_env() should go along with discover_git_directory()\nas part of git setup rework.\n\n>\n>  Few comments spread around below; also, can we see some testcases for\n>  regression?  Or, does the first patch preclude the need for testcases?\n>\n>  Deskin Miller\n>\n>\n>  > ---<---\n>  > diff --git a/environment.c b/environment.c\n>  > index 0693cd9..00ed640 100644\n>  > --- a/environment.c\n>  > +++ b/environment.c\n>  > @@ -49,14 +49,18 @@ static char *work_tree;\n>  >\n>  >  static const char *git_dir;\n>  >  static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;\n>  > +int git_dir_discovered;\n>\n>\n> Should this be 'int git_dir_discovered = 0;' ?\n\nIt is initialized by default IIRC.\n\n>  > Bandage patch:\n>  >\n>  > ---<---\n>  > diff --git a/builtin-archive.c b/builtin-archive.c\n>  > index 432ce2a..5ea0a12 100644\n>  > --- a/builtin-archive.c\n>  > +++ b/builtin-archive.c\n>  > @@ -110,7 +110,9 @@ static const char *extract_remote_arg(int *ac,\n>  > const char **av)\n>  >  int cmd_archive(int argc, const char **argv, const char *prefix)\n>  >  {\n>  >       const char *remote = NULL;\n>  > +     int nongit;\n>  >\n>  > +     prefix = setup_git_directory_gently(&nongit);\n>\n>\n> Here and elsewhere, the 'nongit' variable isn't used.\n>  setup_git_directory_gently can be passed a NULL pointer, why not do that?\n\nPassing NULL to setup_git_directory_gently() tells it to die() if no\ngit repo can be found. If you pass a variable to it, it will set the\nvariable to 1 if no repo is found, 0 otherwise.\n\n>  >       git_config(git_default_config, NULL);\n>  >       while (1 < argc) {\n>  >               if (!no_more_options && argv[1][0] == '-') {\n>  > diff --git a/hash-object.c b/hash-object.c\n>  > index 20937ff..a52b6be 100644\n>  > --- a/hash-object.c\n>  > +++ b/hash-object.c\n>  > @@ -78,19 +78,20 @@ int main(int argc, const char **argv)\n>  >       const char *prefix = NULL;\n>  >       int prefix_length = -1;\n>  >       const char *errstr = NULL;\n>  > +     int nongit;\n>  >\n>  >       type = blob_type;\n>  >\n>  > -     git_config(git_default_config, NULL);\n>  > -\n>  >       argc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);\n>  >\n>  > -     if (write_object) {\n>  > -             prefix = setup_git_directory();\n>  > -             prefix_length = prefix ? strlen(prefix) : 0;\n>  > -             if (vpath && prefix)\n>  > -                     vpath = prefix_filename(prefix, prefix_length, vpath);\n>  > -     }\n>  > +     prefix = setup_git_directory_gently(&nongit);\n>  > +     git_config(git_default_config, NULL);\n>  > +     prefix_length = prefix ? strlen(prefix) : 0;\n>  > +     if (vpath && prefix)\n>  > +             vpath = prefix_filename(prefix, prefix_length, vpath);\n>  > +\n>  > +     if (write_object && nongit)\n>  > +             die(\"Git repository required\");\n>\n>\n> I'd move this check up to just after setup_git_directory_gently.\n\nYeah, sounds reasonable.\n\n-- \nDuy\n"},{"id":"93891","messageId":"49024A05.3090100@lsrfire.ath.cx","threadId":"16008","inReplyTo":"1224712023-5280-1-git-send-email-charles@hashpling.org","subject":"Re: [PATCH] Fixed git archive for bare repos","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-10-24T22:19:49Z","receivedAt":"2008-10-24T22:19:49Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Charles Bailey schrieb:\n> This moves the call to git config to a place where it doesn't break\n> the logic for using git archive in a bare repository but retains the\n> fix to make git archive respect core.autocrlf.\n\nIf one combines your patch, Deskin's commit message and test and extends\non the latter a bit then I think we have a winner. :)\n\nHere are a few more tests which create a ZIP file in addition to a tar\narchive and compare them to their non-bare counterparts.\n\nCare to resend?\n\nThanks,\nRené\n\n\n t/t5000-tar-tree.sh |   21 +++++++++++++++++++++\n 1 files changed, 21 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex e395ff4..bf5fa25 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -58,6 +58,11 @@ test_expect_success \\\n      git commit-tree $treeid </dev/null)'\n \n test_expect_success \\\n+    'create bare clone' \\\n+    'git clone --bare . bare.git &&\n+     cp .gitattributes bare.git/info/attributes'\n+\n+test_expect_success \\\n     'remove ignored file' \\\n     'rm a/ignored'\n \n@@ -74,6 +79,14 @@ test_expect_success \\\n     'diff b.tar b2.tar'\n \n test_expect_success \\\n+    'git archive in a bare repo' \\\n+    '(cd bare.git && git archive HEAD) >b3.tar'\n+\n+test_expect_success \\\n+    'git archive vs. the same in a bare repo' \\\n+    'test_cmp b.tar b3.tar'\n+\n+test_expect_success \\\n     'validate file modification time' \\\n     'mkdir extract &&\n      \"$TAR\" xf b.tar -C extract a/a &&\n@@ -151,6 +164,14 @@ test_expect_success \\\n     'git archive --format=zip' \\\n     'git archive --format=zip HEAD >d.zip'\n \n+test_expect_success \\\n+    'git archive --format=zip in a bare repo' \\\n+    '(cd bare.git && git archive --format=zip HEAD) >d1.zip'\n+\n+test_expect_success \\\n+    'git archive --format=zip vs. the same in a bare repo' \\\n+    'test_cmp d.zip d1.zip'\n+\n $UNZIP -v >/dev/null 2>&1\n if [ $? -eq 127 ]; then\n \techo \"Skipping ZIP tests, because unzip was not found\"\n"},{"id":"93930","messageId":"20081025153814.GA26752@euler","threadId":"16008","inReplyTo":"49024A05.3090100@lsrfire.ath.cx","subject":"[PATCH v2] Fixed git archive for bare repos","fromName":"Deskin Miller","fromEmail":"deskinm@umich.edu","sentAt":"2008-10-25T15:38:14Z","receivedAt":"2008-10-25T15:38:14Z","isPatch":true,"sender":{"key":"deskinm@umich.edu","avatar":"https://gravatar.com/avatar/d340a0e612cdf0a79535c71863c0b4c535e9aba63b42032226ae903e638b64f9?d=mp&s=160"},"body":"From 8f0dce75427283e0333cce1f1e66f4eac9978ad4 Mon Sep 17 00:00:00 2001\nFrom: Charles Bailey <charles@hashpling.org>\n\nThis moves the call to git_config to a place where it doesn't break the\nlogic for using git archive in a bare repository but retains the fix to\nmake git archive respect core.autocrlf.\n\nSigned-off-by: Charles Bailey <charles@hashpling.org>\nTested-by: Deskin Miller <deskinm@umich.edu>\n---\nOn Sat, Oct 25, 2008 at 12:19:49AM +0200, René Scharfe wrote:\n> Charles Bailey schrieb:\n> > This moves the call to git config to a place where it doesn't break\n> > the logic for using git archive in a bare repository but retains the\n> > fix to make git archive respect core.autocrlf.\n> \n> If one combines your patch, Deskin's commit message and test and extends\n> on the latter a bit then I think we have a winner. :)\n> \n> Here are a few more tests which create a ZIP file in addition to a tar\n> archive and compare them to their non-bare counterparts.\n> \n> Care to resend?\n> \n> Thanks,\n> René\n\nHere's a resend.  I've kept Charles's change and commit message, but added\nRené's tests and removed my test, since it was presupposed by the new tests.\n\nStill needs a signoff from René.\n\n archive.c           |    2 ++\n builtin-archive.c   |    2 --\n t/t5000-tar-tree.sh |   21 +++++++++++++++++++++\n 3 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex e2280df..45d242b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -338,5 +338,7 @@ int write_archive(int argc, const char **argv, const char *prefix,\n \tparse_treeish_arg(argv, &args, prefix);\n \tparse_pathspec_arg(argv + 1, &args);\n \n+\tgit_config(git_default_config, NULL);\n+\n \treturn ar->write_archive(&args);\n }\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 432ce2a..5ceec43 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -111,8 +111,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n {\n \tconst char *remote = NULL;\n \n-\tgit_config(git_default_config, NULL);\n-\n \tremote = extract_remote_arg(&argc, argv);\n \tif (remote)\n \t\treturn run_remote_archiver(remote, argc, argv);\ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex e395ff4..0f27d73 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -58,6 +58,11 @@ test_expect_success \\\n      git commit-tree $treeid </dev/null)'\n \n test_expect_success \\\n+    'create bare clone' \\\n+    'git clone --bare . bare.git &&\n+     cp .gitattributes bare.git/info/attributes'\n+\n+test_expect_success \\\n     'remove ignored file' \\\n     'rm a/ignored'\n \n@@ -74,6 +79,14 @@ test_expect_success \\\n     'diff b.tar b2.tar'\n \n test_expect_success \\\n+    'git archive in a bare repo' \\\n+    '(cd bare.git && git archive HEAD) >b3.tar'\n+\n+test_expect_success \\\n+    'git archive vs. the same in a bare repo' \\\n+    'test_cmp b.tar b3.tar'\n+\n+test_expect_success \\\n     'validate file modification time' \\\n     'mkdir extract &&\n      \"$TAR\" xf b.tar -C extract a/a &&\n@@ -151,6 +164,14 @@ test_expect_success \\\n     'git archive --format=zip' \\\n     'git archive --format=zip HEAD >d.zip'\n \n+test_expect_success \\\n+    'git archive --format=zip in a bare repo' \\\n+    '(cd bare.git && git archive --format=zip HEAD) >d1.zip'\n+\n+test_expect_success \\\n+    'git archive --format=zip vs. the same in a bare repo' \\\n+    'test_cmp d.zip d1.zip'\n+\n $UNZIP -v >/dev/null 2>&1\n if [ $? -eq 127 ]; then\n \techo \"Skipping ZIP tests, because unzip was not found\"\n-- \n1.6.0.3.515.g304f\n"},{"id":"93936","messageId":"7vod188p1f.fsf@gitster.siamese.dyndns.org","threadId":"16008","inReplyTo":"20081025153814.GA26752@euler","subject":"Re: [PATCH v2] Fixed git archive for bare repos","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-25T19:15:08Z","receivedAt":"2008-10-25T19:15:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks all.  Will apply to 'maint' for 1.6.0.4.\n"}]}