git/list[1] front-page[2] threads[3] people[4] search[5] about
 

about Starter project;implementing log --size in the print_commit function.

From
STShanti Swarup Tunga <b112041@iiit-bh.ac.in>
Date
Mar 23, 2015, 15:15 UTC
Message-ID
<CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA@mail.gmail.com>

I inserted a size variable of int type and calculated size in each cases of print_commit(). The function is

static void print_commit(git_commit *commit)
{
    char buf[GIT_OID_HEXSZ + 1];
    int i, count;
    const git_signature *sig;
    const char *scan, *eol;
    int size=0;
    git_oid_tostr(buf, sizeof(buf), git_commit_id(commit));
    printf("commit %s\n", buf);
    if ((count = (int)git_commit_parentcount(commit)) > 1) {
        printf("Merge:");
        for (i = 0; i < count; ++i) {
            git_oid_tostr(buf, 8, git_commit_parent_id(commit, i));
            size=size+strlen(buf);
            printf(" %s", buf);
        }
        printf("\n");
    }
    if ((sig = git_commit_author(commit)) != NULL) {
        size=size+strlen(sig->name)+strlen(sig->email);
        printf("Author: %s <%s>\n", sig->name, sig->email);
        print_time(&sig->when, "Date:   ");
    }
    printf("\n");
    for (scan = git_commit_message(commit); scan && *scan; ) {
        for (eol = scan; *eol && *eol != '\n'; ++eol) /* find eol */;
        size=size+strlen(scan);
        printf("    %.*s\n", (int)(eol - scan), scan);
        scan = *eol ? eol + 1 : NULL;
    }
    printf("\n");
    printf("%d",size);
}
Will that approach is going to work for the following problem.?
Next: Junio C Hamano
Message 1 of 2 in “about Starter project;implementing log --size in the print_commit function.”
  1. Shanti Swarup TungaMar 23, 2015
  2. Junio C HamanoMar 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.