glossary: more precise definition of tree-ish (a.k.a. treeish)
[gitweb.git] / line-range.c
index 8faf94374517b605d2529de2f4bafc869b72df60..3942475c2fc8e48c7f0a2d7808f77a4f71a1cde6 100644 (file)
@@ -211,6 +211,8 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
                    void *cb_data, long lines, long *begin, long *end,
                    const char *path)
 {
+       *begin = *end = 0;
+
        if (*arg == ':') {
                arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, begin, end, path);
                if (!arg || *arg)
@@ -226,6 +228,11 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
        if (*arg)
                return -1;
 
+       if (*begin && *end && *end < *begin) {
+               long tmp;
+               tmp = *end; *end = *begin; *begin = tmp;
+       }
+
        return 0;
 }