shithub: git9

Download patch

ref: 8f449d48dd668d9b23b4fffaa275d57775e9afd5
parent: 56e974515ed5be32ae80c4d2b0c7092c027a4196
author: Michael Forney <mforney@mforney.org>
date: Sun Jan 31 21:44:54 EST 2021

git/commit: don't require tree changes when revising a commit

When using -e or -m, we may just be revising the commit message.

--- a/commit
+++ b/commit
@@ -121,10 +121,8 @@
 
 gitup
 
-flagfmt='m:msg message, r:revise, e:edit'; args='file ...'
+flagfmt='m:msg message, r:revise, e:edit'; args='[file ...]'
 eval `''{aux/getflags $*} || exec aux/usage
-if(~ $#* 0)
-	exec aux/usage
 
 msgfile=/tmp/git-msg.$pid
 if(~ $#msg 1)
@@ -135,8 +133,10 @@
 	cat /mnt/git/HEAD/msg >$msgfile.tmp
 }
 
-files=`$nl{git/walk -c `$nl{cleanname $gitrel/$*}}
-if(~ $status '' || ~ $#files 0 && ! test -f .git/index9/merge-parents)
+files=()
+if(! ~ $#* 0)
+	files=`$nl{git/walk -c `$nl{cleanname $gitrel/$*}}
+if(~ $status '' || ~ $#files 0 && ! test -f .git/index9/merge-parents && ~ $#revise 0)
 	die 'nothing to commit' $status
 @{
 	flag e +
--- a/git.1.man
+++ b/git.1.man
@@ -41,7 +41,9 @@
 [
 .B -m msg
 ]
+[
 .I file...
+]
 .PP
 .B git/compat
 .PP
--- a/save.c
+++ b/save.c
@@ -337,7 +337,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s -n name -e email -m message -d date files...\n", argv0);
+	fprint(2, "usage: %s -n name -e email -m message -d date [files...]\n", argv0);
 	exits("usage");
 }
 
@@ -383,7 +383,7 @@
 		if(strlen(dstr) != 0)
 			sysfatal("could not parse date %s", dstr);
 	}
-	if(argc == 0 || msg == nil || name == nil)
+	if(msg == nil || name == nil)
 		usage();
 	for(i = 0; i < argc; i++)
 		cleanname(argv[i]);