mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 06:20:56 +00:00
Support diff.context config
This commit is contained in:
parent
bd0a07f4bb
commit
a5df71c11f
13
src/diff.c
13
src/diff.c
@ -267,6 +267,16 @@ static int config_bool(git_config *cfg, const char *name, int defvalue)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int config_int(git_config *cfg, const char *name, int defvalue)
|
||||||
|
{
|
||||||
|
int val = defvalue;
|
||||||
|
|
||||||
|
if (git_config_get_int32(&val, cfg, name) < 0)
|
||||||
|
giterr_clear();
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
static git_diff_list *git_diff_list_alloc(
|
static git_diff_list *git_diff_list_alloc(
|
||||||
git_repository *repo, const git_diff_options *opts)
|
git_repository *repo, const git_diff_options *opts)
|
||||||
{
|
{
|
||||||
@ -306,7 +316,8 @@ static git_diff_list *git_diff_list_alloc(
|
|||||||
|
|
||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
/* Make sure we default to 3 lines */
|
/* Make sure we default to 3 lines */
|
||||||
diff->opts.context_lines = 3;
|
int context = config_int(cfg, "diff.context", 3);
|
||||||
|
diff->opts.context_lines = max(context, 0);
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user