commit 848d6979f98ff53e56da96dc75ed4aee31f42c31 from: Stefan Sperling date: Mon Aug 12 11:43:17 2019 UTC annotate symlinks with @ in 'got tree' and 'tog tree' commit - cbc52e82e060696e81ab422e23c340cff849c4a3 commit + 848d6979f98ff53e56da96dc75ed4aee31f42c31 blob - 491e31a386d2e43f9aef5aa40c6002f8a22a3b28 blob + 00c7548af39086e290bea57234ee1243e5e1e2bd --- got/got.1 +++ got/got.1 @@ -394,6 +394,7 @@ directory path in the repository. Entries shown in this listing may carry one of the following trailing annotations: .Bl -column YXZ description +.It @ Ta entry is a symbolic link .It / Ta entry is a directory .It * Ta entry is an executable file .El blob - df69fef32b7073df8eca2f0e1cc65808e8d1ebce blob + 486e9fe57b737d0d00f4849e7530505cb0e19467 --- got/got.c +++ got/got.c @@ -2252,14 +2252,21 @@ print_entry(struct got_tree_entry *te, const char *id, const char *root_path) { int is_root_path = (strcmp(path, root_path) == 0); + const char *modestr = ""; path += strlen(root_path); while (path[0] == '/') path++; + if (S_ISLNK(te->mode)) + modestr = "@"; + else if (S_ISDIR(te->mode)) + modestr = "/"; + else if (te->mode & S_IXUSR) + modestr = "*"; + printf("%s%s%s%s%s\n", id ? id : "", path, - is_root_path ? "" : "/", te->name, - S_ISDIR(te->mode) ? "/" : ((te->mode & S_IXUSR) ? "*" : "")); + is_root_path ? "" : "/", te->name, modestr); } static const struct got_error * blob - 701d0e9f0876b10269a09fbd8d963c4c79978dd5 blob + a7499aede5fa0e897dac864134c6ed03bccfef71 --- tog/tog.1 +++ tog/tog.1 @@ -242,6 +242,13 @@ If the .Ar repository path is omitted, assume the repository is located in the current working directory. .Pp +Displayed tree entries may carry one of the following trailing annotations: +.Bl -column YXZ description +.It @ Ta entry is a symbolic link +.It / Ta entry is a directory +.It * Ta entry is an executable file +.El +.Pp The key bindings for .Cm tog tree are as follows: blob - 9ff35534c9fef72dbc358e84d69dbf5206033331 blob + 9acbb83288278439a8f09ce722d49c2eb8619519 --- tog/tog.c +++ tog/tog.c @@ -3852,6 +3852,7 @@ draw_tree_entries(struct tog_view *view, while (te) { char *line = NULL, *id_str = NULL; + const char *modestr = ""; if (show_ids) { err = got_object_id_str(&id_str, te->id); @@ -3859,9 +3860,14 @@ draw_tree_entries(struct tog_view *view, return got_error_from_errno( "got_object_id_str"); } + if (S_ISLNK(te->mode)) + modestr = "@"; + else if (S_ISDIR(te->mode)) + modestr = "/"; + else if (te->mode & S_IXUSR) + modestr = "*"; if (asprintf(&line, "%s %s%s", id_str ? id_str : "", - te->name, S_ISDIR(te->mode) ? "/" : - ((te->mode & S_IXUSR) ? "*" : "")) == -1) { + te->name, modestr) == -1) { free(id_str); return got_error_from_errno("asprintf"); }