{"thread":{"id":"3176","subject":"git commit error on initial (the very first) commit","startedAt":"2006-01-29T17:26:54Z","lastAt":"2006-01-29T21:51:57Z","messageCount":5,"participants":["Andrey Borzenkov","J. Bruce Fields","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15204","messageId":"200601292026.54893.arvidjaar@mail.ru","threadId":"3176","inReplyTo":null,"subject":"git commit error on initial (the very first) commit","fromName":"Andrey Borzenkov","fromEmail":"arvidjaar@mail.ru","sentAt":"2006-01-29T17:26:54Z","receivedAt":"2006-01-29T17:26:54Z","isPatch":false,"sender":{"key":"arvidjaar@mail.ru","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nMay be I do something wrong? What is correct procedure to initially import \ntree? git 1.1.4\n\n{pts/0}% git init-db\ndefaulting to local storage area\n{pts/0}% git add .\n{pts/0}% git commit -m 'initial import'\nusage: git-diff-index [-m] [--cached] [<common diff options>] <tree-ish> \n[<path>...]\ncommon diff options:\n... etc\n\nCommitting initial tree 4c9bc57b6911db86c7ab482cca33948a9ba20ef0\n\n- -andrey\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (GNU/Linux)\n\niD8DBQFD3PreR6LMutpd94wRAiP1AJwI93tNjyQ3PYjuwh/EP/GQJHhjKQCeNsuq\n6oWKT+2XHaU3Qe50hkmkQ+g=\n=493D\n-----END PGP SIGNATURE-----\n"},{"id":"15210","messageId":"20060129181625.GA5540@fieldses.org","threadId":"3176","inReplyTo":"200601292026.54893.arvidjaar@mail.ru","subject":"Re: git commit error on initial (the very first) commit","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2006-01-29T18:16:25Z","receivedAt":"2006-01-29T18:16:25Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Sun, Jan 29, 2006 at 08:26:54PM +0300, Andrey Borzenkov wrote:\n> May be I do something wrong? What is correct procedure to initially import \n> tree? git 1.1.4\n> \n> {pts/0}% git init-db\n> defaulting to local storage area\n> {pts/0}% git add .\n> {pts/0}% git commit -m 'initial import'\n\nIt needs to know which paths to update.  Probably you want to include\nall the files you added with the \"git add\", and you can do that just\nwith -a:\n\n\tgit commit -a -m \"initial import\"\n\nshould do the job.  The default commit command for me is usually just\ngit commit -a.\n\n--b.\n"},{"id":"15226","messageId":"7v8xsyiw2v.fsf@assigned-by-dhcp.cox.net","threadId":"3176","inReplyTo":"200601292026.54893.arvidjaar@mail.ru","subject":"Re: git commit error on initial (the very first) commit","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-29T21:05:28Z","receivedAt":"2006-01-29T21:05:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrey Borzenkov <arvidjaar@mail.ru> writes:\n\n> May be I do something wrong? What is correct procedure to initially import \n> tree? git 1.1.4\n>\n> {pts/0}% git init-db\n> defaulting to local storage area\n> {pts/0}% git add .\n> {pts/0}% git commit -m 'initial import'\n> usage: git-diff-index [-m] [--cached] [<common diff options>] <tree-ish> \n> [<path>...]\n> common diff options:\n> ... etc\n\nI suspect you have $(template_dir)/hooks/pre-commit enabled.\n\n-- >8 --\n[PATCH] pre-commit sample hook: do not barf on the initial import\n\nThe example hook barfs on the initial import.  Ideally it should\nproduce a diff from an empty tree, but for now let's stop at\nsquelching the bogus error message.  Often an initial import\ninvolves tons of badly formatted files from foreign SCM, so not\ncomplaining about them like this patch does might actually be a\nbetter idea than enforcing the \"Perfect Patch\" format on them.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit\nindex 4bb6803..6b3a21b 100644\n--- a/templates/hooks--pre-commit\n+++ b/templates/hooks--pre-commit\n@@ -10,8 +10,16 @@\n # This is slightly modified from Andrew Morton's Perfect Patch.\n # Lines you introduce should not have trailing whitespace.\n # Also check for an indentation that has SP before a TAB.\n+\n+if git-rev-parse --verify HEAD 2>/dev/null\n+then\n+\tgit-diff-index -p -M --cached HEAD\n+else\n+\t# NEEDSWORK: we should produce a diff with an empty tree here\n+\t# if we want to do the same verification for the initial import.\n+\t:\n+fi |\t\t\n perl -e '\n-    my $fh;\n     my $found_bad = 0;\n     my $filename;\n     my $reported_filename = \"\";\n@@ -31,8 +39,7 @@ perl -e '\n \tprint STDERR \"* $why (line $lineno)\\n\";\n \tprint STDERR \"$filename:$lineno:$line\\n\";\n     }\n-    open $fh, \"-|\", qw(git-diff-index -p -M --cached HEAD);\n-    while (<$fh>) {\n+    while (<>) {\n \tif (m|^diff --git a/(.*) b/\\1$|) {\n \t    $filename = $1;\n \t    next;\n"},{"id":"15227","messageId":"7v1wyqivx1.fsf@assigned-by-dhcp.cox.net","threadId":"3176","inReplyTo":"20060129181625.GA5540@fieldses.org","subject":"Re: git commit error on initial (the very first) commit","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-29T21:08:58Z","receivedAt":"2006-01-29T21:08:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"J. Bruce Fields\" <bfields@fieldses.org> writes:\n\n> On Sun, Jan 29, 2006 at 08:26:54PM +0300, Andrey Borzenkov wrote:\n>> May be I do something wrong? What is correct procedure to initially import \n>> tree? git 1.1.4\n>> \n>> {pts/0}% git init-db\n>> defaulting to local storage area\n>> {pts/0}% git add .\n>> {pts/0}% git commit -m 'initial import'\n>\n> It needs to know which paths to update.\n\nWhile I agree with you that individual developers should always\nsay \"commit -a\" after testing their changes, I do not think that\nhas much to do with Andrey's problem.\n\nIn a freshly created repository, \"git add .\" would register\neverything to the index file, and a \"git commit\" with or without\n\"-a\" that immediately follows \"git add .\" would commit what is\nin the index.  Use of \"-a\" would not make a difference here.\n"},{"id":"15228","messageId":"20060129215157.GB12394@fieldses.org","threadId":"3176","inReplyTo":"7v1wyqivx1.fsf@assigned-by-dhcp.cox.net","subject":"Re: git commit error on initial (the very first) commit","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2006-01-29T21:51:57Z","receivedAt":"2006-01-29T21:51:57Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Sun, Jan 29, 2006 at 01:08:58PM -0800, Junio C Hamano wrote:\n> In a freshly created repository, \"git add .\" would register\n> everything to the index file, and a \"git commit\" with or without\n> \"-a\" that immediately follows \"git add .\" would commit what is\n> in the index.  Use of \"-a\" would not make a difference here.\n\nAie, you're right of course, thanks.--b.\n"}]}