{"thread":{"id":"34899","subject":"git-cvsserver strips exec bit","startedAt":"2013-09-10T15:23:42Z","lastAt":"2013-09-11T13:12:58Z","messageCount":7,"participants":["Michael Cronenworth","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"227321","messageId":"522F397E.6080709@cchtml.com","threadId":"34899","inReplyTo":null,"subject":"git-cvsserver strips exec bit","fromName":"Michael Cronenworth","fromEmail":"mike@cchtml.com","sentAt":"2013-09-10T15:23:42Z","receivedAt":"2013-09-10T15:23:42Z","isPatch":false,"sender":{"key":"mike@cchtml.com","avatar":null},"body":"Hello,\n\nOn git 1.8.1.x (Fedora 18) I was able to use the git-cvsserver to checkout code\nto package into a tarball. Script files that were in git with 755 masks were\nchecked-out with the same mask. After upgrading the git repository machine to\nFedora 19 (1.8.3.1) the behaviour has changed. When I checkout the same script\nfiles their mask is now 644. The mask has not changed in git.\n\nI understand I can use git-archive to perform the same functionality, but I'd\nlike to report this issue here.\n\nThanks,\nMichael\n"},{"id":"227330","messageId":"xmqqa9jkzk2l.fsf@gitster.dls.corp.google.com","threadId":"34899","inReplyTo":"522F397E.6080709@cchtml.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-10T17:02:26Z","receivedAt":"2013-09-10T17:02:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Cronenworth <mike@cchtml.com> writes:\n\n> On git 1.8.1.x (Fedora 18) I was able to use the git-cvsserver to checkout code\n> to package into a tarball. Script files that were in git with 755 masks were\n> checked-out with the same mask. After upgrading the git repository machine to\n> Fedora 19 (1.8.3.1) the behaviour has changed. When I checkout the same script\n> files their mask is now 644. The mask has not changed in git.\n\nMatthew, I do not know if you are still using the git-cvsserver, but\nit seems that the only substantial change to that subsystem between\nthe 1.8.1.x and 1.8.3.x is your update.\n\nEspecially 2c3af7e7 (cvsserver: factor out git-log parsing logic,\n2012-10-13) looks interesting.  It has a hunk like this:\n\n-                my $git_perms = \"\";\n-                $git_perms .= \"r\" if ( $mode & 4 );\n-                $git_perms .= \"w\" if ( $mode & 2 );\n-                $git_perms .= \"x\" if ( $mode & 1 );\n-                $git_perms = \"rw\" if ( $git_perms eq \"\" );\n+                my $dbMode = convertToDbMode($mode);\n\nwith the definition of convertToDbMode being:\n\n+sub convertToDbMode\n+{\n+    my $mode = shift;\n+    ...\n+    $mode=~/^\\d\\d(\\d)\\d{3}$/;\n+    my $userBits=$1;\n+\n+    my $dbMode = \"\";\n+    $dbMode .= \"r\" if ( $userBits & 4 );\n+    $dbMode .= \"w\" if ( $userBits & 2 );\n+    $dbMode .= \"x\" if ( $userBits & 1 );\n+    $dbMode = \"rw\" if ( $dbMode eq \"\" );\n+\n+    return $dbMode;\n\nThe $mode in the caller comes from diff-tree output (the post-change\nside of the mode string, like \"100755\").\n\nPicking the third digit from the left (i.e. \"10'0'755\"), instead of\nthe tail digit (i.e. \"10075'5'\"), looks strange.\n\nSide note: now I look at it, the original does not make much sense\nfor that matter.  \"100755\" & 4 is different from oct(\"100755\") & 4.\n"},{"id":"227361","messageId":"xmqqfvtcxwqp.fsf@gitster.dls.corp.google.com","threadId":"34899","inReplyTo":"xmqqa9jkzk2l.fsf@gitster.dls.corp.google.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-10T20:11:42Z","receivedAt":"2013-09-10T20:11:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Michael Cronenworth <mike@cchtml.com> writes:\n>\n>> On git 1.8.1.x (Fedora 18) I was able to use the git-cvsserver to checkout code\n>> to package into a tarball. Script files that were in git with 755 masks were\n>> checked-out with the same mask. After upgrading the git repository machine to\n>> Fedora 19 (1.8.3.1) the behaviour has changed. When I checkout the same script\n>> files their mask is now 644. The mask has not changed in git.\n>\n> Matthew, I do not know if you are still using the git-cvsserver, but\n> it seems that the only substantial change to that subsystem between\n> the 1.8.1.x and 1.8.3.x is your update.\n>\n> Especially 2c3af7e7 (cvsserver: factor out git-log parsing logic,\n> 2012-10-13) looks interesting.  It has a hunk like this:\n>\n> -                my $git_perms = \"\";\n> -                $git_perms .= \"r\" if ( $mode & 4 );\n> -                $git_perms .= \"w\" if ( $mode & 2 );\n> -                $git_perms .= \"x\" if ( $mode & 1 );\n> -                $git_perms = \"rw\" if ( $git_perms eq \"\" );\n> +                my $dbMode = convertToDbMode($mode);\n>\n> with the definition of convertToDbMode being:\n>\n> +sub convertToDbMode\n> +{\n> +    my $mode = shift;\n> +    ...\n> +    $mode=~/^\\d\\d(\\d)\\d{3}$/;\n> +    my $userBits=$1;\n> +\n> +    my $dbMode = \"\";\n> +    $dbMode .= \"r\" if ( $userBits & 4 );\n> +    $dbMode .= \"w\" if ( $userBits & 2 );\n> +    $dbMode .= \"x\" if ( $userBits & 1 );\n> +    $dbMode = \"rw\" if ( $dbMode eq \"\" );\n> +\n> +    return $dbMode;\n>\n> The $mode in the caller comes from diff-tree output (the post-change\n> side of the mode string, like \"100755\").\n>\n> Picking the third digit from the left (i.e. \"10'0'755\"), instead of\n> the tail digit (i.e. \"10075'5'\"), looks strange.\n>\n> Side note: now I look at it, the original does not make much sense\n> for that matter.  \"100755\" & 4 is different from oct(\"100755\") & 4.\n\nI stopped interacting with CVS quite a long time ago, so I do not\nhave any way of verifying, but the fix may be just the matter of\nsomething like this.\n\nI am not sure if we want to use the owner bit (i.e. 4th place)\ninstead of the other bit (i.e. the last place) like this patch does,\nthough.  The old code in 1.8.1.x would have produced either \"r\" (for\n100644) or \"wx\" (for 100755); I think that the result of applying\nthis patch would give us \"r\" (for 100644) or \"rx\" (for 100755).\n\n-- >8 --\nSubject: cvsserver: pick up the right mode bits\n\nWhen determining the file mode from either ls-tree or diff-tree\noutput, we used to grab these octal mode string (typically 100644 or\n100755) and then did\n\n\t$git_perms .= \"r\" if ( $mode & 4 );\n\t$git_perms .= \"w\" if ( $mode & 2 );\n\t$git_perms .= \"x\" if ( $mode & 1 );\n\nwhich was already wrong, as (100644 & 4) is very different from\noct(\"100644\") & 4.  An earlier refactoring 2c3af7e7 (cvsserver:\nfactor out git-log parsing logic, 2012-10-13) further changed it to\npick the third octal digit (10*0*644 or 10*0*755) from the left and\nthen do the above conversion, which does not make sense, either.\n\nLet's use the last digit of the octal mode string to make sure we\nget the executable and read bits right.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n git-cvsserver.perl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex a0d796e..b1d7a4c 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -4167,7 +4167,7 @@ sub convertToDbMode\n     #  this half-converted form, but it isn't currently worth the\n     #  backwards compatibility headaches.\n \n-    $mode=~/^\\d\\d(\\d)\\d{3}$/;\n+    $mode=~/^\\d{5}(\\d)$/;\n     my $userBits=$1;\n \n     my $dbMode = \"\";\n"},{"id":"227378","messageId":"522F9B1D.3070100@cchtml.com","threadId":"34899","inReplyTo":"xmqqfvtcxwqp.fsf@gitster.dls.corp.google.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Michael Cronenworth","fromEmail":"mike@cchtml.com","sentAt":"2013-09-10T22:20:13Z","receivedAt":"2013-09-10T22:20:13Z","isPatch":false,"sender":{"key":"mike@cchtml.com","avatar":null},"body":"Junio C Hamano wrote:\n> I stopped interacting with CVS quite a long time ago, so I do not\n> have any way of verifying, but the fix may be just the matter of\n> something like this.\n\nThis fix is close. Now all files are checked out with a mask of 555.\n"},{"id":"227379","messageId":"522F9BBE.404@cchtml.com","threadId":"34899","inReplyTo":"522F9B1D.3070100@cchtml.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Michael Cronenworth","fromEmail":"mike@cchtml.com","sentAt":"2013-09-10T22:22:54Z","receivedAt":"2013-09-10T22:22:54Z","isPatch":false,"sender":{"key":"mike@cchtml.com","avatar":null},"body":"Michael Cronenworth wrote:\n> This fix is close. Now all files are checked out with a mask of 555.\n\nLet me clarify.\n\nGit mask 755 => CVS mask 555\nGit mask 644 => CVS mask 444\n\nThanks,\nMichael\n"},{"id":"227382","messageId":"xmqqtxhsux25.fsf@gitster.dls.corp.google.com","threadId":"34899","inReplyTo":"522F9BBE.404@cchtml.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-10T22:33:06Z","receivedAt":"2013-09-10T22:33:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Cronenworth <mike@cchtml.com> writes:\n\n> Michael Cronenworth wrote:\n>> This fix is close. Now all files are checked out with a mask of 555.\n>\n> Let me clarify.\n>\n> Git mask 755 => CVS mask 555\n> Git mask 644 => CVS mask 444\n>\n> Thanks,\n> Michael\n\nThen what I wrote was actually relevant ;-)\n\n    I am not sure if we want to use the owner bit (i.e. 4th place)\n    instead of the other bit (i.e. the last place) like this patch does,\n    though.  The old code in 1.8.1.x would have produced either \"r\" (for\n    100644) or \"wx\" (for 100755); I think that the result of applying\n    this patch would give us \"r\" (for 100644) or \"rx\" (for 100755).\n\nThis should then work, I would think.\n\n-- >8 --\nSubject: [PATCH v2] cvsserver: pick up the right mode bits\n\nWhen determining the file mode from either ls-tree or diff-tree\noutput, we used to grab these octal mode string (typically 100644 or\n100755) and then did\n\n\t$git_perms .= \"r\" if ( $mode & 4 );\n\t$git_perms .= \"w\" if ( $mode & 2 );\n\t$git_perms .= \"x\" if ( $mode & 1 );\n\nwhich was already wrong, as (100644 & 4) is very different from\noct(\"100644\") & 4.  An earlier refactoring 2c3af7e7 (cvsserver:\nfactor out git-log parsing logic, 2012-10-13) further changed it to\npick the third octal digit (10*0*644 or 10*0*755) from the left and\nthen do the above conversion, which does not make sense, either.\n\nLet's use the third digit from the last of the octal mode string to\nmake sure we get the executable and read bits right.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n git-cvsserver.perl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex a0d796e..67b1e7b 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -4167,7 +4167,7 @@ sub convertToDbMode\n     #  this half-converted form, but it isn't currently worth the\n     #  backwards compatibility headaches.\n \n-    $mode=~/^\\d\\d(\\d)\\d{3}$/;\n+    $mode=~/^\\d{3}(\\d)\\d\\d$/;\n     my $userBits=$1;\n \n     my $dbMode = \"\";\n"},{"id":"227448","messageId":"52306C5A.7070507@cchtml.com","threadId":"34899","inReplyTo":"xmqqtxhsux25.fsf@gitster.dls.corp.google.com","subject":"Re: git-cvsserver strips exec bit","fromName":"Michael Cronenworth","fromEmail":"mike@cchtml.com","sentAt":"2013-09-11T13:12:58Z","receivedAt":"2013-09-11T13:12:58Z","isPatch":false,"sender":{"key":"mike@cchtml.com","avatar":null},"body":"Junio C Hamano wrote:\n> Then what I wrote was actually relevant;-)\n>\n>      I am not sure if we want to use the owner bit (i.e. 4th place)\n>      instead of the other bit (i.e. the last place) like this patch does,\n>      though.  The old code in 1.8.1.x would have produced either \"r\" (for\n>      100644) or \"wx\" (for 100755); I think that the result of applying\n>      this patch would give us \"r\" (for 100644) or \"rx\" (for 100755).\n>\n> This should then work, I would think.\n\nYes, this new patch fixes the issue.\n\nThanks!\nMichael\n"}]}