Merge with master
authorJonas Fonseca <fonseca@diku.dk>
Sun, 25 Mar 2007 09:10:14 +0000 (11:10 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 25 Mar 2007 09:10:14 +0000 (11:10 +0200)
Makefile
SITES
TODO
tig.c
tigrc.5.txt

index 9d8c57b..0052abd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ mandir = $(prefix)/man
 docdir = $(prefix)/share/doc
 # DESTDIR=
 
-LDLIBS  = -lcurses
+LDLIBS  = -lcurses -liconv
 CFLAGS = -Wall -O2
 DFLAGS = -g -DDEBUG -Werror
 PROGS  = tig
diff --git a/SITES b/SITES
index 500b977..3b4e90d 100644 (file)
--- a/SITES
+++ b/SITES
@@ -1,6 +1,6 @@
- - Homepage:   http://jonas.nitro.dk/tig[]
+ - Homepage:   http://jonas.nitro.dk/tig/[]
  - Manual:     http://jonas.nitro.dk/tig/manual.html[]
- - Releases:   http://jonas.nitro.dk/tig/releases[]
- - Git URL:    http://jonas.nitro.dk/tig/tig.git[] or
-               git://repo.or.cz/tig.git
- - Gitweb:     http://repo.or.cz/?p=tig.git;a=summary[]
+ - Releases:   http://jonas.nitro.dk/tig/releases/[]
+ - Git URL:    git://repo.or.cz/tig.git (mirror) or
+               http://jonas.nitro.dk/tig/tig.git[] (master)
+ - Gitweb:     http://repo.or.cz/w/tig.git[]
diff --git a/TODO b/TODO
index f36da73..f176427 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,7 +10,7 @@ Features that should be explored.
        are both -1, then leaveok is set.  The two routines getsyx and setsyx
        are designed  to  be used by a library routine, which manipulates
        curses windows but does not want to change the current position of the
-       program’s cursor.  The library routine would call getsyx at the
+       program cursor.  The library routine would call getsyx at the
        beginning, do its manipulation of its own windows, do a wnoutrefresh on
        its windows, call  setsyx,  and then call doupdate.
 
@@ -18,3 +18,10 @@ Features that should be explored.
    heads and from which tags the commit is reachable, and perhaps which tag is
    the latest among the ones reachable from that commit, as part of the commit
    detail information you display on the lower pane (log/diff view).
+
+ - Use autoconf to check for iconv in libc and how it is declared (the
+   2nd argument is 'const' on FreeBSD / Mac OS X). Maybe also check for
+   the AsciiDoc and XmlTo document tools.
+
+ - The autoconf check could also be used to determine whether it is a
+   newer git so that git-config will be used instead of git-repo-config.
diff --git a/tig.c b/tig.c
index 1983375..8deab13 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -90,7 +90,7 @@ static size_t utf8_length(const char *string, size_t max_width, int *coloffset,
 #define        SCALE_SPLIT_VIEW(height)        ((height) * 2 / 3)
 
 #define TIG_LS_REMOTE \
-       "git ls-remote . 2>/dev/null"
+       "git ls-remote $(git rev-parse --git-dir) 2>/dev/null"
 
 #define TIG_DIFF_CMD \
        "git show --root --patch-with-stat --find-copies-harder -B -C %s 2>/dev/null"
@@ -121,6 +121,7 @@ struct ref {
        char *name;             /* Ref name; tag or head names are shortened. */
        char id[SIZEOF_REV];    /* Commit SHA1 ID */
        unsigned int tag:1;     /* Is it a tag? */
+       unsigned int remote:1;  /* Is it a remote ref? */
        unsigned int next:1;    /* For ref lists: are there more refs? */
 };
 
@@ -519,7 +520,7 @@ parse_options(int argc, char *argv[])
                if (opt_request == REQ_VIEW_MAIN)
                        /* XXX: This is vulnerable to the user overriding
                         * options required for the main view parser. */
-                       string_copy(opt_cmd, "git log --stat --pretty=raw");
+                       string_copy(opt_cmd, "git log --pretty=raw");
                else
                        string_copy(opt_cmd, "git");
                buf_size = strlen(opt_cmd);
@@ -533,7 +534,6 @@ parse_options(int argc, char *argv[])
                        die("command too long");
 
                opt_cmd[buf_size] = 0;
-
        }
 
        if (*opt_encoding && strcasecmp(opt_encoding, "UTF-8"))
@@ -586,6 +586,7 @@ LINE(MAIN_AUTHOR,  "",                      COLOR_GREEN,    COLOR_DEFAULT,  0), \
 LINE(MAIN_COMMIT,  "",                 COLOR_DEFAULT,  COLOR_DEFAULT,  0), \
 LINE(MAIN_DELIM,   "",                 COLOR_MAGENTA,  COLOR_DEFAULT,  0), \
 LINE(MAIN_TAG,     "",                 COLOR_MAGENTA,  COLOR_DEFAULT,  A_BOLD), \
+LINE(MAIN_REMOTE,  "",                 COLOR_YELLOW,   COLOR_DEFAULT,  A_BOLD), \
 LINE(MAIN_REF,     "",                 COLOR_CYAN,     COLOR_DEFAULT,  A_BOLD), \
 LINE(TREE_DIR,     "",                 COLOR_DEFAULT,  COLOR_DEFAULT,  A_NORMAL), \
 LINE(TREE_FILE,    "",                 COLOR_DEFAULT,  COLOR_DEFAULT,  A_NORMAL)
@@ -1883,7 +1884,7 @@ update_view(struct view *view)
 
                        size_t ret;
 
-                       ret = iconv(opt_iconv, (const char **) &inbuf, &inlen, &outbuf, &outlen);
+                       ret = iconv(opt_iconv, &inbuf, &inlen, &outbuf, &outlen);
                        if (ret != (size_t) -1) {
                                line = out_buffer;
                                linelen = strlen(out_buffer);
@@ -2321,7 +2322,7 @@ add_describe_ref(char *buf, size_t *bufpos, char *commit_id, const char *sep)
        char *ref = NULL;
        FILE *pipe;
 
-       if (!string_format(refbuf, "git describe %s", commit_id))
+       if (!string_format(refbuf, "git describe %s 2>/dev/null", commit_id))
                return TRUE;
 
        pipe = popen(refbuf, "r");
@@ -2363,7 +2364,8 @@ add_pager_refs(struct view *view, struct line *line)
 
        do {
                struct ref *ref = refs[refpos];
-               char *fmt = ref->tag ? "%s[%s]" : "%s%s";
+               char *fmt = ref->tag    ? "%s[%s]" :
+                           ref->remote ? "%s<%s>" : "%s%s";
 
                if (!string_format_from(buf, &bufpos, fmt, sep, ref->name))
                        return;
@@ -2978,6 +2980,8 @@ main_draw(struct view *view, struct line *line, unsigned int lineno, bool select
                                ;
                        else if (commit->refs[i]->tag)
                                wattrset(view->win, get_line_attr(LINE_MAIN_TAG));
+                       else if (commit->refs[i]->remote)
+                               wattrset(view->win, get_line_attr(LINE_MAIN_REMOTE));
                        else
                                wattrset(view->win, get_line_attr(LINE_MAIN_REF));
                        waddstr(view->win, "[");
@@ -3044,46 +3048,35 @@ main_read(struct view *view, char *line)
 
        case LINE_AUTHOR:
        {
+               /* Parse author lines where the name may be empty:
+                *      author  <email@address.tld> 1138474660 +0100
+                */
                char *ident = line + STRING_SIZE("author ");
-               char *end = strchr(ident, '<');
+               char *nameend = strchr(ident, '<');
+               char *emailend = strchr(ident, '>');
 
-               if (!commit)
+               if (!commit || !nameend || !emailend)
                        break;
 
                update_rev_graph(graph);
                graph = graph->next;
 
-               if (end) {
-                       char *email = end + 1;
-
-                       for (; end > ident && isspace(end[-1]); end--) ;
-
-                       if (end == ident && *email) {
-                               ident = email;
-                               end = strchr(ident, '>');
-                               for (; end > ident && isspace(end[-1]); end--) ;
-                       }
-                       *end = 0;
+               *nameend = *emailend = 0;
+               ident = chomp_string(ident);
+               if (!*ident) {
+                       ident = chomp_string(nameend + 1);
+                       if (!*ident)
+                               ident = "Unknown";
                }
 
-               /* End is NULL or ident meaning there's no author. */
-               if (end <= ident)
-                       ident = "Unknown";
-
                string_copy(commit->author, ident);
 
                /* Parse epoch and timezone */
-               if (end) {
-                       char *secs = strchr(end + 1, '>');
-                       char *zone;
-                       time_t time;
-
-                       if (!secs || secs[1] != ' ')
-                               break;
+               if (emailend[1] == ' ') {
+                       char *secs = emailend + 2;
+                       char *zone = strchr(secs, ' ');
+                       time_t time = (time_t) atol(secs);
 
-                       secs += 2;
-                       time = (time_t) atol(secs);
-                       zone = strchr(secs, ' ');
                        if (zone && strlen(zone) == STRING_SIZE(" +0700")) {
                                long tz;
 
@@ -3098,6 +3091,7 @@ main_read(struct view *view, char *line)
 
                                time -= tz;
                        }
+
                        gmtime_r(&time, &commit->time);
                }
                break;
@@ -3573,6 +3567,7 @@ read_ref(char *id, int idlen, char *name, int namelen)
 {
        struct ref *ref;
        bool tag = FALSE;
+       bool remote = FALSE;
 
        if (!strncmp(name, "refs/tags/", STRING_SIZE("refs/tags/"))) {
                /* Commits referenced by tags has "^{}" appended. */
@@ -3586,6 +3581,11 @@ read_ref(char *id, int idlen, char *name, int namelen)
                namelen -= STRING_SIZE("refs/tags/");
                name    += STRING_SIZE("refs/tags/");
 
+       } else if (!strncmp(name, "refs/remotes/", STRING_SIZE("refs/remotes/"))) {
+               remote = TRUE;
+               namelen -= STRING_SIZE("refs/remotes/");
+               name    += STRING_SIZE("refs/remotes/");
+
        } else if (!strncmp(name, "refs/heads/", STRING_SIZE("refs/heads/"))) {
                namelen -= STRING_SIZE("refs/heads/");
                name    += STRING_SIZE("refs/heads/");
@@ -3606,6 +3606,7 @@ read_ref(char *id, int idlen, char *name, int namelen)
        strncpy(ref->name, name, namelen);
        ref->name[namelen] = 0;
        ref->tag = tag;
+       ref->remote = remote;
        string_copy(ref->id, id);
 
        return OK;
index 1b1df67..a3bee01 100644 (file)
@@ -294,7 +294,7 @@ Appearance of the various columns in the main view, including the '~' used for
 delimiting long author names and labels for tag and branch references.
 
 *main-date*, *main-author*, *main-commit*, *main-delim*, *main-tag*,
-*main-ref*
+*main-ref*, *main-remote*
 
 --