shithub: libgit


branches: front

Clone

clone: git://shithub.us/sirjofri/libgit gits://shithub.us/sirjofri/libgit
push: hjgit://shithub.us/sirjofri/libgit

Last commit

48558629 – sirjofri <sirjofri@sirjofri.de> authored on 2024/06/16 10:10
adds ...l versions to man page

About


     GIT(2)                                                     GIT(2)

     NAME
          Initgit, gitcommit, gitadd, gitrm, gitlog, Gitlog - git C
          library

     SYNOPSIS
          #include <u.h>
          #include <libc.h>
          #include <git.h>

          typedef struct Gitlog
          {
               char *hash;
               char *author;
               char *date;
               char *message;
          } Gitlog;

          int initgit(char *dir)
          int freegitlogs(Gitlog *logs)

          int gitcommit(char *msg, char *file, ...)
          int gitcommitl(char *msg, char **files)
          int gitadd(char *file, ...)
          int gitaddl(char **files)
          int gitrm(char *file, ...)
          int gitrml(char **files)
          int gitlog(Gitlog **logs, int n, char *commit, ...)
          int gitlogl(Gitlog **logs, int n, char *commit, char **files)

     DESCRIPTION
          Libgit is a wrapper around git9. It does not provide its own
          git functionality.

          Git functions that receive a list of files expect the last
          element to be nil.  All the file names are expected to be
          relative to the repository root directory.

          Most calls have an l-version which receives an array of
          files instead of a va_list.  The last element in those
          arrays must be nil.

          Initgit initializes libgit with an existing repository at
          location dir.  This will use git(1) to start the backend
          filesystem.

          Gitadd and gitrm add and remove files from the git file
          tracking system by adjusting the INDEX9 file directly.

          Gitcommit will use git(1) to commit the numbered list of
          files.  Arguments are forwarded unchanged, so it should be
          possible to use wildcards like . or *.  Msg will be used as
          the commit message; it can be multiple lines.

          Gitlog allocates the pointer pointed to by logs with as many
          Gitlog structs as needed, plus an additional sentinel Gitlog
          structure.  It will fill this array with the last n commits
          starting from commit or HEAD if commit is nil.  The remain-
          ing arguments can be a list of files used for filtering,
          ending with nil.

          The last Gitlog structure in the initialized array acts as a
          sentinel and has its hash member set to nil.  The array and
          all its strings are allocated with malloc and should be
          freed after using.

          Freegitlogs can be used for that, which is recommended for
          future updates.

     EXAMPLE
               Gitlogs *logs;
               if (!initgit("/path/to/repo"))
                   sysfatal("%r");
               gitadd("addfileA", "addfileB", nil);
               gitrm("rmfileA", "rmfileB", nil);
               gitcommit("adds and removes files\n\nfor demonstration only",
                   "addfileA", "addfileB", "rmfileA", "rmfileB", nil);
               gitlog(&logs, 2, nil, nil);
               for (Gitlog *l = logs; l->hash; l++) {
                   print("hash:   %s\n", l->hash);
                   print("author: %s\n", l->author);
                   print("date:   %s\n", l->date);
                   print("msg:    %s\n", l->message);
               }
               freegitlogs(logs);

     SOURCE
          /sys/src/libgit/git.c

     SEE ALSO
          git(1)

     DIAGNOSTICS
          All commands return 0 on failure and set errstr.

     BUGS
          Sure.

          Libgit is incomplete.