{"thread":{"id":"9908","subject":"[PATCH] contrib/fast-import: add perl version of simple example","startedAt":"2007-09-18T07:26:27Z","lastAt":"2007-09-18T13:25:23Z","messageCount":11,"participants":["Jeff King","Johannes Schindelin","Andreas Ericsson","Sam Vilain"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53404","messageId":"20070918072627.GB3506@coredump.intra.peff.net","threadId":"9908","inReplyTo":null,"subject":"[PATCH] contrib/fast-import: add perl version of simple example","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-09-18T07:26:27Z","receivedAt":"2007-09-18T07:26:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is based on the git-import.sh script, but is a little\nmore robust and efficient. More importantly, it should\nserve as a quick template for interfacing fast-import with\nperl scripts.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n contrib/fast-import/git-import.perl |   64 +++++++++++++++++++++++++++++++++++\n 1 files changed, 64 insertions(+), 0 deletions(-)\n create mode 100755 contrib/fast-import/git-import.perl\n\ndiff --git a/contrib/fast-import/git-import.perl b/contrib/fast-import/git-import.perl\nnew file mode 100755\nindex 0000000..f9fef6d\n--- /dev/null\n+++ b/contrib/fast-import/git-import.perl\n@@ -0,0 +1,64 @@\n+#!/usr/bin/perl\n+#\n+# Performs an initial import of a directory. This is the equivalent\n+# of doing 'git init; git add .; git commit'. It's a little slower,\n+# but is meant to be a simple fast-import example.\n+\n+use strict;\n+use File::Find;\n+\n+my $USAGE = 'Usage: git-import branch import-message';\n+my $branch = shift or die \"$USAGE\\n\";\n+my $message = shift or die \"$USAGE\\n\";\n+\n+chomp(my $username = `git config user.name`);\n+chomp(my $email = `git config user.email`);\n+die 'You need to set user name and email'\n+  unless $username && $email;\n+\n+system('git init');\n+open(my $fi, '|-', qw(git fast-import --date-format=now))\n+  or die \"unable to spawn fast-import: $!\";\n+\n+print $fi <<EOF;\n+commit refs/heads/$branch\n+committer $username <$email> now\n+data <<MSGEOF\n+$message\n+MSGEOF\n+\n+EOF\n+\n+find(\n+  sub {\n+    if($File::Find::name eq './.git') {\n+      $File::Find::prune = 1;\n+      return;\n+    }\n+    return unless -f $_;\n+\n+    my $fn = $File::Find::name;\n+    $fn =~ s#^.\\/##;\n+\n+    open(my $in, '<', $_)\n+      or die \"unable to open $fn: $!\";\n+    my @st = stat($in)\n+      or die \"unable to stat $fn: $!\";\n+    my $len = $st[7];\n+\n+    print $fi \"M 644 inline $fn\\n\";\n+    print $fi \"data $len\\n\";\n+    while($len > 0) {\n+      my $r = read($in, my $buf, $len < 4096 ? $len : 4096);\n+      defined($r) or die \"read error from $fn: $!\";\n+      $r > 0 or die \"premature EOF from $fn: $!\";\n+      print $fi $buf;\n+      $len -= $r;\n+    }\n+    print $fi \"\\n\";\n+\n+  }, '.'\n+);\n+\n+close($fi);\n+exit $?;\n-- \n1.5.3.1.967.g6bb01\n"},{"id":"53405","messageId":"20070918072711.GA3590@coredump.intra.peff.net","threadId":"9908","inReplyTo":"20070918072627.GB3506@coredump.intra.peff.net","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-09-18T07:27:11Z","receivedAt":"2007-09-18T07:27:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 18, 2007 at 03:26:27AM -0400, Jeff King wrote:\n\n> This is based on the git-import.sh script, but is a little\n\nSorry, this was meant to be 2/2 (in case you were breathless in\nanticipation for the second part of the series).\n\n-Peff\n"},{"id":"53440","messageId":"Pine.LNX.4.64.0709181115250.28586@racer.site","threadId":"9908","inReplyTo":"20070918072627.GB3506@coredump.intra.peff.net","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-18T10:16:33Z","receivedAt":"2007-09-18T10:16:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Sep 2007, Jeff King wrote:\n\n> This is based on the git-import.sh script, but is a little\n> more robust and efficient. More importantly, it should\n> serve as a quick template for interfacing fast-import with\n> perl scripts.\n\nYes, please!  Maybe somebody will then grab the low-hanging fruit of \nwriting a \"git-fast-export\", which can be used to dump a complete \nrepository in text format?\n\nCiao,\nDscho\n"},{"id":"53443","messageId":"46EFA84C.3080906@op5.se","threadId":"9908","inReplyTo":"Pine.LNX.4.64.0709181115250.28586@racer.site","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-09-18T10:28:28Z","receivedAt":"2007-09-18T10:28:28Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 18 Sep 2007, Jeff King wrote:\n> \n>> This is based on the git-import.sh script, but is a little\n>> more robust and efficient. More importantly, it should\n>> serve as a quick template for interfacing fast-import with\n>> perl scripts.\n> \n> Yes, please!  Maybe somebody will then grab the low-hanging fruit of \n> writing a \"git-fast-export\", which can be used to dump a complete \n> repository in text format?\n> \n\nI thought that was already taken care of since format-patch handles\n--root flag properly?\n\nOtherwise, \"git repack -a --window=0 --depth=0\" should provide an\neasily parseable dump of an entire repo.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"53444","messageId":"20070918103051.GA22239@coredump.intra.peff.net","threadId":"9908","inReplyTo":"46EFA84C.3080906@op5.se","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-09-18T10:30:51Z","receivedAt":"2007-09-18T10:30:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 18, 2007 at 12:28:28PM +0200, Andreas Ericsson wrote:\n\n>> Yes, please!  Maybe somebody will then grab the low-hanging fruit of \n>> writing a \"git-fast-export\", which can be used to dump a complete \n>> repository in text format?\n>\n> I thought that was already taken care of since format-patch handles\n> --root flag properly?\n>\n> Otherwise, \"git repack -a --window=0 --depth=0\" should provide an\n> easily parseable dump of an entire repo.\n\nI think he means a dump that you can meaningfully edit with sed or a\ntext editor. And even nicer, one that could be fed back into\ngit-fast-import. So you could do something like:\n\ngit-fast-export A..B >dump\nvi dump\ngit-fast-import <dump\n\nto rewrite history in a very flexible way.\n\n-Peff\n"},{"id":"53448","messageId":"Pine.LNX.4.64.0709181216040.28586@racer.site","threadId":"9908","inReplyTo":"46EFA84C.3080906@op5.se","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-18T11:17:15Z","receivedAt":"2007-09-18T11:17:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Sep 2007, Andreas Ericsson wrote:\n\n> Johannes Schindelin wrote:\n>\n> > Maybe somebody will then grab the low-hanging fruit of writing a \n> > \"git-fast-export\", which can be used to dump a complete repository in \n> > text format?\n> \n> I thought that was already taken care of since format-patch handles\n> --root flag properly?\n\nUmm.  Probably you forgot about merge commits, right?  And about more than \none branch?\n\n> Otherwise, \"git repack -a --window=0 --depth=0\" should provide an easily \n> parseable dump of an entire repo.\n\nThis is not a dump.  It is a log.\n\nCiao,\nDscho\n"},{"id":"53450","messageId":"Pine.LNX.4.64.0709181217200.28586@racer.site","threadId":"9908","inReplyTo":"20070918103051.GA22239@coredump.intra.peff.net","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-18T11:18:24Z","receivedAt":"2007-09-18T11:18:24Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Sep 2007, Jeff King wrote:\n\n> I think he means a dump that you can meaningfully edit with sed or a \n> text editor. And even nicer, one that could be fed back into \n> git-fast-import. So you could do something like:\n> \n> git-fast-export A..B >dump\n> vi dump\n> git-fast-import <dump\n> \n> to rewrite history in a very flexible way.\n\nExactly what I meant.  Some people seem to have problems with \nfilter-branch, but somehow no proper bug report, let alone fix, evolved \nfrom that.\n\nI guess these people are more comfortable with what you just described.\n\nCiao,\nDscho\n"},{"id":"53452","messageId":"46EFB65B.6030202@op5.se","threadId":"9908","inReplyTo":"Pine.LNX.4.64.0709181217200.28586@racer.site","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-09-18T11:28:27Z","receivedAt":"2007-09-18T11:28:27Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 18 Sep 2007, Jeff King wrote:\n> \n>> I think he means a dump that you can meaningfully edit with sed or a \n>> text editor. And even nicer, one that could be fed back into \n>> git-fast-import. So you could do something like:\n>>\n>> git-fast-export A..B >dump\n>> vi dump\n>> git-fast-import <dump\n>>\n>> to rewrite history in a very flexible way.\n> \n> Exactly what I meant.  Some people seem to have problems with \n> filter-branch, but somehow no proper bug report, let alone fix, evolved \n> from that.\n> \n\nThe main problem is that it in my use-cases fixes a nuisance, but not a\nreal problem, while the man-page SYNOPSIS consists of a full 5 lines, most\nof which are far from obvious at a first glance. The seeming effort involved\njust doesn't seem worth bothering with.\n\n> I guess these people are more comfortable with what you just described.\n> \n\nI know I would be, especially since all changes would show up in an entirely\ndifferent repo. I know filter-branch is probably completely safe, but even a\n0.1% risk of losing *anything* isn't worth taking to fix a small nuisance.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"53457","messageId":"46EFBD40.1070102@vilain.net","threadId":"9908","inReplyTo":"Pine.LNX.4.64.0709181217200.28586@racer.site","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-09-18T11:57:52Z","receivedAt":"2007-09-18T11:57:52Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>> I think he means a dump that you can meaningfully edit with sed or a \n>> text editor. And even nicer, one that could be fed back into \n>> git-fast-import. So you could do something like:\n>>\n>> git-fast-export A..B >dump\n>> vi dump\n>> git-fast-import <dump\n>>\n>> to rewrite history in a very flexible way.\n>>     \n>\n> Exactly what I meant.  Some people seem to have problems with \n> filter-branch, but somehow no proper bug report, let alone fix, evolved \n> from that.\n>\n> I guess these people are more comfortable with what you just described.\n>   \n\nGuilty. my own filter-branch supports things like custom re-ordering of\ncommits prior to rewriting (eg, if you need to refer to one commit to\nanother in a commit message, you better make sure it happens in the\nright order).\n\nI personally want to be able to dump patches, including merges, to\ngit-format-patch format, in such a way that all other information (eg,\ncommitter, date, etc) is preserved. And probably using something akin to\nMessage-Id: headers for a \"patch UUID\" which is what you need when\nyou're working with piles of patches like that.\n\nSam.\n"},{"id":"53466","messageId":"Pine.LNX.4.64.0709181334210.28586@racer.site","threadId":"9908","inReplyTo":"46EFBD40.1070102@vilain.net","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-18T12:36:12Z","receivedAt":"2007-09-18T12:36:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Sep 2007, Sam Vilain wrote:\n\n> I personally want to be able to dump patches, including merges, to\n> git-format-patch format, in such a way that all other information (eg,\n> committer, date, etc) is preserved.\n\nWe already talked about that on IRC, and you have not even _begun_ to \nthink about the fundamental issues with merges-in-a-patch.  I mentioned a \nfew on IRC, and am still awaiting your reply.\n\nUnless you tackle those fundamental issues, I am afraid it is not worth \nbothering to discuss this subject any more.\n\nCiao,\nDscho\n"},{"id":"53476","messageId":"46EFD1C3.4080008@vilain.net","threadId":"9908","inReplyTo":"Pine.LNX.4.64.0709181334210.28586@racer.site","subject":"Re: [PATCH] contrib/fast-import: add perl version of simple example","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-09-18T13:25:23Z","receivedAt":"2007-09-18T13:25:23Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>> I personally want to be able to dump patches, including merges, to\n>> git-format-patch format, in such a way that all other information (eg,\n>> committer, date, etc) is preserved.\n>>     \n>\n> We already talked about that on IRC, and you have not even _begun_ to \n> think about the fundamental issues with merges-in-a-patch.  I mentioned a \n> few on IRC, and am still awaiting your reply.\n>   \n\nWell, you could store diffs from both parents, or a custom diff format\nthat marks different ancestors, etc. Sure, they wouldn't apply with\n'patch', but that's the breaks.\n\nI don't see the encoding of the information as such a fundamental and\ninsurmountable issue. Why do you consider it so?\n\nSam.\n"}]}