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

2 messages from 2015-03-23 to 2015-03-25. Participants: Shanti Swarup Tunga, Junio C Hamano.
Thread: https://gitlist.dev/t/38891

## Shanti Swarup Tunga, 2015-03-23 15:15

Subject: about Starter project;implementing log --size in the print_commit function.
Message-ID: <CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA@mail.gmail.com>
URL: https://gitlist.dev/e/CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA%40mail.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.?

```

## Junio C Hamano, 2015-03-25 16:13

Subject: Re: about Starter project;implementing log --size in the print_commit function.
Message-ID: <xmqq1tkd3vij.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq1tkd3vij.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA@mail.gmail.com>

```
Shanti Swarup Tunga <b112041@iiit-bh.ac.in> writes:

> 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)
> {
> ...
> }

See Documentation/SubmittingPatches and then also CodingGuidelines

Especially, explain:

 - what does this change try to help and how?
 - why is this patch a good way to achieve that goal?
 - how the users are expected to use the new feature?

in the proposed log message, run existing tests to make sure your
change did not break the existing system, add tests to make sure
you would notice if somebody else broke the feature you are adding
in the future, and describe the new feature in the documentation.

> Will that approach is going to work for the following problem.?

Was your message cut short?  We cannot read "the following" problem
here...

```
