summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e278600)
raw | patch | inline | side by side (parent: e278600)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 10 Feb 2009 20:31:40 +0000 (21:31 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 10 Feb 2009 20:31:40 +0000 (21:31 +0100) |
Inspired by gitweb.
tig.c | patch | blob | history |
index 8b8d593122b1d813f056ed5a5079a1c9b9078038..707209409e8592eadd964ca5b0bb0ccabe186ad4 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -117,6 +117,8 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma
#define NULL_ID "0000000000000000000000000000000000000000"
+#define S_ISGITLINK(mode) (((mode) & S_IFMT) == 0160000)
+
#ifndef GIT_CONFIG
#define GIT_CONFIG "config"
#endif
static bool
draw_mode(struct view *view, mode_t mode)
{
- static const char dir_mode[] = "drwxr-xr-x";
- static const char link_mode[] = "lrwxrwxrwx";
- static const char exe_mode[] = "-rwxr-xr-x";
- static const char file_mode[] = "-rw-r--r--";
const char *str;
if (S_ISDIR(mode))
- str = dir_mode;
+ str = "drwxr-xr-x";
else if (S_ISLNK(mode))
- str = link_mode;
- else if (mode & S_IXUSR)
- str = exe_mode;
+ str = "lrwxrwxrwx";
+ else if (S_ISGITLINK(mode))
+ str = "m---------";
+ else if (S_ISREG(mode) && mode & S_IXUSR)
+ str = "-rwxr-xr-x";
+ else if (S_ISREG(mode))
+ str = "-rw-r--r--";
else
- str = file_mode;
+ str = "----------";
- return draw_field(view, LINE_MODE, str, sizeof(file_mode), FALSE);
+ return draw_field(view, LINE_MODE, str, STRING_SIZE("-rw-r--r-- "), FALSE);
}
static bool