shithub: furgit

Download patch

ref: 2f8f740ea1835bb8001be655d3d5e71b51f123c1
parent: f9d1ae20c727c9cd56d4304de16d128c6b0bd15a
author: Runxi Yu <me@runxiyu.org>
date: Sat Nov 29 11:31:26 EST 2025

show-object: Utility to show an arbitrary object from a repo

--- /dev/null
+++ b/cmd/show-object/main.go
@@ -1,0 +1,37 @@
+package main
+
+import (
+	"flag"
+	"fmt"
+	"log"
+
+	"git.sr.ht/~runxiyu/furgit"
+)
+
+func main() {
+	repoPath := flag.String("r", "", "path to repo (.git or bare)")
+	ref := flag.String("h", "", "ref or hash")
+	flag.Parse()
+
+	if *repoPath == "" || *ref == "" {
+		log.Fatal("must provide -r repo and -h ref/hash")
+	}
+
+	repo, err := furgit.OpenRepository(*repoPath)
+	if err != nil {
+		log.Fatalf("open repo: %v", err)
+	}
+	defer repo.Close()
+
+	h, err := repo.ResolveRefFully(*ref)
+	if err != nil {
+		log.Fatalf("resolve ref: %v", err)
+	}
+
+	obj, err := repo.ReadObject(h)
+	if err != nil {
+		log.Fatalf("read object: %v", err)
+	}
+
+	fmt.Printf("%#v\n", obj)
+}
--