From: Andreas Ericsson <ae@op5.se>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Alan Hourihane <alanh@fairlite.co.uk>,
git@vger.kernel.org
Subject: Re: new platform & S_IFGITLINK problem
Date: Tue, 04 May 2010 08:13:44 +0200 [thread overview]
Message-ID: <4BDFBB18.70800@op5.se> (raw)
In-Reply-To: <alpine.LFD.2.00.1005032042470.5478@i5.linux-foundation.org>
On 05/04/2010 05:52 AM, Linus Torvalds wrote:
>
>
> On Mon, 3 May 2010, Linus Torvalds wrote:
>> On Sat, 1 May 2010, Junio C Hamano wrote:
>>>
>>> (3) write MODE_SYSTEM_TO_GIT() macro to convert from S_IF{REG,DIR,LNK} we
>>> read from struct stat to the "canonical" GIT_S_IF{REG,DIR,LNK}
>>> values; and
>>>
>>> (4) change all the code that read mode from struct stat and use it to
>>> first use MODE_SYSTEM_TO_GIT().
>>>
>>> Currently 'git grep -e "S_IF[A-Z]" -e "struct stat"' reports around 250
>>> hits, so it is not infeasible amount of work, but it is not a trivial and
>>> mechanical replacement, either. I or somebody need to set aside a block
>>> of time to do this clean-up and audit the result.
>>
>> Ugh. And since nobody sane has different values from the system ones, if
>> we miss some case we'll never notice on any sane platform ;(
>
> As to your (3) and (4), I actually think that the best option would be to
> stop using '[lf]stat()' directly for "working tree stat", and instead just
> introduce a 'git_[lf]stat()' function that just always does the conversion
> (when necessary - the "conversion" can be a no-op on sane architectures)
> for us.
>
> Right now, a _lot_ of the functions work either directly on 'st->st_mode'
> _or_ on random index entries, and that would be a major pain if they might
> ever be in "different number domains". So the easiest way to make sure
> that we _always_ use the GIT_IFxyz numbers would be to never ever have
> anything that uses the native ones even by mistake.
>
> I've actually wanted to have a 'git_lstat()' wrapper for other reasons: it
> would have made it _so_ much easier to do breakpoints etc when doing the
> whole name lookup optimizations.
>
> Note: there are various cases of '[lf]stat()' being used not for working
> tree entries, but for things like the pack files etc internal git files.
> Those should _not_ do the conversion - they should use the "native" stat()
> functions. It's only the working tree accesses we should need to do any
> conversion on, since those are the ones that are relevant for the index
> (and tree) comparisons.
>
There are other benefits to the git_[fl]stat as well. Windows people would
probably be delighted if they were introduced. We have them in libgit2 for
that precise reason, since stat() sucks arse but some fileGetInfo() call is
at least reasonably fast on windows.
So why not make even pack file access work with the git macros? After all,
the conversion is a no-op on sane platforms, and it would probably be
easier to review patches if one doesn't have to remember that we have two
stat() implementations and which one to use where. Especially when we add
utility functions like read_file_chunk() (no, it doesn't exist) that could
operate on either internal files or work-tree files.
It would also make code-stealing to libgit2 a bit easier ;)
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
next prev parent reply other threads:[~2010-05-04 6:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-01 23:29 new platform & S_IFGITLINK problem Alan Hourihane
2010-05-02 2:33 ` Junio C Hamano
2010-05-02 9:39 ` Alan Hourihane
2010-05-04 3:39 ` Linus Torvalds
2010-05-04 3:52 ` Linus Torvalds
2010-05-04 6:13 ` Andreas Ericsson [this message]
2010-05-04 14:34 ` Linus Torvalds
2010-05-04 15:29 ` Junio C Hamano
2010-05-04 7:21 ` Alan Hourihane
2010-07-22 16:23 ` Alan Hourihane
2010-07-25 17:29 ` Junio C Hamano
2010-07-25 18:00 ` Alan Hourihane
2010-08-02 16:11 ` Ævar Arnfjörð Bjarmason
2010-08-02 16:14 ` Alan Hourihane
2010-08-02 16:26 ` Ævar Arnfjörð Bjarmason
2010-05-05 2:29 ` Jonathan Nieder
2010-05-05 8:36 ` Alan Hourihane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BDFBB18.70800@op5.se \
--to=ae@op5.se \
--cc=alanh@fairlite.co.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).