Merge branch 'jb/diff-no-index-no-abbrev'
[gitweb.git] / builtin / branch.c
index 7df05437f11f76fb3a6c2c879fbb88fb63e71eac..9d30f55b0b83cfc09294e2cb7cabdc9aa72e2508 100644 (file)
@@ -512,15 +512,6 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
        if (filter->verbose)
                maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
 
-       /*
-        * If no sorting parameter is given then we default to sorting
-        * by 'refname'. This would give us an alphabetically sorted
-        * array with the 'HEAD' ref at the beginning followed by
-        * local branches 'refs/heads/...' and finally remote-tacking
-        * branches 'refs/remotes/...'.
-        */
-       if (!sorting)
-               sorting = ref_default_sorting();
        ref_array_sort(sorting, &array);
 
        for (i = 0; i < array.nr; i++)
@@ -531,7 +522,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 
 static void reject_rebase_or_bisect_branch(const char *target)
 {
-       struct worktree **worktrees = get_worktrees();
+       struct worktree **worktrees = get_worktrees(0);
        int i;
 
        for (i = 0; worktrees[i]; i++) {
@@ -645,6 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        const char *new_upstream = NULL;
        enum branch_track track;
        struct ref_filter filter;
+       int icase = 0;
        static struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
 
        struct option options[] = {
@@ -657,7 +649,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                OPT_SET_INT( 0, "set-upstream",  &track, N_("change upstream info"),
                        BRANCH_TRACK_OVERRIDE),
                OPT_STRING('u', "set-upstream-to", &new_upstream, N_("upstream"), N_("change the upstream info")),
-               OPT_BOOL(0, "unset-upstream", &unset_upstream, "Unset the upstream info"),
+               OPT_BOOL(0, "unset-upstream", &unset_upstream, N_("Unset the upstream info")),
                OPT__COLOR(&branch_use_color, N_("use colored output")),
                OPT_SET_INT('r', "remotes",     &filter.kind, N_("act on remote-tracking branches"),
                        FILTER_REFS_REMOTES),
@@ -686,6 +678,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                        OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
                        N_("print only branches of the object"), 0, parse_opt_object_name
                },
+               OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_END(),
        };
 
@@ -723,6 +716,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
        if (filter.abbrev == -1)
                filter.abbrev = DEFAULT_ABBREV;
+       filter.ignore_case = icase;
+
        finalize_colopts(&colopts, -1);
        if (filter.verbose) {
                if (explicitly_enable_column(colopts))
@@ -744,6 +739,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
                        filter.kind |= FILTER_REFS_DETACHED_HEAD;
                filter.name_patterns = argv;
+               /*
+                * If no sorting parameter is given then we default to sorting
+                * by 'refname'. This would give us an alphabetically sorted
+                * array with the 'HEAD' ref at the beginning followed by
+                * local branches 'refs/heads/...' and finally remote-tacking
+                * branches 'refs/remotes/...'.
+                */
+               if (!sorting)
+                       sorting = ref_default_sorting();
+               sorting->ignore_case = icase;
                print_ref_list(&filter, sorting);
                print_columns(&output, colopts, NULL);
                string_list_clear(&output, 0);
@@ -807,7 +812,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                 * create_branch takes care of setting up the tracking
                 * info and making sure new_upstream is correct
                 */
-               create_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
+               create_branch(branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
        } else if (unset_upstream) {
                struct branch *branch = branch_get(argv[0]);
                struct strbuf buf = STRBUF_INIT;
@@ -853,7 +858,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                strbuf_release(&buf);
 
                branch_existed = ref_exists(branch->refname);
-               create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
+               create_branch(argv[0], (argc == 2) ? argv[1] : head,
                              force, reflog, 0, quiet, track);
 
                /*