git-query

git data extraction tool using c and libgit2

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

commit ee011afc26de2ca680fbb6673d50d8e47c6c9918
parent 5cb62b7da20076985ebd47e1a699c0f3584e46ae
Author: Jul <jul@9o.is>
Date:   Mon,  2 Mar 2026 16:20:47 +0800

remove git-query info

Diffstat:
Mgit-query.1 | 18------------------
Mgit-query.c | 74+-------------------------------------------------------------------------
2 files changed, 1 insertion(+), 91 deletions(-)

diff --git a/git-query.1 b/git-query.1 @@ -18,21 +18,6 @@ The repository can be a bare repository or a regular .git directory. 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 @@ -95,9 +80,6 @@ Each reference contains its name and the commit it points to. .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 diff --git a/git-query.c b/git-query.c @@ -281,75 +281,6 @@ err: } void -print_info(FILE *fp) -{ - char path[PATH_MAX], repodirabs[PATH_MAX + 1], *p; - char description[255] = ""; - char owner[255] = ""; - char cloneurl[1024] = ""; - FILE *fpread; - - if (!realpath(repodir, repodirabs)) - err(1, "realpath"); - - if ((p = strrchr(repodirabs, '/'))) - p++; - else - p = ""; - - fputs("<repository>\n", fp); - fputs("<name>", fp); - xmlencode(fp, p, strlen(p)); - fputs("</name>\n", fp); - - joinpath(path, sizeof(path), repodir, "description"); - if (!(fpread = fopen(path, "r"))) { - joinpath(path, sizeof(path), repodir, ".git/description"); - fpread = fopen(path, "r"); - } - if (fpread) { - if (!fgets(description, sizeof(description), fpread)) - description[0] = '\0'; - fclose(fpread); - } - fputs("<description>", fp); - xmlencode(fp, description, strlen(description)); - fputs("</description>\n", fp); - - joinpath(path, sizeof(path), repodir, "owner"); - if (!(fpread = fopen(path, "r"))) { - joinpath(path, sizeof(path), repodir, ".git/owner"); - fpread = fopen(path, "r"); - } - if (fpread) { - if (!fgets(owner, sizeof(owner), fpread)) - owner[0] = '\0'; - fclose(fpread); - owner[strcspn(owner, "\n")] = '\0'; - } - fputs("<owner>", fp); - xmlencode(fp, owner, strlen(owner)); - fputs("</owner>\n", fp); - - joinpath(path, sizeof(path), repodir, "url"); - if (!(fpread = fopen(path, "r"))) { - joinpath(path, sizeof(path), repodir, ".git/url"); - fpread = fopen(path, "r"); - } - if (fpread) { - if (!fgets(cloneurl, sizeof(cloneurl), fpread)) - cloneurl[0] = '\0'; - fclose(fpread); - cloneurl[strcspn(cloneurl, "\n")] = '\0'; - } - fputs("<cloneurl>", fp); - xmlencode(fp, cloneurl, strlen(cloneurl)); - fputs("</cloneurl>\n", fp); - - fputs("</repository>\n", fp); -} - -void print_log(FILE *fp, size_t nlogcommits) { git_object *obj = NULL; @@ -704,7 +635,6 @@ usage(void) fprintf(stderr, "usage: git-query <command> <repo> [args...]\n"); fprintf(stderr, "\n"); fprintf(stderr, "Commands:\n"); - fprintf(stderr, " info <repo> # repository metadata\n"); fprintf(stderr, " log <repo> [N] # commit log (default 100)\n"); fprintf(stderr, " commit <repo> [oid] # commit detail (default HEAD)\n"); fprintf(stderr, " tree <repo> [oid] # tree entries (default HEAD)\n"); @@ -737,9 +667,7 @@ main(int argc, char *argv[]) return 1; } - if (strcmp(cmd, "info") == 0) { - print_info(fp); - } else if (strcmp(cmd, "log") == 0) { + if (strcmp(cmd, "log") == 0) { size_t n = 100; if (argc > 3) { n = strtoul(argv[3], NULL, 10);