The previous iteration of the same can be found:
http://www.mail-archive.com/git@vger.kernel.org/msg78153.html

Changes in this version:
* use ref_default_sorting()
* Improve documentation, comments and commit message.

Karthik Nayak (8):
  branch: refactor width computation
  branch: bump get_head_description() to the top
  branch: roll show_detached HEAD into regular ref_list
  branch: move 'current' check down to the presentation layer
  branch: drop non-commit error reporting
  branch.c: use 'ref-filter' data structures
  branch.c: use 'ref-filter' APIs
  branch: add '--points-at' option

 Documentation/git-branch.txt |  16 +-
 builtin/branch.c             | 502 +++++++++++++------------------------------
 ref-filter.c                 |   2 +-
 ref-filter.h                 |   6 +-
 t/t1430-bad-ref-name.sh      |  31 ++-
 t/t3203-branch-output.sh     |  20 ++
 6 files changed, 211 insertions(+), 366 deletions(-)

Interdiff:

diff --git a/builtin/branch.c b/builtin/branch.c
index b0a96e1..b7a60f4 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -479,8 +479,6 @@ static void print_ref_list(struct ref_filter *filter, 
struct ref_sorting *sortin
        struct ref_array array;
        int maxwidth = 0;
        const char *remote_prefix = "";
-       struct ref_sorting def_sorting;
-       const char *sort_type = "refname";
 
        /*
         * If we are listing more than just remote branches,
@@ -498,12 +496,15 @@ static void print_ref_list(struct ref_filter *filter, 
struct ref_sorting *sortin
        if (filter->verbose)
                maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
 
-       if (!sorting) {
-               def_sorting.next = NULL;
-               def_sorting.atom = parse_ref_filter_atom(sort_type,
-                                                        sort_type + 
strlen(sort_type));
-               sorting = &def_sorting;
-       }
+       /*
+        * 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);

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 647a9cf..03c7af1 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -237,8 +235,11 @@ start-point is either a local or remote-tracking branch.
        order of the value. You may use the --sort=<key> option
        multiple times, in which case the last key becomes the primary
        key. The keys supported are the same as those in `git
-       for-each-ref`. Sort order defaults to sorting based on branch
-       type.
+       for-each-ref`. Sort order defaults to sorting based on the
+       full refname (including `refs/...` prefix). This lists
+       detached HEAD (if present) first, then local branches and
+       finally remote-tracking branches.
+
 
 --points-at <object>::
        Only list branches of the given object.

 
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to