1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 04:10:07 +00:00

Merge commit '80ec734a953d930838ea6839923c97c3da880a0d'

This commit is contained in:
Roman Perepelitsa 2021-08-18 17:05:04 +02:00
commit ec44300155
6 changed files with 23 additions and 12 deletions

View file

@ -275,7 +275,14 @@ if [ ! -e "$libgit2_tarball" ]; then
fi fi
fi fi
libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
command wget -O "$libgit2_tmp" -- "$libgit2_url" if ! command wget -O "$libgit2_tmp" -- "$libgit2_url"; then
command which wget
command ls -lAd -- "$outdir"
command ls -lA -- "$outdir"
command ls -lAd -- "$outdir"/deps
command ls -lA -- "$outdir"/deps
exit 1
fi
command mv -f -- "$libgit2_tmp" "$libgit2_tarball" command mv -f -- "$libgit2_tmp" "$libgit2_tarball"
else else
>&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz" >&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz"

View file

@ -86,6 +86,7 @@ gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1
# On every prompt, fetch git status and set GITSTATUS_PROMPT. # On every prompt, fetch git status and set GITSTATUS_PROMPT.
PROMPT_COMMAND=gitstatus_prompt_update PROMPT_COMMAND=gitstatus_prompt_update
PROMPT_DIRTRIM=3
# Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded. # Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded.
shopt -s promptvars shopt -s promptvars

View file

@ -106,14 +106,14 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
}; };
constexpr size_t kBufSize = 8 << 10; constexpr size_t kBufSize = 8 << 10;
entries.clear(); const size_t orig_size = entries.size();
while (true) { while (true) {
char* buf = static_cast<char*>(arena.Allocate(kBufSize, alignof(linux_dirent64))); char* buf = static_cast<char*>(arena.Allocate(kBufSize, alignof(linux_dirent64)));
// Save 256 bytes for the rainy day. // Save 256 bytes for the rainy day.
int n = syscall(SYS_getdents64, dir_fd, buf, kBufSize - 256); int n = syscall(SYS_getdents64, dir_fd, buf, kBufSize - 256);
if (n < 0) { if (n < 0) {
entries.clear(); entries.resize(orig_size);
return false; return false;
} }
for (int pos = 0; pos < n;) { for (int pos = 0; pos < n;) {
@ -131,9 +131,9 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
} }
if (case_sensitive) { if (case_sensitive) {
SortEntries<true>(entries.data(), entries.data() + entries.size()); SortEntries<true>(entries.data() + orig_size, entries.data() + entries.size());
} else { } else {
SortEntries<false>(entries.data(), entries.data() + entries.size()); SortEntries<false>(entries.data() + orig_size, entries.data() + entries.size());
} }
return true; return true;
@ -211,7 +211,7 @@ char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) {
bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode, bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode,
bool case_sensitive) { bool case_sensitive) {
entries.clear(); const size_t orig_size = entries.size();
dir_fd = dup(dir_fd); dir_fd = dup(dir_fd);
if (dir_fd < 0) return false; if (dir_fd < 0) return false;
DIR* dir = fdopendir(dir_fd); DIR* dir = fdopendir(dir_fd);
@ -225,10 +225,10 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
entries.push_back(DirenvConvert(arena, *ent, precompose_unicode)); entries.push_back(DirenvConvert(arena, *ent, precompose_unicode));
} }
if (errno) { if (errno) {
entries.clear(); entries.resize(orig_size);
return false; return false;
} }
StrSort(entries.data(), entries.data() + entries.size(), case_sensitive); StrSort(entries.data() + orig_size, entries.data() + entries.size(), case_sensitive);
return true; return true;
} }

View file

@ -25,11 +25,11 @@
namespace gitstatus { namespace gitstatus {
// On error, clears entries and returns false. Does not throw. // On error, leaves entries unchaged and returns false. Does not throw.
// //
// On success, fills entries with the names of files from the specified directory and returns true. // On success, appends names of files from the specified directory to entries and returns true.
// Every entry is a null-terminated string. At -1 offset is its d_type. All elements point into the // Every appended entry is a null-terminated string. At -1 offset is its d_type. All elements
// arena. They are sorted either by strcmp or strcasecmp depending on case_sensitive. // point into the arena. They are sorted either by strcmp or strcasecmp depending on case_sensitive.
// //
// Does not close dir_fd. // Does not close dir_fd.
// //

View file

@ -242,6 +242,7 @@ std::vector<const char*> ScanDirs(git_index* index, int root_fd, IndexDir* const
dir.st = st; dir.st = st;
} }
entries.clear();
arena.Reuse(); arena.Reuse();
if (!ListDir(*dir_fd, arena, entries, caps.precompose_unicode, caps.case_sensitive)) { if (!ListDir(*dir_fd, arena, entries, caps.precompose_unicode, caps.case_sensitive)) {
AddUnmached(""); AddUnmached("");

View file

@ -155,6 +155,8 @@ void TagDb::ReadLooseTags() {
int dir_fd = open(dirname.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); int dir_fd = open(dirname.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) return; if (dir_fd < 0) return;
ON_SCOPE_EXIT(&) { CHECK(!close(dir_fd)) << Errno(); }; ON_SCOPE_EXIT(&) { CHECK(!close(dir_fd)) << Errno(); };
// TODO: recursively traverse directories so that the file refs/tags/foo/bar gets interpreted
// as the tag foo/bar. See https://github.com/romkatv/gitstatus/issues/254.
(void)ListDir(dir_fd, loose_arena_, loose_tags_, /* precompose_unicode = */ false, (void)ListDir(dir_fd, loose_arena_, loose_tags_, /* precompose_unicode = */ false,
/* case_sensitive = */ true); /* case_sensitive = */ true);
} }