MCPcopy Create free account
hub / github.com/git/git / strbuf_add_absolute_path

Function strbuf_add_absolute_path

abspath.c:293–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void strbuf_add_absolute_path(struct strbuf *sb, const char *path)
294{
295 if (!*path)
296 die("The empty string is not a valid path");
297 if (!is_absolute_path(path)) {
298 struct stat cwd_stat, pwd_stat;
299 size_t orig_len = sb->len;
300 char *cwd = xgetcwd();
301 char *pwd = getenv("PWD");
302 if (pwd && strcmp(pwd, cwd) &&
303 !stat(cwd, &cwd_stat) &&
304 (cwd_stat.st_dev || cwd_stat.st_ino) &&
305 !stat(pwd, &pwd_stat) &&
306 pwd_stat.st_dev == cwd_stat.st_dev &&
307 pwd_stat.st_ino == cwd_stat.st_ino)
308 strbuf_addstr(sb, pwd);
309 else
310 strbuf_addstr(sb, cwd);
311 if (sb->len > orig_len && !is_dir_sep(sb->buf[sb->len - 1]))
312 strbuf_addch(sb, '/');
313 free(cwd);
314 }
315 strbuf_addstr(sb, path);
316}
317
318void strbuf_add_real_path(struct strbuf *sb, const char *path)
319{

Callers 15

include_by_gitdirFunction · 0.85
add_pathFunction · 0.85
create_tempfile_modeFunction · 0.85
register_tempfileFunction · 0.85
mks_tempfile_smFunction · 0.85
xmks_tempfile_mFunction · 0.85
absolute_pathFunction · 0.85
absolute_pathdupFunction · 0.85
loose_objs_statsFunction · 0.85

Calls 6

is_absolute_pathFunction · 0.85
xgetcwdFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addchFunction · 0.85
dieFunction · 0.70
statClass · 0.70

Tested by

no test coverage detected