{"thread":{"id":"43564","subject":"[BUG] git-cvsexportcommit doesn't handle added directories","startedAt":"2006-10-27T09:38:59Z","lastAt":"2006-10-27T09:38:59Z","messageCount":1,"participants":["Peter Baumann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"295564","messageId":"802d21790610270238l31042731t80313c8f467a1a55@mail.gmail.com","threadId":"43564","inReplyTo":null,"subject":"[BUG] git-cvsexportcommit doesn't handle added directories","fromName":"Peter Baumann","fromEmail":"peter.baumann@gmail.com","sentAt":"2006-10-27T09:38:59Z","receivedAt":"2006-10-27T09:38:59Z","isPatch":false,"sender":{"key":"peter.baumann@gmail.com","avatar":null},"body":"There is a problem in git-cvsexportcommit if I add a directory with some new\nfiles in git. It dies in safe_pipe_capture().\n\nAnalysis:\n\nforeach my $f (@afiles) {\n    # This should return only one value\n    my @status = grep(m/^File/,  safe_pipe_capture('cvs', '-q', 'status' ,$f));\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    #    OK. Here it tries to run \"cvs -q status src/newdirectory/newfile\"\n    [...]\n}\n\n[...]\n\n# An alternative to `command` that allows input to be passed as an array\n# to work around shell problems with weird characters in arguments\n# if the exec returns non-zero we die\nsub safe_pipe_capture {\n    my @output;\n    if (my $pid = open my $child, '-|') {\n        @output = (<$child>);\n        print \"before close\\n\";\n        close $child or die join(' ',@_).\": x$!x y$?y\";\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n         #   I changed it to see which error will be printed\n        print \"after close\\n\";\n    } else {\n        exec(@_) or die \"$! $?\"; # exec() can fail the executable can't be found\n    }\n    return wantarray ? @output : join('',@output);\n}\n\n\nOutput:\n[...]\nsiprbaum@faui40a.informatik.uni-erlangen.de's password:\ncvs [status aborted]: no such directory `src/newdir'\nbefore close\ncvs -q status src/newdir/newfile.java: xx y256y at\n/home/peter/src/git-cvsexportcommit.perl line 317.\n                                      ^^^^^\nDon't be confused about the wrong line number. I have some other stuff\n(formating\nthe commit message in a special way) in there but I can confirm that the script\ndies at the close of the pipe.\n\nRunning from a shell the command manually:\n\n  xp:~/project/$ cvs -q status src/newdir/newfile\n  siprbaum@faui40a.informatik.uni-erlangen.de's password:\n  cvs [status aborted]: no such directory `src/newdir'\n  xp:~/project/$ echo $?\n  1\n\n\nExcerpt from the \"perldoc -f close\"\n\n  [...]\n  If the file handle came from a piped open, \"close\" will additionally\nreturn false if\n  one of the other system calls involved fails, or if the program\nexits with non-zero\n  status.  (If the only problem was that the program exited non-zero, $! will be\n  set to 0.)  Closing a pipe also waits for the process executing on the pipe to\n  complete, in case you want to look at the output of the pipe afterwards, and\n  implicitly puts the exit status value of that command into $?.\n\n  Prematurely closing the read end of a pipe (i.e. before the process\nwriting to it\n  at the other end has closed it) will result in a SIGPIPE being\ndelivered to the\n  writer. If the other end can't handle that, be sure to read all the\ndata before\n  closing the pipe.\n\nSo according to the manpage $! should be set to 0, because\n\"cvs -q status src/newdir/newfile\" exits with errorcode 1 as shown above.\n\nCould this have something todo that I have to use ssh to connect to the repo?\n(CVSROOT=:extssh:siprbaum@faui40a.informatik.uni-erlangen.de:/path/to/repo)\n\nAny ideas?\n\nGreetings,\n"}]}