Reputation: 367
The title says it all, but for example, if the HEAD
of a Git repository points to ref/heads/master
on any well-used Git implementation for Windows, which of the following is the content of the file .git/HEAD
... oops, .git\HEAD
:
ref: refs/heads/master
, orref: refs\heads\master
?Either way, I need to calculate the absolute path <git project>\.git\refs\heads\master
, but I don't have Windows environment and I can't get to know which form is used! Answer is greatly appreciated.
Background: I'm modifying a Haskell library implementing a macro that embeds the Git revision hashes of Haskell projects into their source codes right on compilation (very nice for implementing --version
option!). When we compile the program invocating that macro, git
is called; however even before that, when a build tool is checking whether recompilation is required, we cannot call git
and all that's done is simple file update check! Therefore, at the time of each compilation, we must compute and save the path of reference file at which HEAD
is pointing, so that the reference file would be checked for update next time. The problem is that I would like to make the library cross-platform but that I don't know how to compute the path of a reference file on Windows, for I don't know the original form.
Upvotes: 1
Views: 550
Reputation: 76459
HEAD
uses a reference name and not a path separator. Git always uses forward slashes in reference names, even on Windows. Backslashes are never allowed in a reference name on any platform, ever.
Since Windows will also allow forward slash path separators (unless you're using UNC paths), it's usually safe to just use forward slashes everywhere unless you know you have special needs.
Upvotes: 2