From: Shanti Swarup Tunga <b112041@iiit-bh.ac.in>
To: git <git@vger.kernel.org>
Subject: about Starter project;implementing log --size in the print_commit function.
Date: Mon, 23 Mar 2015 20:45:11 +0530 [thread overview]
Message-ID: <CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA@mail.gmail.com> (raw)
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 reply other threads:[~2015-03-23 15:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 15:15 Shanti Swarup Tunga [this message]
2015-03-25 16:13 ` about Starter project;implementing log --size in the print_commit function Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABJeaiqhL5eNPkaPpheG_Y47Rapj4ys3igHhFH6YuiroECVGDA@mail.gmail.com \
--to=b112041@iiit-bh.ac.in \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).