{"thread":{"id":"9907","subject":"[PATCH 1/2] contrib/fast-import: add simple shell example","startedAt":"2007-09-18T07:26:01Z","lastAt":"2007-09-18T07:26:01Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"53403","messageId":"20070918072601.GA3506@coredump.intra.peff.net","threadId":"9907","inReplyTo":null,"subject":"[PATCH 1/2] contrib/fast-import: add simple shell example","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-09-18T07:26:01Z","receivedAt":"2007-09-18T07:26:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>\n\nThis example just puts a directory under git control. It is\nsignificantly slower than using the git tools directly, but\nhopefully shows a bit how fast-import works.\n\n  [jk: added header comments]\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jeff King <peff@peff.net>\n---\n contrib/fast-import/git-import.sh |   38 +++++++++++++++++++++++++++++++++++++\n 1 files changed, 38 insertions(+), 0 deletions(-)\n create mode 100755 contrib/fast-import/git-import.sh\n\ndiff --git a/contrib/fast-import/git-import.sh b/contrib/fast-import/git-import.sh\nnew file mode 100755\nindex 0000000..0ca7718\n--- /dev/null\n+++ b/contrib/fast-import/git-import.sh\n@@ -0,0 +1,38 @@\n+#!/bin/sh\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 lot slower,\n+# but is meant to be a simple fast-import example.\n+\n+if [ -z \"$1\" -o -z \"$2\" ]; then\n+\techo \"Usage: git-import branch import-message\"\n+\texit 1\n+fi\n+\n+USERNAME=\"$(git config user.name)\"\n+EMAIL=\"$(git config user.email)\"\n+\n+if [ -z \"$USERNAME\" -o -z \"$EMAIL\" ]; then\n+\techo \"You need to set user name and email\"\n+\texit 1\n+fi\n+\n+git init\n+\n+(\n+\tcat <<EOF\n+commit refs/heads/$1\n+committer $USERNAME <$EMAIL> now\n+data <<MSGEOF\n+$2\n+MSGEOF\n+\n+EOF\n+\tfind * -type f|while read i;do\n+\t\techo \"M 100644 inline $i\"\n+\t\techo data $(stat -c '%s' \"$i\")\n+\t\tcat \"$i\"\n+\t\techo\n+\tdone\n+\techo\n+) | git fast-import --date-format=now\n-- \n1.5.3.1.967.g6bb01\n"}]}