summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMiha <miha.ravselj@ib-caddy.si>2014-03-03 11:40:22 +0100
committerMiha <miha.ravselj@ib-caddy.si>2014-03-03 11:40:22 +0100
commitb5212858f17f053e8854b376a2d3f134a3fbd71b (patch)
tree455facae0be7f01d9d1024c1f066d4e50da94926 /examples
parent3536c168c354906e2109f49a474f51117fc9b7db (diff)
parent494be429ad2d247a8d1fb2b43b8c715a4b9da663 (diff)
downloadlibgit2-b5212858f17f053e8854b376a2d3f134a3fbd71b.tar.gz
Merge remote-tracking branch 'remotes/upstream/development' into development
Diffstat (limited to 'examples')
-rw-r--r--examples/blame.c5
-rw-r--r--examples/diff.c18
2 files changed, 16 insertions, 7 deletions
diff --git a/examples/blame.c b/examples/blame.c
index d7b843cc2..fda605bce 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -31,6 +31,7 @@ struct opts {
int M;
int start_line;
int end_line;
+ int F;
};
static void parse_opts(struct opts *o, int argc, char *argv[]);
@@ -52,6 +53,7 @@ int main(int argc, char *argv[])
parse_opts(&o, argc, argv);
if (o.M) blameopts.flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES;
if (o.C) blameopts.flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES;
+ if (o.F) blameopts.flags |= GIT_BLAME_FIRST_PARENT;
/** Open the repository. */
check_lg2(git_repository_open_ext(&repo, ".", 0, NULL), "Couldn't open repository", NULL);
@@ -147,6 +149,7 @@ static void usage(const char *msg, const char *arg)
fprintf(stderr, " -L <n,m> process only line range n-m, counting from 1\n");
fprintf(stderr, " -M find line moves within and across files\n");
fprintf(stderr, " -C find line copies within and across files\n");
+ fprintf(stderr, " -F follow only the first parent commits\n");
fprintf(stderr, "\n");
exit(1);
}
@@ -175,6 +178,8 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
o->M = 1;
else if (!strcasecmp(a, "-C"))
o->C = 1;
+ else if (!strcasecmp(a, "-F"))
+ o->F = 1;
else if (!strcasecmp(a, "-L")) {
i++; a = argv[i];
if (i >= argc) fatal("Not enough arguments to -L", NULL);
diff --git a/examples/diff.c b/examples/diff.c
index abb9b7103..de994ecab 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -269,19 +269,23 @@ static void diff_print_numstat(git_diff *diff)
{
git_patch *patch;
const git_diff_delta *delta;
- size_t i;
- size_t ndeltas;
+ size_t d, ndeltas = git_diff_num_deltas(diff);
size_t nadditions, ndeletions;
- ndeltas = git_diff_num_deltas(diff);
- for (i = 0; i < ndeltas; i++){
+
+ for (d = 0; d < ndeltas; d++){
check_lg2(
- git_patch_from_diff(&patch, diff, i),
+ git_patch_from_diff(&patch, diff, d),
"generating patch from diff", NULL);
+
check_lg2(
git_patch_line_stats(NULL, &nadditions, &ndeletions, patch),
"generating the number of additions and deletions", NULL);
+
delta = git_patch_get_delta(patch);
- printf("%u\t%u\t%s\n", nadditions, ndeletions, delta->new_file.path);
+
+ printf("%ld\t%ld\t%s\n",
+ (long)nadditions, (long)ndeletions, delta->new_file.path);
+
+ git_patch_free(patch);
}
- git_patch_free(patch);
}