Index: head/devel/got/Makefile =================================================================== --- head/devel/got/Makefile (revision 550278) +++ head/devel/got/Makefile (revision 550279) @@ -1,31 +1,32 @@ # $FreeBSD$ PORTNAME= got PORTVERSION= 0.41 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= https://gameoftrees.org/releases/ MAINTAINER= naddy@FreeBSD.org COMMENT= Game of Trees version control system LICENSE= ISCL LICENSE_FILE= ${WRKSRC}/LICENCE USES= uidfix n= ${.newline} post-extract: @${FIND} ${WRKSRC} -name '*.[cy]' -exec \ ${REINPLACE_CMD} '1,/^#include "/{ \ /^#include "/i\$n#include "openbsd-compat.h"\$n$n}' \ {} + ${CP} -R ${FILESDIR}/openbsd-compat ${WRKSRC} # The regression test suite requires: # installed got # installed git # ssh to 127.0.0.1 run-test: @(cd ${WRKSRC}/regress && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} regress) .include Index: head/devel/got/files/patch-lib_worktree.c =================================================================== --- head/devel/got/files/patch-lib_worktree.c (revision 550278) +++ head/devel/got/files/patch-lib_worktree.c (nonexistent) @@ -1,50 +0,0 @@ ---- lib/worktree.c.orig 2020-09-25 11:58:47 UTC -+++ lib/worktree.c -@@ -1227,7 +1227,7 @@ replace_existing_symlink(const char *ondisk_path, cons - */ - fd = open(ondisk_path, O_RDWR | O_EXCL | O_NOFOLLOW); - if (fd == -1) { -- if (errno != ELOOP) -+ if (errno != ELOOP && errno != EMLINK) - return got_error_from_errno2("open", ondisk_path); - - /* We are updating an existing on-disk symlink. */ -@@ -1703,9 +1703,9 @@ get_file_status(unsigned char *status, struct stat *sb - } - } else { - fd = open(abspath, O_RDONLY | O_NOFOLLOW); -- if (fd == -1 && errno != ENOENT && errno != ELOOP) -+ if (fd == -1 && errno != ENOENT && errno != ELOOP && errno != EMLINK) - return got_error_from_errno2("open", abspath); -- else if (fd == -1 && errno == ELOOP) { -+ else if (fd == -1 && (errno == ELOOP || errno == EMLINK)) { - if (lstat(abspath, sb) == -1) - return got_error_from_errno2("lstat", abspath); - } else if (fd == -1 || fstat(fd, sb) == -1) { -@@ -3518,7 +3518,7 @@ worktree_status(struct got_worktree *worktree, const c - fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW | O_DIRECTORY); - if (fd == -1) { - if (errno != ENOTDIR && errno != ENOENT && errno != EACCES && -- errno != ELOOP) -+ errno != ELOOP && errno != EMLINK) - err = got_error_from_errno2("open", ondisk_path); - else - err = report_single_file_status(path, ondisk_path, -@@ -4190,7 +4190,7 @@ create_patched_content(char **path_outfile, int revers - if (dirfd2 != -1) { - fd2 = openat(dirfd2, de_name2, O_RDONLY | O_NOFOLLOW); - if (fd2 == -1) { -- if (errno != ELOOP) { -+ if (errno != ELOOP && errno != EMLINK) { - err = got_error_from_errno2("openat", path2); - goto done; - } -@@ -4204,7 +4204,7 @@ create_patched_content(char **path_outfile, int revers - } else { - fd2 = open(path2, O_RDONLY | O_NOFOLLOW); - if (fd2 == -1) { -- if (errno != ELOOP) { -+ if (errno != ELOOP && errno != EMLINK) { - err = got_error_from_errno2("open", path2); - goto done; - } Property changes on: head/devel/got/files/patch-lib_worktree.c ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/got/files/openbsd-compat/Makefile =================================================================== --- head/devel/got/files/openbsd-compat/Makefile (revision 550278) +++ head/devel/got/files/openbsd-compat/Makefile (revision 550279) @@ -1,14 +1,15 @@ LIB= openbsd-compat INTERNALLIB= SRCS= basename.c \ dirname.c \ freezero.c \ getdtablecount.c \ imsg.c \ imsg-buffer.c \ + open.c \ recallocarray.c CFLAGS+= -I${.CURDIR} .include Index: head/devel/got/files/openbsd-compat/open.c =================================================================== --- head/devel/got/files/openbsd-compat/open.c (nonexistent) +++ head/devel/got/files/openbsd-compat/open.c (revision 550279) @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020 Christian Weisgerber + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +/* + * POSIX mandates that open(symlink, O_NOFOLLOW) fail with errno == ELOOP. + * FreeBSD chooses to deviate from this, but Got depends on it. + */ +int +open_posix(const char *path, int flags, ...) +{ + va_list ap; + mode_t mode; + int ret; + + if (flags & O_CREAT) { + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + ret = open(path, flags, mode); + } else + ret = open(path, flags); + + if (ret == -1 && (flags & O_NOFOLLOW) && errno == EMLINK) + errno = ELOOP; + + return (ret); +} + +int +openat_posix(int fd, const char *path, int flags, ...) +{ + va_list ap; + mode_t mode; + int ret; + + if (flags & O_CREAT) { + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + ret = openat(fd, path, flags, mode); + } else + ret = openat(fd, path, flags); + + if (ret == -1 && (flags & O_NOFOLLOW) && errno == EMLINK) + errno = ELOOP; + + return (ret); +} Property changes on: head/devel/got/files/openbsd-compat/open.c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +on \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/got/files/openbsd-compat/openbsd-compat.h =================================================================== --- head/devel/got/files/openbsd-compat/openbsd-compat.h (revision 550278) +++ head/devel/got/files/openbsd-compat/openbsd-compat.h (revision 550279) @@ -1,78 +1,87 @@ /* * Compatibility mappings for system headers and * prototypes for functions in libopenbsd-compat. */ #ifndef _OPENBSD_COMPAT_H_ #define _OPENBSD_COMPAT_H_ /* * */ #define __dead __dead2 /* * */ #define SIMPLEQ_HEAD(name, type) \ STAILQ_HEAD(name, type) #define SIMPLEQ_HEAD_INITIALIZER(head) \ STAILQ_HEAD_INITIALIZER(head) #define SIMPLEQ_ENTRY(type) \ STAILQ_ENTRY(type) #define SIMPLEQ_FIRST(head) \ STAILQ_FIRST(head) #define SIMPLEQ_END(head) \ NULL #define SIMPLEQ_EMPTY(head) \ STAILQ_EMPTY(head) #define SIMPLEQ_NEXT(elm, field) \ STAILQ_NEXT(elm, field) #define SIMPLEQ_FOREACH(var, head, field) \ STAILQ_FOREACH(var, head, field) #define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ STAILQ_FOREACH_SAFE(var, head, field, tvar) #define SIMPLEQ_INIT(head) \ STAILQ_INIT(head) #define SIMPLEQ_INSERT_HEAD(head, elm, field) \ STAILQ_INSERT_HEAD(head, elm, field) #define SIMPLEQ_INSERT_TAIL(head, elm, field) \ STAILQ_INSERT_TAIL(head, elm, field) #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \ STAILQ_INSERT_AFTER(head, listelm, elm, field) #define SIMPLEQ_REMOVE_HEAD(head, field) \ STAILQ_REMOVE_HEAD(head, field) #define SIMPLEQ_REMOVE_AFTER(head, elm, field) \ STAILQ_REMOVE_AFTER(head, elm, field) #define SIMPLEQ_CONCAT(head1, head2) \ STAILQ_CONCAT(head1, head2) /* + * + */ +#define open(...) open_posix(__VA_ARGS__) +#define openat(...) openat_posix(__VA_ARGS__) + +int open_posix(const char *path, int flags, ...); +int openat_posix(int fd, const char *path, int flags, ...); + +/* * */ #undef basename #undef dirname #define basename(path) basename_const(path) #define dirname(path) dirname_const(path) char *basename(const char *); char *dirname(const char *); /* * */ void freezero(void *, size_t); void *recallocarray(void *, size_t, size_t, size_t); /* * */ int getdtablecount(void); /* void -> int */ #define closefrom(fd) (closefrom(fd), 0) #define pledge(promises, execpromises) 0 #define unveil(path, permissions) 0 #endif /* _OPENBSD_COMPAT_H_ */ Index: head/devel/got/files/patch-got_got.c =================================================================== --- head/devel/got/files/patch-got_got.c (revision 550278) +++ head/devel/got/files/patch-got_got.c (revision 550279) @@ -1,53 +1,35 @@ --- got/got.c.orig 2020-09-25 11:58:47 UTC +++ got/got.c @@ -215,7 +215,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - optind = 0; + optind = 1; + optreset = 1; if (Vflag) { got_version_print_str(); -@@ -4022,7 +4023,7 @@ print_diff(void *arg, unsigned char status, unsigned c - if (dirfd != -1) { - fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW); - if (fd == -1) { -- if (errno != ELOOP) { -+ if (errno != ELOOP && errno != EMLINK) { - err = got_error_from_errno2("openat", - abspath); - goto done; -@@ -4035,7 +4036,7 @@ print_diff(void *arg, unsigned char status, unsigned c - } else { - fd = open(abspath, O_RDONLY | O_NOFOLLOW); - if (fd == -1) { -- if (errno != ELOOP) { -+ if (errno != ELOOP && errno != EMLINK) { - err = got_error_from_errno2("open", - abspath); - goto done; @@ -9421,11 +9422,11 @@ cat_commit(struct got_object_id *id, struct got_reposi } fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_AUTHOR, got_object_commit_get_author(commit), - got_object_commit_get_author_time(commit)); + (long long)got_object_commit_get_author_time(commit)); fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_COMMITTER, got_object_commit_get_author(commit), - got_object_commit_get_committer_time(commit)); + (long long)got_object_commit_get_committer_time(commit)); logmsg = got_object_commit_get_logmsg_raw(commit); fprintf(outfile, "messagelen %zd\n", strlen(logmsg)); @@ -9480,7 +9481,7 @@ cat_tag(struct got_object_id *id, struct got_repositor fprintf(outfile, "%s%s %lld +0000\n", GOT_TAG_LABEL_TAGGER, got_object_tag_get_tagger(tag), - got_object_tag_get_tagger_time(tag)); + (long long)got_object_tag_get_tagger_time(tag)); tagmsg = got_object_tag_get_message(tag); fprintf(outfile, "messagelen %zd\n", strlen(tagmsg)); Index: head/devel/got/files/patch-lib_object__create.c =================================================================== --- head/devel/got/files/patch-lib_object__create.c (revision 550278) +++ head/devel/got/files/patch-lib_object__create.c (revision 550279) @@ -1,44 +1,35 @@ --- lib/object_create.c.orig 2020-09-25 11:58:47 UTC +++ lib/object_create.c -@@ -131,7 +131,7 @@ got_object_blob_file_create(struct got_object_id **id, - - fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW); - if (fd == -1) { -- if (errno != ELOOP) -+ if (errno != ELOOP && errno != EMLINK) - return got_error_from_errno2("open", ondisk_path); - - if (lstat(ondisk_path, &sb) == -1) { @@ -144,7 +144,7 @@ got_object_blob_file_create(struct got_object_id **id, } if (asprintf(&header, "%s %lld", GOT_OBJ_LABEL_BLOB, - sb.st_size) == -1) { + (long long)sb.st_size) == -1) { err = got_error_from_errno("asprintf"); goto done; } @@ -440,12 +440,12 @@ got_object_commit_create(struct got_object_id **id, } if (asprintf(&author_str, "%s%s %lld +0000\n", - GOT_COMMIT_LABEL_AUTHOR, author, author_time) == -1) + GOT_COMMIT_LABEL_AUTHOR, author, (long long)author_time) == -1) return got_error_from_errno("asprintf"); if (asprintf(&committer_str, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_COMMITTER, committer ? committer : author, - committer ? committer_time : author_time) + (long long)(committer ? committer_time : author_time)) == -1) { err = got_error_from_errno("asprintf"); goto done; @@ -646,7 +646,7 @@ got_object_tag_create(struct got_object_id **id, } if (asprintf(&tagger_str, "%s%s %lld +0000\n", - GOT_TAG_LABEL_TAGGER, tagger, tagger_time) == -1) + GOT_TAG_LABEL_TAGGER, tagger, (long long)tagger_time) == -1) return got_error_from_errno("asprintf"); msg0 = strdup(tagmsg);