Commit 5b58d6f7 by Vicent Marti

Merge pull request #2289 from libgit2/rb/note-git-diff-index-behavior

Some doc and examples/diff.c changes
parents a32d684f e60883c8
......@@ -33,14 +33,27 @@ static const char *colors[] = {
"\033[36m" /* cyan */
};
enum {
OUTPUT_DIFF = (1 << 0),
OUTPUT_STAT = (1 << 1),
OUTPUT_SHORTSTAT = (1 << 2),
OUTPUT_NUMSTAT = (1 << 3),
OUTPUT_SUMMARY = (1 << 4)
};
enum {
CACHE_NORMAL = 0,
CACHE_ONLY = 1,
CACHE_NONE = 2
};
/** The 'opts' struct captures all the various parsed command line options. */
struct opts {
git_diff_options diffopts;
git_diff_find_options findopts;
int color;
int cached;
int numstat;
int shortstat;
int cache;
int output;
git_diff_format_t format;
const char *treeish1;
const char *treeish2;
......@@ -48,11 +61,11 @@ struct opts {
};
/** These functions are implemented at the end */
static void usage(const char *message, const char *arg);
static void parse_opts(struct opts *o, int argc, char *argv[]);
static int color_printer(
const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*);
static void diff_print_numstat(git_diff *diff);
static void diff_print_shortstat(git_diff *diff);
static void diff_print_stats(git_diff *diff, struct opts *o);
int main(int argc, char *argv[])
{
......@@ -61,7 +74,7 @@ int main(int argc, char *argv[])
git_diff *diff;
struct opts o = {
GIT_DIFF_OPTIONS_INIT, GIT_DIFF_FIND_OPTIONS_INIT,
-1, 0, 0, 0, GIT_DIFF_FORMAT_PATCH, NULL, NULL, "."
-1, 0, 0, GIT_DIFF_FORMAT_PATCH, NULL, NULL, "."
};
git_threads_init();
......@@ -78,6 +91,7 @@ int main(int argc, char *argv[])
* * &lt;sha1&gt; --cached
* * &lt;sha1&gt;
* * --cached
* * --nocache (don't use index data in diff at all)
* * nothing
*
* Currently ranged arguments like &lt;sha1&gt;..&lt;sha2&gt; and &lt;sha1&gt;...&lt;sha2&gt;
......@@ -93,20 +107,23 @@ int main(int argc, char *argv[])
check_lg2(
git_diff_tree_to_tree(&diff, repo, t1, t2, &o.diffopts),
"diff trees", NULL);
else if (t1 && o.cached)
else if (o.cache != CACHE_NORMAL) {
if (!t1)
treeish_to_tree(&t1, repo, "HEAD");
if (o.cache == CACHE_NONE)
check_lg2(
git_diff_tree_to_workdir(&diff, repo, t1, &o.diffopts),
"diff tree to working directory", NULL);
else
check_lg2(
git_diff_tree_to_index(&diff, repo, t1, NULL, &o.diffopts),
"diff tree to index", NULL);
}
else if (t1)
check_lg2(
git_diff_tree_to_workdir_with_index(&diff, repo, t1, &o.diffopts),
"diff tree to working directory", NULL);
else if (o.cached) {
treeish_to_tree(&t1, repo, "HEAD");
check_lg2(
git_diff_tree_to_index(&diff, repo, t1, NULL, &o.diffopts),
"diff tree to index", NULL);
}
else
check_lg2(
git_diff_index_to_workdir(&diff, repo, NULL, &o.diffopts),
......@@ -121,11 +138,13 @@ int main(int argc, char *argv[])
/** Generate simple output using libgit2 display helper. */
if (o.numstat == 1)
diff_print_numstat(diff);
else if (o.shortstat == 1)
diff_print_shortstat(diff);
else {
if (!o.output)
o.output = OUTPUT_DIFF;
if (o.output != OUTPUT_DIFF)
diff_print_stats(diff, &o);
if ((o.output & OUTPUT_DIFF) != 0) {
if (o.color >= 0)
fputs(colors[0], stdout);
......@@ -210,16 +229,25 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
usage("Only one or two tree identifiers can be provided", NULL);
}
else if (!strcmp(a, "-p") || !strcmp(a, "-u") ||
!strcmp(a, "--patch"))
!strcmp(a, "--patch")) {
o->output |= OUTPUT_DIFF;
o->format = GIT_DIFF_FORMAT_PATCH;
}
else if (!strcmp(a, "--cached"))
o->cached = 1;
else if (!strcmp(a, "--name-only"))
o->cache = CACHE_ONLY;
else if (!strcmp(a, "--nocache"))
o->cache = CACHE_NONE;
else if (!strcmp(a, "--name-only") || !strcmp(a, "--format=name"))
o->format = GIT_DIFF_FORMAT_NAME_ONLY;
else if (!strcmp(a, "--name-status"))
else if (!strcmp(a, "--name-status") ||
!strcmp(a, "--format=name-status"))
o->format = GIT_DIFF_FORMAT_NAME_STATUS;
else if (!strcmp(a, "--raw"))
else if (!strcmp(a, "--raw") || !strcmp(a, "--format=raw"))
o->format = GIT_DIFF_FORMAT_RAW;
else if (!strcmp(a, "--format=diff-index")) {
o->format = GIT_DIFF_FORMAT_RAW;
o->diffopts.id_abbrev = 40;
}
else if (!strcmp(a, "--color"))
o->color = 0;
else if (!strcmp(a, "--no-color"))
......@@ -242,10 +270,14 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
o->diffopts.flags |= GIT_DIFF_PATIENCE;
else if (!strcmp(a, "--minimal"))
o->diffopts.flags |= GIT_DIFF_MINIMAL;
else if (!strcmp(a, "--stat"))
o->output |= OUTPUT_STAT;
else if (!strcmp(a, "--numstat"))
o->numstat = 1;
o->output |= OUTPUT_NUMSTAT;
else if (!strcmp(a, "--shortstat"))
o->shortstat = 1;
o->output |= OUTPUT_SHORTSTAT;
else if (!strcmp(a, "--summary"))
o->output |= OUTPUT_SUMMARY;
else if (match_uint16_arg(
&o->findopts.rename_threshold, &args, "-M") ||
match_uint16_arg(
......@@ -267,6 +299,8 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
&o->diffopts.context_lines, &args, "--unified") &&
!match_uint16_arg(
&o->diffopts.interhunk_lines, &args, "--inter-hunk-context") &&
!match_uint16_arg(
&o->diffopts.id_abbrev, &args, "--abbrev") &&
!match_str_arg(&o->diffopts.old_prefix, &args, "--src-prefix") &&
!match_str_arg(&o->diffopts.new_prefix, &args, "--dst-prefix") &&
!match_str_arg(&o->dir, &args, "--git-dir"))
......@@ -274,72 +308,30 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
}
}
/** Display diff output with "--numstat".*/
static void diff_print_numstat(git_diff *diff)
/** Display diff output with "--stat", "--numstat", or "--shortstat" */
static void diff_print_stats(git_diff *diff, struct opts *o)
{
git_patch *patch;
const git_diff_delta *delta;
size_t d, ndeltas = git_diff_num_deltas(diff);
size_t nadditions, ndeletions;
for (d = 0; d < ndeltas; d++){
check_lg2(
git_patch_from_diff(&patch, diff, d),
"generating patch from diff", NULL);
git_diff_stats *stats;
git_buf b = GIT_BUF_INIT_CONST(NULL, 0);
git_diff_stats_format_t format = 0;
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("%ld\t%ld\t%s\n",
(long)nadditions, (long)ndeletions, delta->new_file.path);
git_patch_free(patch);
}
}
/** Display diff output with "--shortstat".*/
static void diff_print_shortstat(git_diff *diff)
{
git_patch *patch;
size_t d, ndeltas = git_diff_num_deltas(diff);
size_t nadditions, ndeletions;
long nadditions_sum, ndeletions_sum;
git_diff_get_stats(&stats, diff), "generating stats for diff", NULL);
nadditions_sum = 0;
ndeletions_sum = 0;
if (o->output & OUTPUT_STAT)
format |= GIT_DIFF_STATS_FULL;
if (o->output & OUTPUT_SHORTSTAT)
format |= GIT_DIFF_STATS_SHORT;
if (o->output & OUTPUT_NUMSTAT)
format |= GIT_DIFF_STATS_NUMBER;
if (o->output & OUTPUT_SUMMARY)
format |= GIT_DIFF_STATS_INCLUDE_SUMMARY;
for (d = 0; d < ndeltas; d++){
check_lg2(
git_patch_from_diff(&patch, diff, d),
"generating patch from diff", NULL);
git_diff_stats_to_buf(&b, stats, format, 80), "formatting stats", NULL);
check_lg2(
git_patch_line_stats(NULL, &nadditions, &ndeletions, patch),
"generating the number of additions and deletions", NULL);
nadditions_sum += nadditions;
ndeletions_sum += ndeletions;
git_patch_free(patch);
}
if (ndeltas) {
fputs(b.ptr, stdout);
printf(" %ld ", (long)ndeltas);
printf("%s", 1==ndeltas ? "file changed" : "files changed");
if(nadditions_sum) {
printf(", %ld ",nadditions_sum);
printf("%s", 1==nadditions_sum ? "insertion(+)" : "insertions(+)");
}
if(ndeletions_sum) {
printf(", %ld ",ndeletions_sum);
printf("%s", 1==ndeletions_sum ? "deletion(-)" : "deletions(-)");
}
printf("\n");
}
git_buf_free(&b);
git_diff_stats_free(stats);
}
......@@ -725,24 +725,17 @@ GIT_EXTERN(int) git_diff_index_to_workdir(
* The tree you provide will be used for the "old_file" side of the delta,
* and the working directory will be used for the "new_file" side.
*
* Please note: this is *NOT* the same as `git diff <treeish>`. Running
* `git diff HEAD` or the like actually uses information from the index,
* along with the tree and working directory info.
*
* This function returns strictly the differences between the tree and the
* files contained in the working directory, regardless of the state of
* files in the index. It may come as a surprise, but there is no direct
* equivalent in core git.
*
* To emulate `git diff <tree>`, use `git_diff_tree_to_workdir_with_index`
* (or `git_diff_tree_to_index` and `git_diff_index_to_workdir`, then call
* `git_diff_merge` on the results). That will yield a `git_diff` that
* matches the git output.
*
* If this seems confusing, take the case of a file with a staged deletion
* where the file has then been put back into the working dir and modified.
* The tree-to-workdir diff for that file is 'modified', but core git would
* show status 'deleted' since there is a pending deletion in the index.
* This is not the same as `git diff <treeish>` or `git diff-index
* <treeish>`. Those commands use information from the index, whereas this
* function strictly returns the differences between the tree and the files
* in the working directory, regardless of the state of the index. Use
* `git_diff_tree_to_workdir_with_index` to emulate those commands.
*
* To see difference between this and `git_diff_tree_to_workdir_with_index`,
* consider the example of a staged file deletion where the file has then
* been put back into the working dir and further modified. The
* tree-to-workdir diff for that file is 'modified', but `git diff` would
* show status 'deleted' since there is a staged delete.
*
* @param diff A pointer to a git_diff pointer that will be allocated.
* @param repo The repository containing the tree.
......@@ -1143,12 +1136,14 @@ GIT_EXTERN(size_t) git_diff_stats_deletions(
* @param out buffer to store the formatted diff statistics in.
* @param stats A `git_diff_stats` generated by one of the above functions.
* @param format Formatting option.
* @param width Target width for output (only affects GIT_DIFF_STATS_FULL)
* @return 0 on success; non-zero on error
*/
GIT_EXTERN(int) git_diff_stats_to_buf(
git_buf *out,
const git_diff_stats *stats,
git_diff_stats_format_t format);
git_diff_stats_format_t format,
size_t width);
/**
* Deallocate a `git_diff_stats`.
......
......@@ -1590,7 +1590,8 @@ int git_diff_format_email(
if ((error = git_buf_puts(out, "---\n")) < 0 ||
(error = git_diff_get_stats(&stats, diff)) < 0 ||
(error = git_diff_stats_to_buf(out, stats, format_flags)) < 0 ||
(error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 ||
(error = git_buf_putc(out, '\n')) < 0 ||
(error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0)
goto on_error;
......
......@@ -175,7 +175,8 @@ static int diff_print_one_raw(
git_oid_tostr(end_oid, pi->oid_strlen, &delta->new_file.id);
git_buf_printf(
out, ":%06o %06o %s... %s... %c",
out, (pi->oid_strlen <= GIT_OID_HEXSZ) ?
":%06o %06o %s... %s... %c" : ":%06o %06o %s %s %c",
delta->old_file.mode, delta->new_file.mode, start_oid, end_oid, code);
if (delta->similarity > 0)
......
......@@ -17,14 +17,43 @@ void test_diff_format_email__cleanup(void)
cl_git_sandbox_cleanup();
}
void test_diff_format_email__simple(void)
static void assert_email_match(
const char *expected,
const char *oidstr,
git_diff_format_email_options *opts)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
git_oid_fromstr(&oid, oidstr);
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts->id = git_commit_id(commit);
opts->author = git_commit_author(commit);
if (!opts->summary)
opts->summary = git_commit_summary(commit);
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, opts));
cl_assert_equal_s(expected, git_buf_cstr(&buf));
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(
&buf, repo, commit, 1, 1, opts->flags, NULL));
cl_assert_equal_s(expected, git_buf_cstr(&buf));
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
}
void test_diff_format_email__simple(void)
{
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
const char *email =
"From 9264b96c6d104d0e07ae33d3007b6a48246c6f92 Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -64,25 +93,8 @@ void test_diff_format_email__simple(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "9264b96c6d104d0e07ae33d3007b6a48246c6f92");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = git_commit_summary(commit);
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(&buf, repo, commit, 1, 1, 0, NULL));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
}
void test_diff_format_email__multiple(void)
......@@ -167,6 +179,7 @@ void test_diff_format_email__multiple(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "10808fe9c9be5a190c0ba68d1a002233fb363508");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
......@@ -196,7 +209,7 @@ void test_diff_format_email__multiple(void)
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
cl_assert_equal_s(email, git_buf_cstr(&buf));
git_diff_free(diff);
git_commit_free(commit);
......@@ -205,12 +218,7 @@ void test_diff_format_email__multiple(void)
void test_diff_format_email__exclude_marker(void)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
const char *email =
"From 9264b96c6d104d0e07ae33d3007b6a48246c6f92 Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -250,27 +258,10 @@ void test_diff_format_email__exclude_marker(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "9264b96c6d104d0e07ae33d3007b6a48246c6f92");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = git_commit_summary(commit);
opts.flags |= GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER;
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(&buf, repo, commit, 1, 1,
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER, NULL));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
}
void test_diff_format_email__invalid_no(void)
......@@ -303,12 +294,7 @@ void test_diff_format_email__invalid_no(void)
void test_diff_format_email__mode_change(void)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
const char *email =
"From 7ade76dd34bba4733cf9878079f9fd4a456a9189 Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -330,35 +316,13 @@ void test_diff_format_email__mode_change(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "7ade76dd34bba4733cf9878079f9fd4a456a9189");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = git_commit_summary(commit);
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(&buf, repo, commit, 1, 1, 0, NULL));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "7ade76dd34bba4733cf9878079f9fd4a456a9189", &opts);
}
void test_diff_format_email__rename_add_remove(void)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
const char *email =
"From 6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -422,35 +386,13 @@ void test_diff_format_email__rename_add_remove(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = git_commit_summary(commit);
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(&buf, repo, commit, 1, 1, 0, NULL));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d", &opts);
}
void test_diff_format_email__multiline_summary(void)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
const char *email =
"From 9264b96c6d104d0e07ae33d3007b6a48246c6f92 Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -490,36 +432,15 @@ void test_diff_format_email__multiline_summary(void)
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
git_oid_fromstr(&oid, "9264b96c6d104d0e07ae33d3007b6a48246c6f92");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = "Modify some content\nSome extra stuff here";
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_buf_clear(&buf);
cl_git_pass(git_diff_commit_as_email(&buf, repo, commit, 1, 1, 0, NULL));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
}
void test_diff_format_email__binary(void)
{
git_oid oid;
git_commit *commit = NULL;
git_diff *diff = NULL;
git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
git_buf buf = GIT_BUF_INIT;
/* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
const char *email =
"From 8d7523f6fcb2404257889abe0d96f093d9f524f9 Mon Sep 17 00:00:00 2001\n" \
"From: Jacques Germishuys <jacquesg@striata.com>\n" \
......@@ -536,21 +457,11 @@ void test_diff_format_email__binary(void)
"--\n" \
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
/* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
git_oid_fromstr(&oid, "8d7523f6fcb2404257889abe0d96f093d9f524f9");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
opts.id = git_commit_id(commit);
opts.author = git_commit_author(commit);
opts.summary = "Modified binary file";
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
cl_assert(strcmp(git_buf_cstr(&buf), email) == 0);
git_diff_free(diff);
git_commit_free(commit);
git_buf_free(&buf);
assert_email_match(
email, "8d7523f6fcb2404257889abe0d96f093d9f524f9", &opts);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment