I am trying to remove a small amount of lines of a diff with git patch -p foobar
.
The resulting chunk is like this (without git's comments):
@@ -142,4 +150,26 @@
{
perr( "fcntl" );
+ return stream_s();
+ }
+ return stream;
+}
+
+int pid_read( stream_s* data, unsigned char* buff, size_t max_siz, size_t *rd_size )
+{
+ assert( data );
+ ssize_t rd = read( data->fd, buff, max_siz );
+ if( rd < 0 )
+ {
+ return waitpid( data->pid, NULL, WNOHANG ) <= 0;
+ }
+ *rd_size = static_cast<size_t>( rd );
+ return 1;
+}
+
+string_list_t pkg_list( char const* script )
+{
+ stream_s stream;
+ if( ( stream = init_command( script ) ) == stream_s() )
+ {
return string_list_t();
}
The block I would like to remove is the function pid_read. So, following the quick guide, just removing those lines should be ok, but in effect, git refuses the change saying that the patch could not be applied cleanly. No more information.
I've tried to reproduce the problem on a smaller sample, but I can't... It's not the first time I have this problem, and usually I "solve" it by doing the change manually, but it's not really nice when the change is more complex.