Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Maftoul <samuel.maftoul@gmail.com>2018-08-16 12:35:08 +0300
committerJunio C Hamano <gitster@pobox.com>2018-08-16 21:17:10 +0300
commit560ae1c164ad040a389ccc47834dce8c15447294 (patch)
treeff10bf3737823e15698fabb29c4e0928321eda50 /builtin
parent63749b2dea5d1501ff85bab7b8a7f64911d21dea (diff)
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 <samuel.maftoul@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/branch.c10
1 files changed, 9 insertions, 1 deletions
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;