Re: Fwd: git status options feature suggestion

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff King
Date: Sunday, October 12, 2008 - 1:26 am

On Sun, Oct 12, 2008 at 12:49:00AM -0400, Jeff King wrote:


BTW, in case anybody is interested, here is the patch. Like I said, I
think we are better off with an alternative to "status", but maybe this
is useful to somebody anyway.

---
diff --git a/builtin-commit.c b/builtin-commit.c
index b01ad9f..8951364 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -217,7 +217,8 @@ static void create_base_index(void)
 		exit(128); /* We've already reported the error, finish dying */
 }
 
-static char *prepare_index(int argc, const char **argv, const char *prefix)
+static char *prepare_index(int argc, const char **argv, const char *prefix,
+		int status_only)
 {
 	int fd;
 	struct string_list partial;
@@ -270,7 +271,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
 	 * We still need to refresh the index here.
 	 */
 	if (!pathspec || !*pathspec) {
-		fd = hold_locked_index(&index_lock, 1);
+		fd = hold_locked_index(&index_lock, 0);
+		if (fd < 0) {
+			if (!status_only)
+				die("unable to lock index: %s",
+						strerror(errno));
+			return get_index_file();
+		}
 		refresh_cache(REFRESH_QUIET);
 		if (write_cache(fd, active_cache, active_nr) ||
 		    commit_locked_index(&index_lock))
@@ -869,7 +876,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
 	argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
 
-	index_file = prepare_index(argc, argv, prefix);
+	index_file = prepare_index(argc, argv, prefix, 1);
 
 	commitable = run_status(stdout, index_file, prefix, 0);
 
@@ -953,7 +960,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
 
-	index_file = prepare_index(argc, argv, prefix);
+	index_file = prepare_index(argc, argv, prefix, 0);
 
 	/* Set up everything for writing the commit object.  This includes
 	   running hooks, writing the trees, and interacting with the user.  */
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Fwd: git status options feature suggestion, Caleb Cushing, (Wed Oct 8, 11:27 pm)
Re: Fwd: git status options feature suggestion, Johannes Schindelin, (Thu Oct 9, 2:03 am)
Re: Fwd: git status options feature suggestion, Michael J Gruber, (Thu Oct 9, 8:12 am)
Re: ls-files, James Cloos, (Thu Oct 9, 3:52 pm)
Re: Fwd: git status options feature suggestion, Caleb Cushing, (Thu Oct 9, 7:20 pm)
Re: Fwd: git status options feature suggestion, Elijah Newren, (Thu Oct 9, 9:25 pm)
Re: Fwd: git status options feature suggestion, Johannes Schindelin, (Fri Oct 10, 4:13 am)
Re: Fwd: git status options feature suggestion, Jeff King, (Sat Oct 11, 9:49 pm)
Re: Fwd: git status options feature suggestion, Junio C Hamano, (Sat Oct 11, 11:41 pm)
Re: Fwd: git status options feature suggestion, Jeff King, (Sat Oct 11, 11:45 pm)
Re: Fwd: git status options feature suggestion, Junio C Hamano, (Sun Oct 12, 1:10 am)
Re: Fwd: git status options feature suggestion, Jeff King, (Sun Oct 12, 1:26 am)
Re: Fwd: git status options feature suggestion, Junio C Hamano, (Sun Oct 12, 2:58 am)
Re: git status options feature suggestion, Wincent Colaiuta, (Sun Oct 12, 3:47 am)
Re: git status options feature suggestion, Teemu Likonen, (Sun Oct 12, 4:40 am)
Re: git status options feature suggestion, Andreas Ericsson, (Sun Oct 12, 6:52 am)
Re: Fwd: git status options feature suggestion, Shawn O. Pearce, (Sun Oct 12, 11:05 am)
Re: Fwd: git status options feature suggestion, Jeff King, (Sun Oct 12, 5:59 pm)
Re: Fwd: git status options feature suggestion, Jeff King, (Sun Oct 12, 6:04 pm)
Re: Fwd: git status options feature suggestion, Jeff King, (Sun Oct 12, 6:06 pm)
Re: Fwd: git status options feature suggestion, Shawn O. Pearce, (Sun Oct 12, 6:30 pm)
Re: Fwd: git status options feature suggestion, Junio C Hamano, (Sat Oct 25, 6:47 pm)
Re: Fwd: git status options feature suggestion, Jeff King, (Sat Oct 25, 9:59 pm)