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

Function send_local_file

http-backend.c:188–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static void send_local_file(struct strbuf *hdr, const char *the_type,
189 const char *name)
190{
191 char *p = repo_git_path(the_repository, "%s", name);
192 size_t buf_alloc = 8192;
193 char *buf = xmalloc(buf_alloc);
194 int fd;
195 struct stat sb;
196
197 fd = open(p, O_RDONLY);
198 if (fd < 0)
199 not_found(hdr, "Cannot open '%s': %s", p, strerror(errno));
200 if (fstat(fd, &sb) < 0)
201 die_errno("Cannot stat '%s'", p);
202
203 hdr_int(hdr, content_length, sb.st_size);
204 hdr_str(hdr, content_type, the_type);
205 hdr_date(hdr, last_modified, sb.st_mtime);
206 end_headers(hdr);
207
208 for (;;) {
209 ssize_t n = xread(fd, buf, buf_alloc);
210 if (n < 0)
211 die_errno("Cannot read '%s'", p);
212 if (!n)
213 break;
214 write_or_die(1, buf, n);
215 }
216 close(fd);
217 free(buf);
218 free(p);
219}
220
221static void get_text_file(struct strbuf *hdr, char *name)
222{

Callers 4

get_text_fileFunction · 0.85
get_loose_objectFunction · 0.85
get_pack_fileFunction · 0.85
get_idx_fileFunction · 0.85

Calls 10

repo_git_pathFunction · 0.85
not_foundFunction · 0.85
die_errnoFunction · 0.85
hdr_intFunction · 0.85
hdr_strFunction · 0.85
hdr_dateFunction · 0.85
end_headersFunction · 0.85
xreadFunction · 0.85
write_or_dieFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected