* git-pull sets write bit, git-push does not @ 2008-08-02 22:32 Alexander E Genaud 2008-08-02 23:18 ` Matt Pearson 0 siblings, 1 reply; 3+ messages in thread From: Alexander E Genaud @ 2008-08-02 22:32 UTC (permalink / raw) To: git git-pull sets write bit, git-push does not Hello, Background: I am using Git locally with ClearCase upstream. I initialized a Git repository on top of a ClearCase snapshot view, while my work branches are in a clone. As ClearCase is particular about the write bit, I have come to depend on an undocumented feature of Git. Namely, that git-push preserves read only permissions, while git-pull sets modified files writable. Can git-push be relied upon to preserve the write bit (readonly)? Why is git-pull different? Is it a side effect of the plumbing? Thanks, Alex http://genaud.net/2008/08/clearcase-globally-git-locally/ Simplified case: echo -- echo create a repo r1 with files A and B committed echo -- mkdir r1 cd r1 echo A > A echo B > B git init git add . git commit -m init echo -- echo create an identical repo r2 whose files are readonly echo -- cp -r ../r1 ../r2 chmod u-w ../r2/[AB] echo -- echo push a modification of A from r1 to r2 echo -- echo AA > A git commit -a -m modA git push ../r2 echo -- echo pull a modification of B from r1 to r2 echo -- echo BB > B git commit -a -m modB cd ../r2 git pull ../r1 echo -- echo notice that pushed A remains readonly echo while pulled B has become writable echo -- ls -l -- [ alex@genaud.net ][ http://genaud.net ] [ B068 ED90 F47B 0965 2953 9FC3 EE9C C4D5 3E51 A207 ] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-pull sets write bit, git-push does not 2008-08-02 22:32 git-pull sets write bit, git-push does not Alexander E Genaud @ 2008-08-02 23:18 ` Matt Pearson 2008-08-03 1:15 ` Matt Pearson 0 siblings, 1 reply; 3+ messages in thread From: Matt Pearson @ 2008-08-02 23:18 UTC (permalink / raw) To: Alexander E Genaud; +Cc: git On Sat, Aug 2, 2008 at 6:32 PM, Alexander E Genaud <alex@genaud.net> wrote: > git-pull sets write bit, git-push does not > > Hello, > > Background: I am using Git locally with ClearCase upstream. I > initialized a Git repository on top of a ClearCase snapshot view, > while my work branches are in a clone. As ClearCase is particular > about the write bit, I have come to depend on an undocumented feature > of Git. Namely, that git-push preserves read only permissions, while > git-pull sets modified files writable. > > Can git-push be relied upon to preserve the write bit (readonly)? Why > is git-pull different? Is it a side effect of the plumbing? Push and pull are not opposite operations: the opposite of push is fetch. This is because pull updates the working copy, while push does not (like fetch, it only modifies the ref). > > Thanks, > Alex > > http://genaud.net/2008/08/clearcase-globally-git-locally/ > > > Simplified case: > > echo -- > echo create a repo r1 with files A and B committed > echo -- > mkdir r1 > cd r1 > echo A > A > echo B > B > git init > git add . > git commit -m init > > echo -- > echo create an identical repo r2 whose files are readonly > echo -- > cp -r ../r1 ../r2 > chmod u-w ../r2/[AB] > > echo -- > echo push a modification of A from r1 to r2 > echo -- > echo AA > A > git commit -a -m modA > git push ../r2 > > echo -- > echo pull a modification of B from r1 to r2 > echo -- > echo BB > B > git commit -a -m modB > cd ../r2 > git pull ../r1 > > echo -- > echo notice that pushed A remains readonly > echo while pulled B has become writable > echo -- > ls -l > After running this: $ cat A A $ cat ../r1/A AA The working copy in r2 was not updated with the changes you pushed to it (both the content and the mode change). ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-pull sets write bit, git-push does not 2008-08-02 23:18 ` Matt Pearson @ 2008-08-03 1:15 ` Matt Pearson 0 siblings, 0 replies; 3+ messages in thread From: Matt Pearson @ 2008-08-03 1:15 UTC (permalink / raw) To: Alexander E Genaud; +Cc: git On Sat, Aug 2, 2008 at 7:18 PM, Matt Pearson <404emailnotfound@gmail.com> wrote: > The working copy in r2 was not updated with the changes you pushed to > it (both the content and the mode change). Hm, your test case is more complicated than I originally thought. I get that result with the git from Ubuntu Hardy, but current master dies on the pull complaining B is not uptodate (has local changes). I guess this was a bug that was fixed, but there's no way I'm going to bisect or look at release notes over half a year (or more) of changes :) What it mainly comes down to is that git has only two possible file modes: 644 and 755. These are the only ones that will ever be stored in the object database. It seems like older git would ignore permission changes to the working copy, and reset the permissions to the "normalized" version when updating a file that was modified by the pull. Here's a blow-by-blow explanation. I'll use numbers to refer to the commits, where 1 is the initial commit, 2 is the commit you pushed, and 3 is the one you pulled. After the cp -r, both repos have a clean working tree; the chmod dirties the working tree of r2. The push causes both repos to have 2 be the HEAD commit, but r2 keeps the dirty working tree changes, including (what now appears to be, from git's POV) a change in the content of A from 'AA' to the 'A' in the initial commit. (The content change will appear as a staged change when running status in r2, because the index isn't updated either) When pulling 3, git thinks that these changes were made on top of 2, and you want to keep them. So it doesn't modify the contents of A because A was not changed in commit 3---if it was, you'd get a "not uptodate" message. B, however, *was* changed in 3, so it tries to apply those changes. With the older version, it seems to ignore the permissions change and simply fast-forward to the state B was in after commit 3 (content 'BB', mode 644). With the newer version, it does see that the mode has been changed, and aborts due to a conflict. In fact, it doesn't seem to like any mode change---it still dies with a conflict if I change the chmod to 'a+x'. Hope that clears it up better---figuring this out helped me learn some stuff about git. Now I'll wait for someone more knowledgeable than I to tell me I'm wrong. :) Matt ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-03 1:17 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-08-02 22:32 git-pull sets write bit, git-push does not Alexander E Genaud 2008-08-02 23:18 ` Matt Pearson 2008-08-03 1:15 ` Matt Pearson
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 NNTP newsgroup(s).