[BUG] git-cvsexportcommit doesn't handle added directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:/path/to/repo)

Any ideas?

Greetings,
 Peter Baumann
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]