MCPcopy Index your code
hub / github.com/git/git / strbuf_getcwd

Function strbuf_getcwd

strbuf.c:609–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609int strbuf_getcwd(struct strbuf *sb)
610{
611 size_t oldalloc = sb->alloc;
612 size_t guessed_len = 128;
613
614 for (;; guessed_len *= 2) {
615 strbuf_grow(sb, guessed_len);
616 if (getcwd(sb->buf, sb->alloc)) {
617 strbuf_setlen(sb, strlen(sb->buf));
618 return 0;
619 }
620
621 /*
622 * If getcwd(3) is implemented as a syscall that falls
623 * back to a regular lookup using readdir(3) etc. then
624 * we may be able to avoid EACCES by providing enough
625 * space to the syscall as it's not necessarily bound
626 * to the same restrictions as the fallback.
627 */
628 if (errno == EACCES && guessed_len < PATH_MAX)
629 continue;
630
631 if (errno != ERANGE)
632 break;
633 }
634 if (oldalloc == 0)
635 strbuf_release(sb);
636 else
637 strbuf_reset(sb);
638 return -1;
639}
640
641#ifdef HAVE_GETDELIM
642int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term)

Callers 8

xgetcwdFunction · 0.85
unix_sockaddr_initFunction · 0.85
init_gitFunction · 0.85
chdir_notifyFunction · 0.85
strbuf_realpath_1Function · 0.85

Calls 3

strbuf_growFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected