{"thread":{"id":"29898","subject":"Passing commit IDs to git-archive","startedAt":"2012-03-09T22:14:05Z","lastAt":"2012-03-12T13:24:40Z","messageCount":5,"participants":["Stephen Bash","Junio C Hamano","René Scharfe","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"186588","messageId":"8fb14091-99dc-4383-9cab-5bf508e0a554@mail","threadId":"29898","inReplyTo":"8c6d921d-9e8e-4caf-bc04-b1d2cfdd294f@mail","subject":"Passing commit IDs to git-archive","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2012-03-09T22:14:05Z","receivedAt":"2012-03-09T22:14:05Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"Hi all-\n\nFor an upcoming release, I'm attempting to update our build scripts to suck down some content from a remote Git repository and include it en masse in our installer.  My first inclination was to use submodules, but similar to this question on Stack Overflow\n\n  http://stackoverflow.com/questions/6553743/\n\nthe content used to be in our development repository and has recently been migrated out, so jumping between branches/back and forth in history is causing problems (unlike the question, I'm not willing to rewrite history to make the submodule approach work).  So after googling around I came to git-archive using the --remote argument, which actually seems nice for my situation because the content is basically support material for the end user that the devs don't manage/edit.\n\nUnfortunately I just attempted\n\n  warp:bar bash$ git archive --remote=file:///Users/bash/Development/foo \\\n                             --output=test.tgz 3b9e49b \\\n                             path/to/subdir\n  remote: fatal: no such ref: 3b9e49b\n  remote: git upload-archive: archiver died with error\n  fatal: sent error to the client: git upload-archive: archiver died with error\n\n  warp:bar bash$ git archive --remote=file:///Users/bash/Development/foo \\\n                             --output=test.tgz 3b9e49b:path/to/subdir\n  remote: fatal: no such ref: 3b9e49b\n  remote: git upload-archive: archiver died with error\n  fatal: sent error to the client: git upload-archive: archiver died with error\n\n  warp:bar bash$ cd /Users/bash/Development/foo\n  warp:foo bash$ git rev-parse --short master\n  3b9e49b\n  warp:foo bash$ \n  warp:foo bash$ git --version\n  git version 1.7.9.2\n  warp:foo bash$ \n\non Mac OS 10.6.8 (obviously this is local testing, the goal is to use ssh remotely).  After parsing the error \"no such ref\" I attempted the same operation using master as the tree-ish and archive worked as expected (either specifying the path separately or using the colon syntax to reference the tree directly).  Is there a reason git-archive requires a named ref rather than just a commit (or tree) ID?  If not, would it be difficult to patch git-upload-archive to use the IDs?  I could use tags for the ref, but in my case would result in almost every commit being a tag which seems wasteful.\n\nThoughts?  Thanks in advance!\n\nStephen\n"},{"id":"186592","messageId":"7vhaxx4d5s.fsf@alter.siamese.dyndns.org","threadId":"29898","inReplyTo":"8fb14091-99dc-4383-9cab-5bf508e0a554@mail","subject":"Re: Passing commit IDs to git-archive","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-09T22:34:07Z","receivedAt":"2012-03-09T22:34:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Bash <bash@genarts.com> writes:\n\n> Unfortunately I just attempted\n>\n>   warp:bar bash$ git archive --remote=file:///Users/bash/Development/foo \\\n>                              --output=test.tgz 3b9e49b \\\n>                              path/to/subdir\n>\n> Thoughts?  Thanks in advance!\n\nIf you are always fetching from that same location, perhaps doing\nthis only once\n\n\tgit clone file:///...\n\nand then every time you want to use the test.tgz, do something like\n\n\tgit fetch\n        git archive --output=test.tgz 3b9e49b path/to/subdir\n\nor something like that?\n"},{"id":"186613","messageId":"4F5AF757.2040000@lsrfire.ath.cx","threadId":"29898","inReplyTo":"8fb14091-99dc-4383-9cab-5bf508e0a554@mail","subject":"Re: Passing commit IDs to git-archive","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2012-03-10T06:40:23Z","receivedAt":"2012-03-10T06:40:23Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 09.03.2012 23:14, schrieb Stephen Bash:\n> Unfortunately I just attempted\n>\n>    warp:bar bash$ git archive --remote=file:///Users/bash/Development/foo \\\n>                               --output=test.tgz 3b9e49b \\\n>                               path/to/subdir\n>    remote: fatal: no such ref: 3b9e49b\n>    remote: git upload-archive: archiver died with error\n>    fatal: sent error to the client: git upload-archive: archiver died with error\n\nHow about something like this instead?\n\n\t$ (\n\t\tcd /Users/bash/Development/foo &&\n\t\tgit archive --format=tgz 3b9e49b path/to/subdir\n\t) >test.tgz\n\nI.e. instead of using the --remote option, going to the target and \ncreating the archive locally.  You could also keep using the --output \nparameter if you specify the target file using an absolute path, of course.\n\nRené\n"},{"id":"186695","messageId":"20120312114742.GC12921@sigill.intra.peff.net","threadId":"29898","inReplyTo":"8fb14091-99dc-4383-9cab-5bf508e0a554@mail","subject":"Re: Passing commit IDs to git-archive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-12T11:47:42Z","receivedAt":"2012-03-12T11:47:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 09, 2012 at 05:14:05PM -0500, Stephen Bash wrote:\n\n> on Mac OS 10.6.8 (obviously this is local testing, the goal is to use\n> ssh remotely).  After parsing the error \"no such ref\" I attempted the\n> same operation using master as the tree-ish and archive worked as\n> expected (either specifying the path separately or using the colon\n> syntax to reference the tree directly).  Is there a reason git-archive\n> requires a named ref rather than just a commit (or tree) ID?\n\nYes; generally git repositories do not allow clients to access arbitrary\nsha1s. Instead, they require that the requested objects be accessible by\na ref.\n\ngit-archive was not properly enforcing this, and was changed recently to\nallow only refs by name, as well as sub-trees of refs (e.g.,\nHEAD:subdir/). That means we do disallow an arbitrary commit or tree\nsha1, even if it is reachable from the advertised refs.\n\n> would it be difficult to patch git-upload-archive to use the IDs?  I\n> could use tags for the ref, but in my case would result in almost\n> every commit being a tag which seems wasteful.\n\nDoing it right is a bit expensive, because in the general case (somebody\nrequested a tree sha1), we would need to traverse every tree of every\ncommit to see if it is reachable.\n\nWe could potentially implement a more restricted set of rules, allowing\n\"<commit>:<subdir>\" and checking that <commit> is reachable.  That would\ndisallow an arbitrary tree sha1, but I suspect it would cover the common\nuse case (i.e., you want to get the tree, or even a subtree, of a\nparticular revision).\n\n-Peff\n"},{"id":"186705","messageId":"57b23100-a04d-4eca-bb0e-35455464ec5c@mail","threadId":"29898","inReplyTo":"20120312114742.GC12921@sigill.intra.peff.net","subject":"Re: Passing commit IDs to git-archive","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2012-03-12T13:24:40Z","receivedAt":"2012-03-12T13:24:40Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"----- Original Message -----\n> From: \"Jeff King\" <peff@peff.net>\n> Sent: Monday, March 12, 2012 7:47:42 AM\n> Subject: Re: Passing commit IDs to git-archive\n> \n> On Fri, Mar 09, 2012 at 05:14:05PM -0500, Stephen Bash wrote:\n> \n> > on Mac OS 10.6.8 (obviously this is local testing, the goal is to\n> > use ssh remotely).  After parsing the error \"no such ref\" I\n> > attempted the same operation using master as the tree-ish and\n> > archive worked as expected (either specifying the path separately or\n> > using the colon syntax to reference the tree directly).  Is there a\n> > reason git-archive requires a named ref rather than just a commit\n> > (or tree) ID?\n> \n> Yes; generally git repositories do not allow clients to access\n> arbitrary sha1s. Instead, they require that the requested objects be\n> accessible by a ref.\n\nJeff: thanks for the concise summary.  I thought that might be the case, but wanted to confirm.\n\nJunio and René: thanks for the input and ideas. Seems I'll be investigating my options today.\n\nThanks,\nStephen\n"}]}