git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Jim Meyering <jim@meyering.net>
Cc: git@vger.kernel.org
Subject: Re: Set permissions of each new file before "cvs add"ing it.
Date: Sun, 03 Dec 2006 18:47:26 -0800	[thread overview]
Message-ID: <7v64cstm0x.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vbqmktmb7.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Sun, 03 Dec 2006 18:41:16 -0800")

Junio C Hamano <junkio@cox.net> writes:

> Jim Meyering <jim@meyering.net> writes:
>
>> Without the following patch, git-cvsexportcommit would fail to propagate
>> permissions of files added in git to the CVS repository...
> ...
> Why sed in a Perl script ;-)?

That is,...

-- >8 --

diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 7bac16e..7f70501 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -116,6 +116,7 @@ if ($opt_a) {
 close MSG;
 
 my (@afiles, @dfiles, @mfiles, @dirs);
+my (%amodes);
 my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
 #print @files;
 $? && die "Error in git-diff-tree";
@@ -124,6 +125,7 @@ foreach my $f (@files) {
     my @fields = split(m!\s+!, $f);
     if ($fields[4] eq 'A') {
         my $path = $fields[5];
+	$amodes[$path] = $fields[1];
 	push @afiles, $path;
         # add any needed parent directories
 	$path = dirname $path;
@@ -268,6 +270,7 @@ if (($? >> 8) == 2) {
 }
 
 foreach my $f (@afiles) {
+    set_new_file_permissions($f, $amodes[$f]);
     if (grep { $_ eq $f } @bfiles) {
       system('cvs', 'add','-kb',$f);
     } else {
@@ -342,3 +345,13 @@ sub safe_pipe_capture {
     }
     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";
+}

  reply	other threads:[~2006-12-04  2:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-03 19:51 Set permissions of each new file before "cvs add"ing it Jim Meyering
2006-12-04  2:41 ` Junio C Hamano
2006-12-04  2:47   ` Junio C Hamano [this message]
2006-12-04  7:55     ` Jim Meyering
2006-12-04 16:51 ` Robin Rosenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v64cstm0x.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=jim@meyering.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).