Set permissions of each new file before "cvs add"ing it.
Otherwise, an executable script in git would end up being checked into the CVS repository without the execute bit. [jc: with an additional test script from Robin Rosenberg.] Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>maint
							parent
							
								
									278fcd7deb
								
							
						
					
					
						commit
						7c0f7028ee
					
				| 
						 | 
					@ -116,6 +116,7 @@ if ($opt_a) {
 | 
				
			||||||
close MSG;
 | 
					close MSG;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my (@afiles, @dfiles, @mfiles, @dirs);
 | 
					my (@afiles, @dfiles, @mfiles, @dirs);
 | 
				
			||||||
 | 
					my %amodes;
 | 
				
			||||||
my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
 | 
					my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
 | 
				
			||||||
#print @files;
 | 
					#print @files;
 | 
				
			||||||
$? && die "Error in git-diff-tree";
 | 
					$? && die "Error in git-diff-tree";
 | 
				
			||||||
| 
						 | 
					@ -124,6 +125,7 @@ foreach my $f (@files) {
 | 
				
			||||||
    my @fields = split(m!\s+!, $f);
 | 
					    my @fields = split(m!\s+!, $f);
 | 
				
			||||||
    if ($fields[4] eq 'A') {
 | 
					    if ($fields[4] eq 'A') {
 | 
				
			||||||
        my $path = $fields[5];
 | 
					        my $path = $fields[5];
 | 
				
			||||||
 | 
						$amodes{$path} = $fields[1];
 | 
				
			||||||
	push @afiles, $path;
 | 
						push @afiles, $path;
 | 
				
			||||||
        # add any needed parent directories
 | 
					        # add any needed parent directories
 | 
				
			||||||
	$path = dirname $path;
 | 
						$path = dirname $path;
 | 
				
			||||||
| 
						 | 
					@ -268,6 +270,7 @@ if (($? >> 8) == 2) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach my $f (@afiles) {
 | 
					foreach my $f (@afiles) {
 | 
				
			||||||
 | 
					    set_new_file_permissions($f, $amodes{$f});
 | 
				
			||||||
    if (grep { $_ eq $f } @bfiles) {
 | 
					    if (grep { $_ eq $f } @bfiles) {
 | 
				
			||||||
      system('cvs', 'add','-kb',$f);
 | 
					      system('cvs', 'add','-kb',$f);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
| 
						 | 
					@ -342,3 +345,13 @@ sub safe_pipe_capture {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return wantarray ? @output : join('',@output);
 | 
					    return wantarray ? @output : join('',@output);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# For any file we want to add to cvs, we must first set its permissions
 | 
				
			||||||
 | 
					# properly, *before* the "cvs add ..." command.  Otherwise, it is impossible
 | 
				
			||||||
 | 
					# to change the permission of the file in the CVS repository using only cvs
 | 
				
			||||||
 | 
					# commands.  This should be fixed in cvs-1.12.14.
 | 
				
			||||||
 | 
					sub set_new_file_permissions {
 | 
				
			||||||
 | 
					    my ($file, $perm) = @_;
 | 
				
			||||||
 | 
					    chmod oct($perm), $file
 | 
				
			||||||
 | 
					      or die "failed to set permissions of \"$file\": $!\n";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,4 +142,20 @@ test_expect_success \
 | 
				
			||||||
     diff F/newfile6.png ../F/newfile6.png
 | 
					     diff F/newfile6.png ../F/newfile6.png
 | 
				
			||||||
     )'
 | 
					     )'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_expect_success 'Retain execute bit' '
 | 
				
			||||||
 | 
						mkdir G &&
 | 
				
			||||||
 | 
						echo executeon >G/on &&
 | 
				
			||||||
 | 
						chmod +x G/on &&
 | 
				
			||||||
 | 
						echo executeoff >G/off &&
 | 
				
			||||||
 | 
						git add G/on &&
 | 
				
			||||||
 | 
						git add G/off &&
 | 
				
			||||||
 | 
						git commit -a -m "Execute test" &&
 | 
				
			||||||
 | 
						(
 | 
				
			||||||
 | 
							cd "$CVSWORK" &&
 | 
				
			||||||
 | 
							git-cvsexportcommit -c HEAD
 | 
				
			||||||
 | 
							test -x G/on &&
 | 
				
			||||||
 | 
							! test -x G/off
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
					'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_done
 | 
					test_done
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue