shithub: riscv

Download patch

ref: 4521ae32bb95562b4210c23bee02a9fe1b1e3137
parent: ec98c2e178ee0e247e0e425e5e74393c62d4ce36
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Aug 10 07:14:55 EDT 2022

git/hist: add command to show history of files

--- /dev/null
+++ b/sys/src/cmd/git/hist
@@ -1,0 +1,34 @@
+#!/bin/rc
+rfork ne
+
+. /sys/lib/git/common.rc
+gitup
+
+fn dodiff {
+	while(t=`{read}){
+		h=$t(1)
+		o=.git/fs/object/`{git/query $h~}
+		c=.git/fs/object/$h
+		echo 'Hash:' $h
+		echo -n 'Date: '; date `{walk -em $c/msg}
+		echo -n 'Author: '; cat $c/author
+		echo -n 'Message: '; cat $c/msg
+		echo
+		for(f in $files){
+			curr=$c/tree/$f
+			prev=$o/tree/$f
+			if(! test -e $curr)
+				curr=/dev/null
+			if(! test -e $prev)
+				prev=/dev/null
+			diff -u $prev $curr
+		}
+		echo
+	}
+}
+
+if(~ $#* 0)
+	die usage: $0 files...
+
+files=`{cleanname $gitrel/$*}
+git/log -s $files | dodiff
--- a/sys/src/cmd/git/mkfile
+++ b/sys/src/cmd/git/mkfile
@@ -21,6 +21,7 @@
 	compat\
 	diff\
 	export\
+	hist\
 	import\
 	init\
 	merge\