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

[RFC] Add --index to git-commit: just commit current index

From
Alex Riesen <raa.lkml@gmail.com>
Date
Mar 15, 2007, 09:43 UTC
Message-ID
<81b0412b0703150243h6a5f036aye8f115d82e11e883@mail.gmail.com>

Refreshing index takes a long time on big repositories with many files, especially if the developer was unlucky enough to stick to a slow filesystem or a broken OS. In this situation explicit git-update-index with git-commit --index will speedup the workflow. Giving either --all, -o, or -i silently turns --index off (these have to refresh index). In case of unmodified index no status message is shown, for all the same reasons: it takes too long. ---

First use of new --quiet :)
 git-commit.sh |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
From 49b846a654d2f1ef540d6438356bffeafa97ba62 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Thu, 15 Mar 2007 10:39:36 +0100
Subject: [PATCH] Add --index to git-commit: just commit current index
Refreshing index takes a long time on big repositories with many files,
especially if the developer is unlucky enough to stick to a slow filesystem
or a broken OS. In this situation explicit git-update-index with
git-commit --index will speedup the workflow.
Giving either --all, --only, or --include silently turns --index off.
---
 git-commit.sh |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 3656d60..56543c9 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
 
-USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
+USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--index] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
@@ -87,6 +87,7 @@ signoff=
 force_author=
 only_include_assumed=
 untracked_files=
+index_only=
 while case "$#" in 0) break;; esac
 do
 	case "$1" in
@@ -262,6 +263,10 @@ $1"
 		untracked_files=t
 		shift
 		;;
+	--index)
+		index_only=t
+		shift
+		;;
 	--)
 		shift
 		break
@@ -275,6 +280,7 @@ $1"
 	esac
 done
 case "$edit_flag" in t) no_edit= ;; esac
+case "$all$also$only" in t*) index_only= ;; esac
 
 ################################################################
 # Sanity check options
@@ -404,15 +410,22 @@ else
 	USE_INDEX="$THIS_INDEX"
 fi
 
-case "$status_only" in
-t)
+case "$status_only,$index_only" in
+t,*)
 	# This will silently fail in a read-only repository, which is
 	# what we want.
 	GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --unmerged --refresh
 	run_status
 	exit $?
 	;;
-'')
+,t)
+	GIT_INDEX_FILE="$USE_INDEX" \
+	git-diff-index --cached --quiet --exit-code HEAD && {
+		echo >&2 "No changes in the index"
+		exit 1
+	}
+	;;
+,)
 	GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --refresh || exit
 	;;
 esac
-- 
1.5.0.4.439.gce5f
Next: Junio C Hamano
Message 1 of 3 in “[RFC] Add --index to git-commit: just commit current index”
  1. Alex RiesenMar 15, 2007
  2. Junio C HamanoMar 16, 2007
  3. Alex RiesenMar 16, 2007

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.