From 560ae1c164ad040a389ccc47834dce8c15447294 Mon Sep 17 00:00:00 2001 From: Samuel Maftoul Date: Thu, 16 Aug 2018 11:35:08 +0200 Subject: branch: support configuring --sort via .gitconfig Add support for configuring default sort ordering for git branches. Command line option will override this configured value, using the exact same syntax. Signed-off-by: Samuel Maftoul Signed-off-by: Junio C Hamano --- builtin/branch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'builtin/branch.c') diff --git a/builtin/branch.c b/builtin/branch.c index 4fc55c3508..bbd006aab4 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -74,6 +74,14 @@ define_list_config_array(color_branch_slots); static int git_branch_config(const char *var, const char *value, void *cb) { const char *slot_name; + struct ref_sorting **sorting_tail = (struct ref_sorting **)cb; + + if (!strcmp(var, "branch.sort")) { + if (!value) + return config_error_nonbool(var); + parse_ref_sorting(sorting_tail, value); + return 0; + } if (starts_with(var, "column.")) return git_column_config(var, value, "branch", &colopts); @@ -653,7 +661,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_branch_usage, options); - git_config(git_branch_config, NULL); + git_config(git_branch_config, sorting_tail); track = git_branch_track; -- cgit v1.2.3