threads / discuss / 18055

How can I force git to recognize a change change in file modes?

Subject: How can I force git to recognize a change change in file modes?

## tl;dr

8 messages between Feb 28, 2009 and Feb 28, 2009.

replies: 7people: 5as markdown or json

Brent Goodrick· Feb 28, 2009, 01:17 UTC · lore
Hi,

I checked in a slew of scripts, only to realize that the file permissions were too open (I want them to be chmod 700, not chmod 755). Somehow I thought that git was tracking those permission bits, but simply using "chmod 700 <fileset>; git add <fileset>" did not add the change of file modes, well, at least git status output doesn't show it. Is there a way to do this?

Thanks, Brent

Lars Noschinski· Feb 28, 2009, 01:25 UTC · re: Brent Goodrick · lore

Re: How can I force git to recognize a change change in file modes?

* Brent Goodrick <bgoodr@gmail.com> [09-02-28 02:17]:
Show 6 quoted lines
> I checked in a slew of scripts, only to realize that the file
> permissions were too open (I want them to be chmod 700, not chmod
> 755).  Somehow I thought that git was tracking those permission bits,
> but simply using "chmod 700 <fileset>; git add <fileset>" did not add
> the change of file modes, well, at least git status output doesn't
> show it. Is there a way to do this?
Git does only track the executable bit.
Jan Krüger· Feb 28, 2009, 03:55 UTC · re: Brent Goodrick · lore

Re: How can I force git to recognize a change change in file modes?

Hi,
Show 6 quoted lines
> I checked in a slew of scripts, only to realize that the file
> permissions were too open (I want them to be chmod 700, not chmod
> 755).  Somehow I thought that git was tracking those permission bits,
> but simply using "chmod 700 <fileset>; git add <fileset>" did not add
> the change of file modes, well, at least git status output doesn't
> show it. Is there a way to do this?

git doesn't track permissions quite that closely; all it remembers is whether the file should be executable or not.

-Jan
Brent Goodrick· Feb 28, 2009, 16:24 UTC · re: Jan Krüger · lore

Re: How can I force git to recognize a change change in file modes?

> git doesn't track permissions quite that closely; all it remembers is
> whether the file should be executable or not.

Thanks Jan. Was this choice made due to the conditional coding required to track the permission bits content between *NIX and non-*NIX platform(s)?

bg
Jay Soffian· Feb 28, 2009, 16:52 UTC · re: Brent Goodrick · lore

Re: How can I force git to recognize a change change in file modes?

On Sat, Feb 28, 2009 at 11:24 AM, Brent Goodrick <bgoodr@gmail.com> wrote:
> Thanks Jan.  Was this choice made due to the conditional coding
> required to track the permission bits content between *NIX and
> non-*NIX platform(s)?

The short answer is: because Git was designed to track content. The long answer is more complicated. Here's one of the more useful past discussions:

http://thread.gmane.org/gmane.comp.version-control.git/91783
I'm sure you can find others by searching the git list for "metadata".
j.
Brent Goodrick· Feb 28, 2009, 17:34 UTC · re: Jay Soffian · lore

Re: How can I force git to recognize a change change in file modes?

Show 7 quoted lines
> The short answer is: because Git was designed to track content. The
> long answer is more complicated. Here's one of the more useful past
> discussions:
>
> http://thread.gmane.org/gmane.comp.version-control.git/91783
>
> I'm sure you can find others by searching the git list for "metadata".

I read that thread you showed above. Sounds like a big squirmy can-o-worms, and I see that thread died on the vine because of it. :)

All I want to do in my case is just chmod 700 a bunch of scripts after they are checked out or updated. I'll need to re-read the git-hooks man page more closely.

Thanks for your help! bg

Todd Zullinger· Feb 28, 2009, 18:34 UTC · re: Brent Goodrick · lore

Re: How can I force git to recognize a change change in file modes?

Brent Goodrick wrote:
> All I want to do in my case is just chmod 700 a bunch of scripts
> after they are checked out or updated.  I'll need to re-read the
> git-hooks man page more closely.

You may want to check contrib/hooks/setgitperms.perl as well, if you haven't seen it already.

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problems are opportunity in work clothes.
Brent Goodrick· Feb 28, 2009, 22:43 UTC · re: Todd Zullinger · lore

Re: How can I force git to recognize a change change in file modes?

On Sat, Feb 28, 2009 at 10:34 AM, Todd Zullinger <tmz@pobox.com> wrote:
> You may want to check contrib/hooks/setgitperms.perl as well, if you
> haven't seen it already.

Yes I did see that. I'll be varying that approach a bit since I won't need to preserve perm bits before and after the git operation, but just force them to be a specific value all the time after checkout and update.

bg

← back to recent threads