* Is there a "git reset --keep <sha1> || git reset --hard <sha1>" alternative?
@ 2016-04-20 17:18 Ævar Arnfjörð Bjarmason
2016-04-20 19:03 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2016-04-20 17:18 UTC (permalink / raw
To: Git; +Cc: Christian Couder
If you check out a git repository and chmod a checked-in file there
there away from git defaults then "git reset --hard" will re-chmod it.
The use-case for not having this happen is if you e.g. have some
inotify thing or a stat() loop monitoring changes to the files, and
you'd like them to fire on "real" updates, not just updates that were
introduced because something re-chmoded a file.
E.g. on current git.git master:
$ ls -l INSTALL ; chmod 600 INSTALL ; git reset --hard @{u} ; ls -l INSTALL
-rw-r--r-- 1 avar avar 9147 Apr 20 17:11 INSTALL
HEAD is now at e6ac6e1 Fifth batch for post 2.8 cycle
-rw-r--r-- 1 avar avar 9147 Apr 20 17:12 INSTALL
What I'd like is for the permissions not to be altered:
$ ls -l INSTALL ; chmod 600 INSTALL ; git reset --keep @{u} ; ls -l INSTALL
-rw-r--r-- 1 avar avar 9147 Apr 20 17:12 INSTALL
-rw------- 1 avar avar 9147 Apr 20 17:12 INSTALL
But I don't want this to happen:
$ echo "Blah" > INSTALL && git add INSTALL && git commit -m"blah"
[master d29463e] blah
1 file changed, 1 insertion(+), 223 deletions(-)
rewrite INSTALL (100%)
$ ls -l INSTALL ; chmod 600 INSTALL ; git reset --keep @{u} ; ls -l INSTALL
-rw------- 1 avar avar 5 Apr 20 17:14 INSTALL
error: Entry 'INSTALL' not uptodate. Cannot merge.
fatal: Could not reset index file to revision '@{u}'.
-rw------- 1 avar avar 5 Apr 20 17:14 INSTALL
Instead I want:
$ ls -l INSTALL ; chmod 600 INSTALL ; git reset --keep @{u} || git
reset --hard @{u} ; ls -l INSTALL
-rw------- 1 avar avar 5 Apr 20 17:14 INSTALL
error: Entry 'INSTALL' not uptodate. Cannot merge.
fatal: Could not reset index file to revision '@{u}'.
HEAD is now at e6ac6e1 Fifth batch for post 2.8 cycle
-rw-r--r-- 1 avar avar 9147 Apr 20 17:15 INSTALL
And the expectation here is that I'll have something that does a chmod
after the reset happens, which is fine because we had a "real" change,
I just don't want the repo to keep having flip-flopping permissions
because I'd both like:
* Local chmod to be respected
* Actual file content changes to be wiped away by reset --hard
Is there another way to do this, or dare I say alternatively maybe we
could use another option to reset making it even more confusing :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is there a "git reset --keep <sha1> || git reset --hard <sha1>" alternative?
2016-04-20 17:18 Is there a "git reset --keep <sha1> || git reset --hard <sha1>" alternative? Ævar Arnfjörð Bjarmason
@ 2016-04-20 19:03 ` Junio C Hamano
2016-04-20 20:28 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2016-04-20 19:03 UTC (permalink / raw
To: Ævar Arnfjörð Bjarmason; +Cc: Git, Christian Couder
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> $ ls -l INSTALL ; chmod 600 INSTALL ; git reset --hard @{u} ; ls -l INSTALL
> -rw-r--r-- 1 avar avar 9147 Apr 20 17:11 INSTALL
> HEAD is now at e6ac6e1 Fifth batch for post 2.8 cycle
> -rw-r--r-- 1 avar avar 9147 Apr 20 17:12 INSTALL
A quick question. What happens when you did this instead?
chmod 600 INSTALL
git update-index --refresh
git reset --hard
Does it match what you want to see?
The reason I ask is because I recall making a deliberate design
decision around this area.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is there a "git reset --keep <sha1> || git reset --hard <sha1>" alternative?
2016-04-20 19:03 ` Junio C Hamano
@ 2016-04-20 20:28 ` Ævar Arnfjörð Bjarmason
0 siblings, 0 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2016-04-20 20:28 UTC (permalink / raw
To: Junio C Hamano; +Cc: Git, Christian Couder
On Wed, Apr 20, 2016 at 9:03 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> $ ls -l INSTALL ; chmod 600 INSTALL ; git reset --hard @{u} ; ls -l INSTALL
>> -rw-r--r-- 1 avar avar 9147 Apr 20 17:11 INSTALL
>> HEAD is now at e6ac6e1 Fifth batch for post 2.8 cycle
>> -rw-r--r-- 1 avar avar 9147 Apr 20 17:12 INSTALL
>
> A quick question. What happens when you did this instead?
>
> chmod 600 INSTALL
> git update-index --refresh
> git reset --hard
>
> Does it match what you want to see?
>
> The reason I ask is because I recall making a deliberate design
> decision around this area.
The --hard doesn't wipe away the chmod, makes sense:
$ ls -l INSTALL ; chmod 600 INSTALL ; git update-index --refresh;
git reset --hard @{u} ; ls -l INSTALL
-rw-r--r-- 1 avar avar 9147 Apr 20 22:27 INSTALL
HEAD is now at 05045e0 tracing
-rw------- 1 avar avar 9147 Apr 20 22:27 INSTALL
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-20 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 17:18 Is there a "git reset --keep <sha1> || git reset --hard <sha1>" alternative? Ævar Arnfjörð Bjarmason
2016-04-20 19:03 ` Junio C Hamano
2016-04-20 20:28 ` Ævar Arnfjörð Bjarmason
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).