git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] builtin-apply: prevent non-explicit permission changes

From
APAlexander Potashev <aspotashev@gmail.com>
Date
Jan 1, 2009, 22:17 UTC
Message-ID
<20090101221720.GA5603@myhost>
In-Reply-To
<7vfxk3npuc.fsf@gitster.siamese.dyndns.org>
On 05:00 Thu 01 Jan     , Junio C Hamano wrote:
Show 26 quoted lines
> Alexander Potashev <aspotashev@gmail.com> writes:
> 
> >  builtin-apply.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/builtin-apply.c b/builtin-apply.c
> > index 07244b0..071f6d8 100644
> > --- a/builtin-apply.c
> > +++ b/builtin-apply.c
> > @@ -630,7 +630,7 @@ static int gitdiff_index(const char *line, struct patch *patch)
> >  	memcpy(patch->new_sha1_prefix, line, len);
> >  	patch->new_sha1_prefix[len] = 0;
> >  	if (*ptr == ' ')
> > -		patch->new_mode = patch->old_mode = strtoul(ptr+1, NULL, 8);
> > +		patch->old_mode = strtoul(ptr+1, NULL, 8);
> >  	return 0;
> >  }
> >  
> > @@ -2447,6 +2447,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
> >  	if (st_mode != patch->old_mode)
> >  		fprintf(stderr, "warning: %s has type %o, expected %o\n",
> >  			old_name, st_mode, patch->old_mode);
> > +	patch->new_mode = st_mode;
> 
> Can you do this unconditionally, overwriting whatever we read from the
> patch header metainfo lines?

Do you mean overwriting of 'patch->new_mode' right after patch parsing? If so, there would be yet another call to 'stat' to get the permissions of the existing file (that is not very good).

I'm not very familiar with Git sources.

Also, I don't understand what are the permissions in 'index ...' lines for (e.g. "index fc3c3a4..066a4ac 100644"), my patch simply drops them:

> > -		patch->new_mode = patch->old_mode = strtoul(ptr+1, NULL, 8);
> > +		patch->old_mode = strtoul(ptr+1, NULL, 8);

...not completely drops, probably we should cross out this line completely (I don't know whether it breaks something).

					Alexander
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “builtin-apply: prevent non-explicit permission changes”
  1. builtin-apply: prevent non-explicit permission changesAlexander Potashev, Dec 30, 2008
  2. Junio C HamanoJan 1, 2009
  3. Alexander PotashevJan 1, 2009
  4. Junio C HamanoJan 2, 2009
  5. Alexander PotashevJan 2, 2009
  6. Junio C HamanoJan 2, 2009
  7. Jeff KingJan 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.