diff options
| author | Junio C Hamano <gitster@pobox.com> | 2008-02-26 00:14:22 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2008-02-26 00:14:22 -0800 |
| commit | 2db511fdbdbe1c8aab80f4bc13f0df037bce8a33 (patch) | |
| tree | 23350997a56089356ccaeaa923a783378c198bf6 /copy.c | |
| parent | gitweb: Better cutting matched string and its context (diff) | |
| parent | Documentation/git-am.txt: Pass -r in the example invocation of rm -f .dotest (diff) | |
| download | git-2db511fdbdbe1c8aab80f4bc13f0df037bce8a33.tar.gz git-2db511fdbdbe1c8aab80f4bc13f0df037bce8a33.zip | |
Merge branch 'maint'
* maint:
Documentation/git-am.txt: Pass -r in the example invocation of rm -f .dotest
timezone_names[]: fixed the tz offset for New Zealand.
filter-branch documentation: non-zero exit status in command abort the filter
rev-parse: fix potential bus error with --parseopt option spec handling
Use a single implementation and API for copy_file()
Documentation/git-filter-branch: add a new msg-filter example
Correct fast-export file mode strings to match fast-import standard
Diffstat (limited to 'copy.c')
| -rw-r--r-- | copy.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -34,3 +34,24 @@ int copy_fd(int ifd, int ofd) close(ifd); return 0; } + +int copy_file(const char *dst, const char *src, int mode) +{ + int fdi, fdo, status; + + mode = (mode & 0111) ? 0777 : 0666; + if ((fdi = open(src, O_RDONLY)) < 0) + return fdi; + if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) { + close(fdi); + return fdo; + } + status = copy_fd(fdi, fdo); + if (close(fdo) != 0) + return error("%s: write error: %s", dst, strerror(errno)); + + if (!status && adjust_shared_perm(dst)) + return -1; + + return status; +} |
