Git development
 help / color / mirror / Atom feed
From: Johannes Sixt <johannes.sixt@telecom.at>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>
Subject: Re: [PATCH] Add core.symlinks to mark filesystems that do not support symbolic links.
Date: Sat, 3 Mar 2007 13:20:13 +0100	[thread overview]
Message-ID: <200703031320.13535.johannes.sixt@telecom.at> (raw)
In-Reply-To: <7vr6s7chim.fsf@assigned-by-dhcp.cox.net>

On Saturday 03 March 2007 01:12, Junio C Hamano wrote:
> Junio C Hamano <junkio@cox.net> writes:
> > This code (I am the guilty one before your change above) always
> > confused me.  How about doing something like this instead?
> >
> >     static inline unsigned int ce_mode_from_stat(struct cache_entry
> > *ce,... {
> >         /*
> >          * A regular file that appears on the filesystem can have
> >          * a "wrong" st_mode information.  A few repository config
> >          * variables can tell us to trust the mode recorded in the
> >          * index more than what we get from the filesystem.
> >          */
> >         if (ce && S_ISREG(mode)) {
> >             extern int trust_executable_bit, has_symlinks;
> >
> >             if (!has_symlinks && S_ISLNK(ntohl(ce->ce_mode)))
> >                 return ce->ce_mode;
>
> Oops, these three lines
>
> >             if (!trust_executable_bit && S_ISREG(ntohl(ce->ce_mode)))
> >                 return ce->ce_mode;
> >             return create_ce_mode(0666);
>
> should be:
>
> 		if (!trust...) {
>                 	if (S_ISREG(...))
>                         	return ce->ce_mode;
> 			return create_ce_mode(0666);
> 		}

I think that's still not correct. Because in the case of !trust_executable_bit 
we want create_ce_mode(0666) regardless of whether a ce exists or not. Maybe 
this way:

    static inline unsigned int ce_mode_from_stat(struct cache_entry *ce,...
    {
        /*
         * A regular file that appears on the filesystem can have
         * a "wrong" st_mode information.  A few repository config
         * variables can tell us to trust the mode recorded in the
         * index more than what we get from the filesystem.
         */
        if (S_ISREG(mode)) {
            extern int trust_executable_bit, has_symlinks;

            if (!has_symlinks && ce && S_ISLNK(ntohl(ce->ce_mode)))
                return ce->ce_mode;
            if (!trust_executable_bit) {
                if (ce && S_ISREG(ntohl(ce->ce_mode)))
                    return ce->ce_mode;
                return create_ce_mode(0666);
            }
        }
        return create_ce_mode(mode);
    }


-- Hannes

  reply	other threads:[~2007-03-03 12:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-02 21:11 [PATCH] Add core.symlinks to mark filesystems that do not support symbolic links Johannes Sixt
2007-03-02 21:35 ` Johannes Schindelin
2007-03-02 22:05   ` Johannes Sixt
2007-03-03  0:05 ` Junio C Hamano
2007-03-03  0:12   ` Junio C Hamano
2007-03-03 12:20     ` Johannes Sixt [this message]
2007-03-03 12:44       ` Junio C Hamano
2007-03-03  0:14   ` Narrow checkouts, was " Johannes Schindelin

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=200703031320.13535.johannes.sixt@telecom.at \
    --to=johannes.sixt@telecom.at \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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