git-query

git data extraction tool using c and libgit2

git clone https://9o.is/git/git-query.git

commit 5cb62b7da20076985ebd47e1a699c0f3584e46ae
parent 051b9f1965f8d669b01a1f38a33f73e3a93ae651
Author: Jul <jul@9o.is>
Date:   Mon,  2 Mar 2026 15:54:08 +0800

save git-query man file

Diffstat:
MMakefile | 3++-
Agit-query.1 | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -33,7 +33,8 @@ BIN = \ git-query MAN1 = \ stagit.1\ - stagit-index.1 + stagit-index.1\ + git-query.1 DOC = \ LICENSE\ README diff --git a/git-query.1 b/git-query.1 @@ -0,0 +1,120 @@ +.Dd March 2, 2026 +.Dt GIT-QUERY 1 +.Os +.Sh NAME +.Nm git-query +.Nd git data extraction tool +.Sh SYNOPSIS +.Nm +.Ar command +.Ar repo +.Op Ar args... +.Sh DESCRIPTION +.Nm +is a tool to extract git repository data in XML format. +It outputs data to stdout, suitable for piping to other tools or templating. +The repository can be a bare repository or a regular .git directory. +.Pp +The commands are: +.Bl -tag -width Ds +.It Xo +.Cm info +.Ar repo +.Xc +Output repository metadata in XML format: +.Bl -tag -width Ds +.It name +Repository name (basename of the directory). +.It description +Repository description. +.It owner +Repository owner. +.It cloneurl +Clone URL. +.El +.It Xo +.Cm log +.Ar repo +.Op Ar N +.Xc +Output commit log in XML format. +.Ar N +is the number of commits to output, default is 100. +Each commit element contains: +.Bl -tag -width Ds +.It oid +Commit hash. +.It parent +Parent commit hash. +.It author +Author name, email, and timestamp. +.It summary +Commit summary (first line of message). +.It message +Full commit message. +.It stats +Number of files changed, additions, and deletions. +.El +.It Xo +.Cm commit +.Ar repo +.Op Ar oid +.Xc +Output commit detail in XML format. +.Ar oid +defaults to HEAD if not specified. +The output includes the full diff with hunks and lines. +.It Xo +.Cm tree +.Ar repo +.Op Ar oid +.Xc +Output tree (file listing) in XML format. +.Ar oid +defaults to HEAD if not specified. +Each entry contains path, mode, type (blob/tree/commit), oid and size (for blobs). +.It Xo +.Cm blob +.Ar repo +.Ar path +.Op Ar oid +.Xc +Output blob (file content) in XML format. +.Ar path +is the path to the file relative to the repository root. +.Ar oid +can be specified to get the file at a specific commit. +.It Xo +.Cm refs +.Ar repo +.Xc +Output references (branches and tags) in XML format. +Each reference contains its name and the commit it points to. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +.Bd -literal +# Get repository info +git-query info /path/to/repo + +# Get last 10 commits +git-query log /path/to/repo 10 + +# Get specific commit +git-query commit /path/to/repo abc123def + +# Get file tree at HEAD +git-query tree /path/to/repo + +# Get file content +git-query blob /path/to/repo README.md + +# Get list of branches and tags +git-query refs /path/to/repo +.Ed +.Sh SEE ALSO +.Xr stagit 1 , +.Xr stagit-index 1 +.Sh AUTHORS +.An Hiltjo Posthuma Aq Mt hiltjo@codemadness.org