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

Function copy_file

copy.c:38–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38int copy_file(const char *dst, const char *src, int mode)
39{
40 int fdi, fdo, status;
41
42 mode = (mode & 0111) ? 0777 : 0666;
43 if ((fdi = open(src, O_RDONLY)) < 0)
44 return fdi;
45 if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
46 close(fdi);
47 return fdo;
48 }
49 status = copy_fd(fdi, fdo);
50 switch (status) {
51 case COPY_READ_ERROR:
52 error_errno("copy-fd: read returned");
53 break;
54 case COPY_WRITE_ERROR:
55 error_errno("copy-fd: write returned");
56 break;
57 }
58 close(fdi);
59 if (close(fdo) != 0)
60 return error_errno("%s: close error", dst);
61
62 if (!status && adjust_shared_perm(the_repository, dst))
63 return -1;
64
65 return status;
66}
67
68int copy_file_with_time(const char *dst, const char *src, int mode)
69{

Callers 10

copy_templates_1Function · 0.85
copy_file_with_timeFunction · 0.85
do_pick_commitFunction · 0.85
error_failed_squashFunction · 0.85
do_rerere_one_pathFunction · 0.85
copy_uri_to_fileFunction · 0.85
files_copy_or_rename_refFunction · 0.85
copy_sparse_checkoutFunction · 0.85
run_dir_diffFunction · 0.85

Calls 3

copy_fdFunction · 0.85
error_errnoFunction · 0.85
adjust_shared_permFunction · 0.85

Tested by

no test coverage detected