ref: 270be365a4b9c55e071564903256999e2ce66b28
parent: c078b56e125d24e66405ee38d6a25a165175df14
	author: Jacob Moody <moody@posixcafe.org>
	date: Tue Aug  5 06:59:31 EDT 2025
	
git: cleanup git/hist * -n flag for limiting commit output * fix usage when not in gitroot * diff delimiters * document in man page
--- a/sys/man/1/git
+++ b/sys/man/1/git
@@ -2,7 +2,7 @@
.SH NAME
git, git/conf, git/query, git/walk, git/clone, git/branch,
git/commit, git/diff, git/init, git/log, git/merge, git/push,
-git/pull, git/rm, git/serve \- manage git repositories
+git/pull, git/rm, git/serve, git/hist \- manage git repositories
.SH SYNOPSIS
.B git/add
[
@@ -186,6 +186,13 @@
[
.I file ...
]
+.PP
+.B git/hist
+[
+.B -n
+.I count
+]
+.I files...
.SH DESCRIPTION
Git is a distributed version control system.
This means that each repository contains a full copy of the history.
@@ -561,6 +568,16 @@
commands to run tools like
.I go get
but not much more.
+.PP
+.I Git/hist
+provides the diffs of specific
+.I files
+in reverse chronological order.
+The
+.B -n
+flag may be used to limit the output to the last
+.I count
+commits.
.SH REF SYNTAX
Refs are specified with a simple query syntax.
A bare hash always evaluates to itself.
--- a/sys/src/cmd/git/hist
+++ b/sys/src/cmd/git/hist
@@ -4,6 +4,10 @@
. /sys/lib/git/common.rc
gitup
+flagfmt='n:num count'; args='files...'
+eval `''{aux/getflags $*} || exec aux/usage+if(~ $#* 0) exec aux/usage
+
 fn dodiff { 	while(t=`{read}){h=$t(1)
@@ -23,12 +27,14 @@
prev=/dev/null
diff -u $prev $curr
}
+ echo --' '
+ echo ⑨
echo
}
}
-if(~ $#* 0)
- die usage: $0 files...
-
-files=`{cleanname $gitrel/$*}-git/log -s $files | dodiff
+files=`{cleanname $*}+args=(-s $files)
+if(! ~ $#num 0)
+ args=(-n $num $args)
+git/log $args | dodiff
--
⑨