lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] git: committing content and mode changes together


From: Greg Chicares
Subject: Re: [lmi] git: committing content and mode changes together
Date: Fri, 4 Nov 2016 14:33:00 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.3.0

On 2016-11-04 13:52, Vadim Zeitlin wrote:
> On Fri, 4 Nov 2016 01:59:36 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> Working with one particular file (in a proprietary repository),
> GC> I changed its contents and its mode, thus:
> GC>   git update-index --chmod=-x my_file.txt
> 
>  I hadn't known about --chmod option of update-index until today, thanks
> for mentioning it, it's surely going to be useful to me in the future.

Well, that's a revelation. I had assumed that 'update-index --chmod'
was imperative--that it was the only way to change permissions on a file
in the repository. I was thinking in this context:

http://stackoverflow.com/questions/17846551/svn-how-to-set-the-executable-bit-on-a-file
| I've tried:
|   chmod +x sync.py
|   svn commit sync.py -m "Make sync.py executable"
| But the change was not propagated.

where 'svn propset' is required, and the parallel git command is
'git update-index --chmod'. However: "svn makes me do this silly thing,
so what would be the silly way to do the same thing with git?" is not
the right question.

[...snip puzzling problems...]

>  I can't explain this though... As I said, I don't have any experience with
> it because the way I normally do it is just
> 
>       $ chmod -x my_file.txt
>       $ git commit -m 'Reset executable bit' $_

I had no idea it was that easy. And I think this crucial point explains
why nobody ever asked about this on stackoverflow (e.g.), because it
really is as simple as dirt.

[...snip more puzzling problems...]

>  This is even more mysterious, especially if this is under Linux and not
> Cygwin. Under Cygwin file permissions are a never ending source of
> puzzlement as Cygwin permissions don't map one to one to MSW ACLs and if
> you touch the same file using a native MSW program you're almost bound to
> have some surprises. It also depends on whether you use the Cygwin or
> native version of git, whether your core.filemode is true or false (which I
> strongly recommend) for this repository and the current phase of the moon.

I'm not using cygwin at all anymore, except for occasional testing.

Kim's using cygwin; and cygwin's own 'git' (never 'msysgit' or any
native 'git'); and some native msw programs.

I hesitate to set this:
  git config core.filemode true
because, if that's set, then changing a file's mode really does require
'update-index --chmod', doesn't it? And I hesitate to suggest setting it
for msw (cygwin) only because that would make the same command behave
differently on different systems. Instead, I think the One True Way is
to install a pre-commit hook that validates the mode of every file.

> GC> but my problem is the opposite: I want to commit them together. What's
> GC> the simple, obvious sequence of steps to do that?

It seems that you answered that above:
  change the file's mode with /bin/chmod (not 'update-index --chmod');
  change the file's contents (before or after changing the mode); then
  git commit




reply via email to

[Prev in Thread] Current Thread [Next in Thread]