summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d976593)
raw | patch | inline | side by side (parent: d976593)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 20 Dec 2009 04:07:26 +0000 (23:07 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 20 Dec 2009 04:11:08 +0000 (23:11 -0500) |
NEWS | patch | blob | history | |
tig.c | patch | blob | history |
index 17d3925bb8557223476fdacbef76b17680a10d6a..d5997911d1e4c1deb364ecbc50cc6d0f1a2396df 100644 (file)
--- a/NEWS
+++ b/NEWS
- Status view: fix usage from sub directories, which was broken by the
changes made to support blame view from sub directories.
- Fix parsing of boolean show-date values.
+ - Fix relative date.
tig-0.15
--------
index 1c7928dabe56900a2f384c920c36169c3b2f17a1..81b85e724a57dbae6dfd32d97638c1d696209d6d 100644 (file)
--- a/tig.c
+++ b/tig.c
}
-/*
- * What value of "tz" was in effect back then at "time" in the
- * local timezone?
- */
-static int local_tzoffset(time_t time)
-{
- time_t t, t_local;
- struct tm tm;
- int offset, eastwest;
-
- t = time;
- localtime_r(&t, &tm);
- t_local = mktime(&tm);
-
- if (t_local < t) {
- eastwest = -1;
- offset = t - t_local;
- } else {
- eastwest = 1;
- offset = t_local - t;
- }
- offset /= 60; /* in minutes */
- offset = (offset % 60) + ((offset / 60) * 100);
- return offset * eastwest;
-}
-
#define DATE_INFO \
DATE_(NO), \
DATE_(DEFAULT), \
#undef DATE_
};
+struct time {
+ time_t sec;
+ int tz;
+};
+
+static inline int timecmp(const struct time *t1, const struct time *t2)
+{
+ return t1->sec - t2->sec;
+}
+
static const char *
-string_date(const time_t *time, enum date date)
+string_date(const struct time *time, enum date date)
{
static char buf[DATE_COLS + 1];
static const struct enum_map reldate[] = {
if (date == DATE_RELATIVE) {
struct timeval now;
- time_t date = *time + local_tzoffset(*time);
+ time_t date = time->sec + time->tz;
time_t seconds;
int i;
}
}
- gmtime_r(time, &tm);
+ gmtime_r(&time->sec, &tm);
return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL;
}
@@ -2259,7 +2243,7 @@ draw_field(struct view *view, enum line_type type, const char *text, int len, bo
}
static bool
-draw_date(struct view *view, time_t *time)
+draw_date(struct view *view, struct time *time)
{
const char *date = time ? mkdate(time) : "";
int cols = opt_date == DATE_SHORT ? DATE_SHORT_COLS : DATE_COLS;
}
static void
-parse_timezone(time_t *time, const char *zone)
+parse_timesec(struct time *time, const char *sec)
+{
+ time->sec = (time_t) atol(sec);
+}
+
+static void
+parse_timezone(struct time *time, const char *zone)
{
long tz;
if (zone[0] == '-')
tz = -tz;
- *time -= tz;
+ time->tz = tz;
+ time->sec -= tz;
}
/* Parse author lines where the name may be empty:
* author <email@address.tld> 1138474660 +0100
*/
static void
-parse_author_line(char *ident, const char **author, time_t *time)
+parse_author_line(char *ident, const char **author, struct time *time)
{
char *nameend = strchr(ident, '<');
char *emailend = strchr(ident, '>');
char *secs = emailend + 2;
char *zone = strchr(secs, ' ');
- *time = (time_t) atol(secs);
+ parse_timesec(time, secs);
if (zone && strlen(zone) == STRING_SIZE(" +0700"))
parse_timezone(time, zone + 1);
struct tree_entry {
char id[SIZEOF_REV];
mode_t mode;
- time_t time; /* Date from the author ident. */
+ struct time time; /* Date from the author ident. */
const char *author; /* Author of the commit. */
char name[1];
};
switch (get_sort_field(tree_sort_state)) {
case ORDERBY_DATE:
- return sort_order(tree_sort_state, entry1->time - entry2->time);
+ return sort_order(tree_sort_state, timecmp(&entry1->time, &entry2->time));
case ORDERBY_AUTHOR:
return sort_order(tree_sort_state, strcmp(entry1->author, entry2->author));
tree_read_date(struct view *view, char *text, bool *read_date)
{
static const char *author_name;
- static time_t author_time;
+ static struct time author_time;
if (!text && *read_date) {
*read_date = FALSE;
char id[SIZEOF_REV]; /* SHA1 ID. */
char title[128]; /* First line of the commit message. */
const char *author; /* Author of the commit. */
- time_t time; /* Date from the author ident. */
+ struct time time; /* Date from the author ident. */
char filename[128]; /* Name of file. */
bool has_previous; /* Was a "previous" line detected. */
};
commit->author = get_author(line);
} else if (match_blame_header("author-time ", &line)) {
- commit->time = (time_t) atol(line);
+ parse_timesec(&commit->time, line);
} else if (match_blame_header("author-tz ", &line)) {
parse_timezone(&commit->time, line);
blame_draw(struct view *view, struct line *line, unsigned int lineno)
{
struct blame *blame = line->data;
- time_t *time = NULL;
+ struct time *time = NULL;
const char *id = NULL, *author = NULL;
char text[SIZEOF_STR];
struct branch {
const char *author; /* Author of the last commit. */
- time_t time; /* Date of the last activity. */
+ struct time time; /* Date of the last activity. */
const struct ref *ref; /* Name and commit ID information. */
};
switch (get_sort_field(branch_sort_state)) {
case ORDERBY_DATE:
- return sort_order(branch_sort_state, branch1->time - branch2->time);
+ return sort_order(branch_sort_state, timecmp(&branch1->time, &branch2->time));
case ORDERBY_AUTHOR:
return sort_order(branch_sort_state, strcmp(branch1->author, branch2->author));
char id[SIZEOF_REV]; /* SHA1 ID. */
char title[128]; /* First line of the commit message. */
const char *author; /* Author of the commit. */
- time_t time; /* Date from the author ident. */
+ struct time time; /* Date from the author ident. */
struct ref_list *refs; /* Repository references. */
chtype graph[SIZEOF_REVGRAPH]; /* Ancestry chain graphics. */
size_t graph_size; /* The width of the graph array. */