git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Set permissions of each new file before "cvs add"ing it.

From
Jim Meyering <jim@meyering.net>
Date
Dec 3, 2006, 19:51 UTC
Message-ID
<87ac24zrk0.fsf@rho.meyering.net>

Without the following patch, git-cvsexportcommit would fail to propagate permissions of files added in git to the CVS repository. I.e., when I added an executable script in coreutils' git repo, then tried to propagate that addition to the mirroring CVS repository, the script ended up added not executable there.

Signed-off-by: Jim Meyering <jim@meyering.net>
---
 git-cvsexportcommit.perl |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 7bac16e..f819eb2 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -268,6 +268,7 @@ if (($? >> 8) == 2) {
 }

 foreach my $f (@afiles) {
+    set_new_file_permissions($f);
     if (grep { $_ eq $f } @bfiles) {
       system('cvs', 'add','-kb',$f);
     } else {
@@ -342,3 +343,21 @@ 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) = @_;
+    # Given input like this:
+    # ba45154d8e9f5f49f46c8c2c2d8a554db7c3465f ...
+    # :000000 100755 0000000... b595dc6... A  tests/du/one-file-system
+    # extract the three octal permission digits:
+    my $cmd = 'git-whatchanged --max-count=1 --pretty=oneline -- $f'
+      . q! | sed -n '2s/^:00* [0-7][0-7][0-7]\([0-7][0-7][0-7]\) .*/\1/p'!;
+    my $perm = `$cmd`;
+
+    chmod oct($perm), $file
+      or die "failed to set permissions of \"$file\": $!\n";
+}
--
Next: Junio C Hamano
Message 1 of 5 in “Set permissions of each new file before "cvs add"ing it.”
  1. Jim MeyeringDec 3, 2006
  2. Junio C HamanoDec 4, 2006
  3. Junio C HamanoDec 4, 2006
  4. Jim MeyeringDec 4, 2006
  5. Robin RosenbergDec 4, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.