git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git-cvsexportcommit doesn't handle added directories
@ 2006-10-27  9:38 Peter Baumann
  0 siblings, 0 replies; only message in thread
From: Peter Baumann @ 2006-10-27  9:38 UTC (permalink / raw)
  To: git; +Cc: Martin Langhoff, Yann Dirson

There is a problem in git-cvsexportcommit if I add a directory with some new
files in git. It dies in safe_pipe_capture().

Analysis:

foreach my $f (@afiles) {
    # This should return only one value
    my @status = grep(m/^File/,  safe_pipe_capture('cvs', '-q', 'status' ,$f));
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    #    OK. Here it tries to run "cvs -q status src/newdirectory/newfile"
    [...]
}

[...]

# An alternative to `command` that allows input to be passed as an array
# to work around shell problems with weird characters in arguments
# if the exec returns non-zero we die
sub safe_pipe_capture {
    my @output;
    if (my $pid = open my $child, '-|') {
        @output = (<$child>);
        print "before close\n";
        close $child or die join(' ',@_).": x$!x y$?y";
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         #   I changed it to see which error will be printed
        print "after close\n";
    } else {
        exec(@_) or die "$! $?"; # exec() can fail the executable can't be found
    }
    return wantarray ? @output : join('',@output);
}


Output:
[...]
siprbaum@faui40a.informatik.uni-erlangen.de's password:
cvs [status aborted]: no such directory `src/newdir'
before close
cvs -q status src/newdir/newfile.java: xx y256y at
/home/peter/src/git-cvsexportcommit.perl line 317.
                                      ^^^^^
Don't be confused about the wrong line number. I have some other stuff
(formating
the commit message in a special way) in there but I can confirm that the script
dies at the close of the pipe.

Running from a shell the command manually:

  xp:~/project/$ cvs -q status src/newdir/newfile
  siprbaum@faui40a.informatik.uni-erlangen.de's password:
  cvs [status aborted]: no such directory `src/newdir'
  xp:~/project/$ echo $?
  1


Excerpt from the "perldoc -f close"

  [...]
  If the file handle came from a piped open, "close" will additionally
return false if
  one of the other system calls involved fails, or if the program
exits with non-zero
  status.  (If the only problem was that the program exited non-zero, $! will be
  set to 0.)  Closing a pipe also waits for the process executing on the pipe to
  complete, in case you want to look at the output of the pipe afterwards, and
  implicitly puts the exit status value of that command into $?.

  Prematurely closing the read end of a pipe (i.e. before the process
writing to it
  at the other end has closed it) will result in a SIGPIPE being
delivered to the
  writer. If the other end can't handle that, be sure to read all the
data before
  closing the pipe.

So according to the manpage $! should be set to 0, because
"cvs -q status src/newdir/newfile" exits with errorcode 1 as shown above.

Could this have something todo that I have to use ssh to connect to the repo?
(CVSROOT=:extssh:siprbaum@faui40a.informatik.uni-erlangen.de:/path/to/repo)

Any ideas?

Greetings,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-10-27  9:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-27  9:38 [BUG] git-cvsexportcommit doesn't handle added directories Peter Baumann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).