Skip to content

Don't use absolute paths (Cygwin workaround)#22

Open
mcfrisk wants to merge 1 commit intohoxu:masterfrom
mcfrisk:rela_paths
Open

Don't use absolute paths (Cygwin workaround)#22
mcfrisk wants to merge 1 commit intohoxu:masterfrom
mcfrisk:rela_paths

Conversation

@mcfrisk
Copy link
Copy Markdown

@mcfrisk mcfrisk commented Jul 16, 2013

They break when Cygwin is mixing both unix and dos path formats.
This creates directories named like dos drives, like C:, and
removing them in Cygwin results in "rm -rf C:/" which is not nice.

Signed-off-by: Mikko Rapeli mikko.rapeli@iki.fi

They break when Cygwin is mixing both unix and dos path formats.
This creates directories named like dos drives, like C:, and
removing them in Cygwin results in "rm -rf C:/" which is not nice.

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
@hoxu
Copy link
Copy Markdown
Owner

hoxu commented Jul 16, 2013

I'm afraid this change would break things. For example, gitstats . output/foo would result in call to os.path.basename('.') which does not give expected result.

I don't see why os.path.abspath should break things on any platform, so I'm leaning towards considering this a Cygwin issue.

@mcfrisk
Copy link
Copy Markdown
Author

mcfrisk commented Jul 16, 2013

Well, . is a valid path name. IMO, all scripts which take path names as input should use the same paths without mangling or cleaning them up. Just use them as they come. That way failure modes are easy to understand for the user who supplied the path name. In my case CMake generates makefiles in Windows which contain cygwin&Windows compatible path names. These paths are then fed to tools like gitstats. I've had fix a number of python scripts to get rid of abspath, but yes, cygwin&python case is a bit special compared to standard unix behaviour.

@hoxu
Copy link
Copy Markdown
Owner

hoxu commented Jul 16, 2013

If I remember right, those abspath calls are there for a reason. git log -Sabspath -p might be useful here. One of those abspath calls is needed to get the last part of the path component for the default project name.

Another thing is, gitstats uses os.chdir. If I skimmed the source right, that wouldn't be an issue in this case, but I'm still a bit vary of mixing chdir & relative path names.

What kind of pathnames does cmake generate? Is Cygwin the only option for running gitstats on Windows (I think someone used msysgit in the past, I personally don't have a Windows box so I have no clue)?

@mcfrisk
Copy link
Copy Markdown
Author

mcfrisk commented Jul 16, 2013

IMO there's no way to infer a project name correctly from a git tree unless .git/description has been set, and even that might not be a single word name. I would never convert user supplied paths to absolute ones. I'd just use the provided path name and fail on errors.

CMake is generating paths like c:/temp when using the "Unix Makefiles" generator on Windows. All GNU make versions on Windows, cygwin and native Windows tools that I've used work with these path names which are already absolute.

I posted a question also to cygwin list:
http://cygwin.com/ml/cygwin/2013-07/msg00322.html

@hoxu
Copy link
Copy Markdown
Owner

hoxu commented Jul 16, 2013

As you posted on the mailing list, python behavior seems odd on Cygwin, more so in comparison to perl. I think it would be better that the actual problem is fixed (unexpected behavior of os.path.abspath on Cygwin), rather than a workaround created for gitstats.

I'll leave this issue open for now, in case anyone else runs into the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants