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

[PATCH 1/2] git-commit: prepare to make '-a' behaviour the default.

From
Junio C Hamano <junkio@cox.net>
Date
Nov 28, 2006, 07:00 UTC
Message-ID
<7v64d06op0.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vk61gcnzl.fsf@assigned-by-dhcp.cox.net>

This makes "git commit" accept "-i" without any parameter (we used to barf on such a command line) to mean "commit what is in the index as-is". There is nothing surprising about this new behaviour. "git commit -i paths..." means "in addition to the changes I accumulated in the index, also run update-index on these paths and then make a commit" and this new behaviour is a natural extension to that to the case where "paths..." is empty.

"git commit" without -i, -a, nor -o still behave the same way as it has done for a long time, but it now warns that this will be changed to default to the "-a" behaviour.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-commit.sh |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 81c3a0c..6c95817 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -11,10 +11,10 @@ git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t
 branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
 
 case "$0" in
-*status)
+*status|*status.sh)
 	status_only=t
 	unmerged_ok_if_status=--unmerged ;;
-*commit)
+*commit|*commit.sh)
 	status_only=
 	unmerged_ok_if_status= ;;
 esac
@@ -287,11 +287,15 @@ esac
 case "$#,$also,$only,$amend" in
 *,t,t,*)
 	die "Only one of --include/--only can be used." ;;
-0,t,,* | 0,,t,)
-	die "No paths with --include/--only does not make sense." ;;
+0,t,,*)
+	;;
+0,,t,)
+	die "No paths with --only does not make sense." ;;
 0,,t,t)
 	only_include_assumed="# Clever... amending the last one with dirty index." ;;
 0,,,*)
+	: all=t
+	only_include_assumed="# We will start assuming -a without -i; you have been warned."
 	;;
 *,,,*)
 	only_include_assumed="# Explicit paths specified without -i nor -o; assuming --only paths..."
@@ -304,8 +308,6 @@ t,t,*)
 	die "Cannot use -a and -i at the same time." ;;
 t,,[1-9]*)
 	die "Paths with -a does not make sense." ;;
-,t,0)
-	die "No paths with -i does not make sense." ;;
 esac
 
 ################################################################
@@ -317,8 +319,8 @@ then
 	TOP=./
 fi
 
-case "$all,$also" in
-t,)
+case "$all,$also,$#" in
+t,,*)
 	save_index &&
 	(
 		cd "$TOP"
@@ -328,7 +330,7 @@ t,)
 		git-update-index --remove -z --stdin
 	)
 	;;
-,t)
+,t,[1-9]*)
 	save_index &&
 	git-ls-files --error-unmatch -- "$@" >/dev/null || exit
 
@@ -340,7 +342,7 @@ t,)
 		git-update-index --remove -z --stdin
 	)
 	;;
-,)
+,,* | ,t,0)
 	case "$#" in
 	0)
 		;; # commit as-is
@@ -407,7 +409,7 @@ GIT_INDEX_FILE="$USE_INDEX" \
 # If the request is status, just show it and exit.
 
 case "$0" in
-*status)
+*status|*status.sh)
 	run_status
 	exit $?
 esac
@@ -539,7 +541,11 @@ then
 		echo ""
 		echo "# Please enter the commit message for your changes."
 		echo "# (Comment lines starting with '#' will not be included)"
-		test -z "$only_include_assumed" || echo "$only_include_assumed"
+		test -z "$only_include_assumed" || {
+			echo "#"
+			echo "$only_include_assumed"
+			echo "#"
+		}
 		run_status
 	} >>"$GIT_DIR"/COMMIT_EDITMSG
 else
-- 
1.4.4.1.gcee8-dirty
Previous: Andy WhitcroftNext: Junio C Hamano
Message 21 of 25 in “"init-db" can really be just "init"”
  1. "init-db" can really be just "init"Nicolas Pitre, Nov 27, 2006
  2. Junio C HamanoNov 27, 2006
  3. Hyphens and hiding core commands (was: "init-db" can really be just "init")Carl Worth, Nov 27, 2006
  4. Junio C HamanoNov 27, 2006
  5. Carl WorthNov 28, 2006
  6. Junio C HamanoNov 28, 2006
  7. Carl WorthNov 28, 2006
  8. Junio C HamanoNov 28, 2006
  9. 0/2 Making "git commit" to mean "git commit -a".Junio C Hamano, Nov 28, 2006
  10. Andy WhitcroftNov 28, 2006
  11. Josef WeidendorferNov 28, 2006
  12. Jakub NarebskiNov 28, 2006
  13. Carl WorthNov 28, 2006
  14. Salikh ZakirovNov 30, 2006
  15. Jakub NarebskiNov 30, 2006
  16. Seth FalconNov 30, 2006
  17. Nguyen Thai Ngoc DuyNov 30, 2006
  18. Seth FalconNov 30, 2006
  19. Jakub NarebskiNov 30, 2006
  20. Andy WhitcroftNov 30, 2006
  21. 1/2 git-commit: prepare to make '-a' behaviour the default.Junio C Hamano, Nov 28, 2006
  22. 2/2 git-commit: make '-a' the default.Junio C Hamano, Nov 28, 2006
  23. Jakub NarebskiNov 28, 2006
  24. Johannes SchindelinNov 27, 2006
  25. Han-Wen NienhuysNov 28, 2006

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.