Re: [Request] Git reset should be able to ignore file permissions

2013-06-20 Thread Alexander Nestorov
@Matthieu
 Ok, I'm replacing with Reset only files which actually changed (not
those with only stat information change)

@Junio
 I'm not sure what you're asking, sorry, I'm not able to understand
your question.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-19 Thread Alexander Nestorov
Ok, this is how it looks. If everything is ok, I'm sending it to the ML

From 262bdfb5cc84fec7c9b74dc92bb604f9d168ef9a Mon Sep 17 00:00:00 2001
From: Alexander Nestorov alexander...@gmail.com
Date: Wed, 19 Jun 2013 09:55:42 +0200
Subject: [PATCH] Add example for reseting based on content changes instead of
 stat changes

---
 Documentation/git-reset.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index a404b47..da639e9 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -289,6 +289,18 @@ $ git reset --keep start3
 3 But you can use reset --keep to remove the unwanted commit after
 you switched to branch2.

+Reset only files who's content changed (instead of stat information)::
++
+
+$ git update-index --refresh   1
+$ git reset --hard 2
+
++
+1 Make Git realize which files actually changed instead of
+checking out all files whether their content changed or only
+their mtime changed.
+2 Now git reset --hard will checkout only the files that
+actually changed.

 DISCUSSION
 --
--
1.8.1.msysgit.1
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
Recently I had to write some automation scripts and I found
that git reset --hard actually restores each file's permissions.

That is causing both the created and the last-modified dates
of the file to get changed to the time of the git reset.

This behavior is easy to demonstrate:

echo test  myfile
chmod 777 myfile
git add myfile  git commit -m Test  git push
chmod 775 myfile
git reset --hard origin/master

After the git reset --hard command, the entire file was
checkout-ed. Instead, git should be able to check if the
content of the file changed and only if it did, check it out.

I do realize that checking the content of each file in a big
repo could result in a slow operation, but there should be a
switch/argument/option to make git reset actually check the
content of each file instead of blindly replacing it.

After reading man a few times I didn't saw any option
that'd let me do this; the only solution I'm able to think about
is actually restoring the permissions of each file to the ones
git thinks they should have before doing the git reset.

Maybe I'm wrong and there is a way for doing what I want, if
so, please correct me.
But if there isn't, should this be implemented? Are there any
reasons for not doing it?


Thank you for your attention
Regards

--
alexandernst
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
Git does preserve file permissions, that is, git is aware of the
permissions you can set with chmod.

I'm not trying to ignore the x bit, what I'm trying to do is make
git reset checkout only the files that actually changed instead
of checking out all the files with different permissions than the
ones git thinks they should have.

Said with other word: when you run git reset, git does a status
and checkouts all the files that showed up from the status.
That's exactly what I'm trying to avoid, as status is aware of both
content changes and permissions changes.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
Git reset --keep is not an option as it will abort the operation if
there are local changes,
which is exactly what I want to do: replace files with local changes
but leave file
permissions as they are.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
Indeed, git update-index --refresh before git reset did the trick :)
Anyways, what about the proposal? Should it be implemented?

Thank you
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
Sorry for not keeping everyone Cced, I wasn't aware of the rules.

Yes, writing about that in the docs seems more reasonable than patching reset,
as as you said, that'd just run update-index before the reset.
Let me get at home and I'll try to push a change :)

Regards
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Request] Git reset should be able to ignore file permissions

2013-06-18 Thread Alexander Nestorov
I'm home, 
https://github.com/alexandernst/git/commit/61f0a7d558e3cbae308fabdff66bd87569d6aa18
Is that good? Should I PR?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html