monotone

Issue 99: mtn:execute attr sometimes initialized wrong on Cygwin and MinGW

Reported by Stephen Leake, Oct 28, 2010

For example, see the diff_on_missing_trailing_newline_at_end_of_file 
test; file1 and file2 both have the mtn:execute attr set when using 
the attr_init_function in std_hooks.lua

mtn version 0.47 and after

There are conflicting requirements for 
attr_init_functions["mtn:execute"]. On one hand, if a 
project is multi-platform, it must produce the same answer for the 
same file on all platforms, so revids are invariant across 
platforms.

On the other hand, if a project is single platform, it would be 
reasonable to have use the same algorithm as the platform to mark 
executable files.

Since single platform projects are more common, it makes sense for 
the mtn default to be appropriate for the current platform; projects 
with other needs must override the hook.

This was discussed in issue 97. Adapting what Richard wrote:

Looking at the source, I'd say that the problem lies in the lua 
routine called is_executable(), in unix/process.cc and 
win32/process.cc.  win32/process.cc does nothing (it just returns 
false), while unix/process.cc does what's sensible for Unix.

Further analysis shows that (since mtn 0.47), Cygwin is regarded as 
unix by configure.ac.  This is probably normally a good thing, since 
it tries to emulate unix...  but when it comes to is_executable, 
maybe 
that's not the best idea.

So we have a choice.  Either add *-pc-cygwin in the case that 
catches Win32 platforms in configure.ac, or make is_executable in 
unix/process.cc a special case for Cygwin.

(end adapt Richard)

Note that the default value for Win32 is also wrong; it should 
compare the file extension to the PATHEXT environment variable, as 
the DOS shell does.

The problem on Cygwin is compounded by the fact that 'mtn checkout' 
marks some files as executable even when they do not have the 
mtn:execute attr; for example, file1 in 
diff_on_missing_trailing_newline_at_end_of_file.

Comment 1 by Stephen Leake, Oct 28, 2010

Lapo Luchini writes on monotone-devel:

Cygwin *has* the executable bit, and it is mapped on the "can 
be executed" standard Windows ACL, which more or less all files 
gets by default.

So, if you create a text file with notepad.exe, Cygwin see it as 
executable. If you create one with Cygwin's nano, it is not.

The same is true of mtn MinGW; it uses the standard Windows file 
create API, which sets the "can be executed" ACL. So 
non-executable files checked out by the MinGW mtn are seen by the 
Cygwin mtn as executable. That explains the symptoms reported above.

A partial fix would be to have the MinGW mtn set the ACL correctly, 
and document the bizarre Windows behavior for non-mtn non-cygwin 
tools.

Created: 8 years 11 months ago by Stephen Leake

Updated: 8 years 11 months ago

Status: New

Labels:
Type:Defect
Priority:Medium

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status