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

Re: FYI: git-am allows creation of empty commits.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 24, 2006, 05:56 UTC
Message-ID
<7v1wxtgv02.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<m1slqahyxt.fsf@ebiederm.dsl.xmission.com>
ebiederm@xmission.com (Eric W. Biederman) writes:
> After fixing it up and doing all of my edits I occasionally forget
> the git-update-index step, before calling git-am --resolved.  This
> proceeds along it's merry way and creates an empty commit.

Certainly a safty measure is missing here. Thanks for noticing. How about something like this?

---
diff --git a/git-am.sh b/git-am.sh
index 85ecada..6730813 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -300,10 +300,16 @@ do
 	    } >"$dotest/final-commit"
 	    ;;
 	*)
-		case "$resolved,$interactive" in
-		tt)
-			# This is used only for interactive view option.
+		case "$resolved" in
+		t)
+			# This is used for interactive view option, but
+			# also we should see if the user really did
+			# something...
 			git-diff-index -p --cached HEAD >"$dotest/patch"
+			test -s "$dotest/patch" || {
+				echo "You said resolved, but there is no change in the index..."
+				stop_here $this
+			}
 			;;
 		esac
 	esac
Previous: Eric W. BiedermanNext: Eric W. Biederman
Message 2 of 8 in “FYI: git-am allows creation of empty commits.”
  1. Eric W. BiedermanFeb 23, 2006
  2. Junio C HamanoFeb 24, 2006
  3. Eric W. BiedermanFeb 24, 2006
  4. Junio C HamanoFeb 24, 2006
  5. commit-tree: disallow an empty single-parent commit.Junio C Hamano, Feb 24, 2006
  6. Eric W. BiedermanFeb 24, 2006
  7. Eric WongFeb 24, 2006
  8. Junio C HamanoFeb 25, 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.