git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Destructive side-effect of "cg-status"

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 1, 2005, 16:41 UTC
Message-ID
<Pine.LNX.4.64.0510010934290.3378@g5.osdl.org>
In-Reply-To
<20050930160353.F025C352B7B@atlas.denx.de>
On Fri, 30 Sep 2005, Wolfgang Denk wrote:
Show 5 quoted lines
>
> So far I  thought  "cg-status"  is  a  harmless  command  which  just
> displays  some  status information. It ain't so. One of our engineers
> reported a  corrupted  repository  after  I  ran  "cg-status"  in  his
> directory:
Well, it's not corrupted, but yes, the index file ends up unreadable.
> That means, that "cg-status" actually *rewrote* .git/index,  with  me
> (wd)  as  new  owner, and - ignoring my umask - with permissions that
> prevent the original owner (sr) to access the file!
The umask thing looks like a bug. Fixed thus.

Also, arguably we should try to avoid writing the index file when not necessary, although the fact is, that cg-status (and "git status") _do_ need to actually keep it up-to-date in order to do the right thing. Also true of some other programs that might otherwise appear to be read-only (ie I've considered doing the same thing for "git diff").

We used to have that optimization, but it was broken. I fixed it but disabled it for fear of other bugs.

But honoring umask would seem to be a no-brainer.
		Linus
----
diff --git a/index.c b/index.c
--- a/index.c
+++ b/index.c
@@ -29,7 +29,7 @@ int hold_index_file_for_update(struct ca
 		signal(SIGINT, remove_lock_file_on_signal);
 		atexit(remove_lock_file);
 	}
-	return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0600);
+	return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0666);
 }
 
 int commit_index_file(struct cache_file *cf)
Previous: Martin LanghoffNext: Junio C Hamano
Message 3 of 18 in “Destructive side-effect of "cg-status"”
  1. Wolfgang DenkSep 30, 2005
  2. Martin LanghoffOct 1, 2005
  3. Linus TorvaldsOct 1, 2005
  4. Junio C HamanoOct 1, 2005
  5. Honor extractor's umask in git-tar-tree.Junio C Hamano, Oct 1, 2005
  6. H. Peter AnvinOct 2, 2005
  7. Matthias UrlichsOct 2, 2005
  8. H. Peter AnvinOct 3, 2005
  9. Junio C HamanoOct 3, 2005
  10. H. Peter AnvinOct 3, 2005
  11. Junio C HamanoOct 3, 2005
  12. H. Peter AnvinOct 3, 2005
  13. Linus TorvaldsOct 3, 2005
  14. H. Peter AnvinOct 3, 2005
  15. Linus TorvaldsOct 3, 2005
  16. H. Peter AnvinOct 3, 2005
  17. Wolfgang DenkOct 1, 2005
  18. Linus TorvaldsOct 1, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.