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

[PATCH] git status: do not require write permission

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 20, 2010, 00:06 UTC
Message-ID
<alpine.DEB.1.00.1001200105230.3164@intel-tinevez-2-302>

Today, git status played violin on my nerves for the very last time. There is no good reason, really none, for git status to require write permissions. If the index is not up-to-date, so be it, I cannot commit anyway.

But in most cases, the index _is_ up-to-date, and now I can tell my fellow former users that their repository XYZ.git does not have any uncommitted changes, so can they please delete it to free up some disk space, thank you very much.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin-commit.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 55676fd..9eccc51 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -325,11 +325,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 	 * We still need to refresh the index here.
 	 */
 	if (!pathspec || !*pathspec) {
-		fd = hold_locked_index(&index_lock, 1);
-		refresh_cache_or_die(refresh_flags);
-		if (write_cache(fd, active_cache, active_nr) ||
-		    commit_locked_index(&index_lock))
-			die("unable to write new_index file");
+		fd = hold_locked_index(&index_lock, 0);
+		if (fd >= 0) {
+			refresh_cache_or_die(refresh_flags);
+			if (write_cache(fd, active_cache, active_nr) ||
+			    commit_locked_index(&index_lock))
+				die("unable to write new_index file");
+		}
 		commit_style = COMMIT_AS_IS;
 		return get_index_file();
 	}
-- 
1.6.4.297.gcb4cc
Next: Jeff King
Message 1 of 8 in “git status: do not require write permission”
  1. git status: do not require write permissionJohannes Schindelin, Jan 20, 2010
  2. Jeff KingJan 20, 2010
  3. Johannes SchindelinJan 20, 2010
  4. Johannes SchindelinJan 20, 2010
  5. Junio C HamanoJan 20, 2010
  6. Junio C HamanoJan 20, 2010
  7. Johannes SchindelinJan 20, 2010
  8. Junio C HamanoJan 20, 2010

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.