redox/recipes/git/git.patch
2019-03-31 15:07:59 -06:00

244 lines
6.2 KiB
Diff

diff -ruw source/compat/terminal.c source-new/compat/terminal.c
--- source/compat/terminal.c 2017-06-04 19:08:11.000000000 -0600
+++ source-new/compat/terminal.c 2019-03-13 14:50:29.028179965 -0600
@@ -137,6 +137,18 @@
return buf.buf;
}
+#elif defined(__redox__)
+
+ssize_t __getline(char **lptr, size_t *n, FILE *fp);
+
+char *git_terminal_prompt(const char *prompt, int echo)
+{
+ char *line = NULL;
+ size_t n = 0;
+ __getline(&line, &n, stdin);
+ return line; // XXX leak
+}
+
#else
char *git_terminal_prompt(const char *prompt, int echo)
diff -ruw source/configure source-new/configure
--- source/configure 2017-06-04 19:08:11.000000000 -0600
+++ source-new/configure 2019-03-27 19:53:37.398482599 -0600
@@ -6156,7 +6156,7 @@
ac_res=$ac_cv_search_getaddrinfo
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- NO_IPV6=
+ NO_IPV6=YesPlease
else
NO_IPV6=YesPlease
fi
diff -ruw source/daemon.c source-new/daemon.c
--- source/daemon.c 2017-06-04 19:08:11.000000000 -0600
+++ source-new/daemon.c 2019-03-13 14:50:29.028179965 -0600
@@ -71,13 +71,21 @@
return hi->ip_address.buf;
}
+#if defined(__redox__)
+#define LOG_ERR 0
+#define LOG_INFO 1
+#endif
+
static void logreport(int priority, const char *err, va_list params)
{
+#if !defined(__redox__)
if (log_syslog) {
char buf[1024];
vsnprintf(buf, sizeof(buf), err, params);
syslog(priority, "%s", buf);
- } else {
+ } else
+#endif
+ {
/*
* Since stderr is set to buffered mode, the
* logging of different processes will not overlap
@@ -888,8 +896,12 @@
if (!reuseaddr)
return 0;
+#if defined(__redox__)
+ return 0;
+#else
return setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on));
+#endif
}
struct socketlist {
@@ -1174,11 +1186,7 @@
if (!group_name)
c.gid = c.pass->pw_gid;
else {
- struct group *group = getgrnam(group_name);
- if (!group)
die("group not found - %s", group_name);
-
- c.gid = group->gr_gid;
}
return &c;
@@ -1348,10 +1356,12 @@
usage(daemon_usage);
}
+#if !defined(__redox__)
if (log_syslog) {
openlog("git-daemon", LOG_PID, LOG_DAEMON);
set_die_routine(daemon_die);
} else
+#endif
/* avoid splitting a message in the middle */
setvbuf(stderr, NULL, _IOFBF, 4096);
diff -ruw source/git-compat-util.h source-new/git-compat-util.h
--- source/git-compat-util.h 2017-06-04 19:08:11.000000000 -0600
+++ source-new/git-compat-util.h 2019-03-13 15:56:28.419769725 -0600
@@ -179,7 +179,9 @@
#include <assert.h>
#include <regex.h>
#include <utime.h>
+#if !defined(__redox__)
#include <syslog.h>
+#endif
#ifndef NO_SYS_POLL_H
#include <sys/poll.h>
#else
@@ -320,8 +322,20 @@
#endif
#ifndef PATH_SEP
+#if defined(__redox__)
+#define PATH_SEP ';'
+#else
#define PATH_SEP ':'
#endif
+#endif
+
+#ifndef DEV_NULL
+#if defined(__redox__)
+#define DEV_NULL "null:"
+#else
+#define DEV_NULL "/dev/null"
+#endif
+#endif
#ifdef HAVE_PATHS_H
#include <paths.h>
diff -ruw source/Makefile source-new/Makefile
--- source/Makefile 2017-06-04 19:08:11.000000000 -0600
+++ source-new/Makefile 2019-03-13 14:50:29.028179965 -0600
@@ -1802,7 +1802,6 @@
$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && \
- ln $< $@ 2>/dev/null || \
ln -s $< $@ 2>/dev/null || \
cp $< $@
@@ -2096,7 +2095,6 @@
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
$(QUIET_LNCP)$(RM) $@ && \
- ln $< $@ 2>/dev/null || \
ln -s $< $@ 2>/dev/null || \
cp $< $@
@@ -2449,14 +2447,12 @@
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
$(RM) "$$bindir/$$p" && \
test -z "$(NO_INSTALL_HARDLINKS)" && \
- ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
done && \
for p in $(BUILT_INS); do \
$(RM) "$$execdir/$$p" && \
test -z "$(NO_INSTALL_HARDLINKS)" && \
- ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
done && \
@@ -2464,7 +2460,6 @@
for p in $$remote_curl_aliases; do \
$(RM) "$$execdir/$$p" && \
test -z "$(NO_INSTALL_HARDLINKS)" && \
- ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
done && \
diff -ruw source/run-command.c source-new/run-command.c
--- source/run-command.c 2017-06-04 19:08:11.000000000 -0600
+++ source-new/run-command.c 2019-03-13 15:56:57.331276675 -0600
@@ -120,9 +120,9 @@
#ifndef GIT_WINDOWS_NATIVE
static inline void dup_devnull(int to)
{
- int fd = open("/dev/null", O_RDWR);
+ int fd = open(DEV_NULL, O_RDWR);
if (fd < 0)
- die_errno(_("open /dev/null failed"));
+ die_errno(_("open %s failed"), DEV_NULL);
if (dup2(fd, to) < 0)
die_errno(_("dup2(%d,%d) failed"), fd, to);
close(fd);
@@ -138,7 +138,7 @@
return NULL;
while (1) {
- const char *end = strchrnul(p, ':');
+ const char *end = strchrnul(p, PATH_SEP);
strbuf_reset(&buf);
diff -ruw source/setup.c source-new/setup.c
--- source/setup.c 2017-06-04 19:08:11.000000000 -0600
+++ source-new/setup.c 2019-03-13 14:50:29.028179965 -0600
@@ -1146,11 +1146,11 @@
/* if any standard file descriptor is missing open it to /dev/null */
void sanitize_stdfds(void)
{
- int fd = open("/dev/null", O_RDWR, 0);
+ int fd = open(DEV_NULL, O_RDWR, 0);
while (fd != -1 && fd < 2)
fd = dup(fd);
if (fd == -1)
- die_errno("open /dev/null or dup failed");
+ die_errno("open %s or dup failed", DEV_NULL);
if (fd > 2)
close(fd);
}
@@ -1169,8 +1169,10 @@
default:
exit(0);
}
+#if !defined(__redox__)
if (setsid() == -1)
die_errno("setsid failed");
+#endif
close(0);
close(1);
close(2);
diff -ruw source/strbuf.c source-new/strbuf.c
--- source/strbuf.c 2017-06-04 19:08:11.000000000 -0600
+++ source-new/strbuf.c 2019-03-13 14:50:29.028179965 -0600
@@ -446,6 +446,13 @@
for (;; guessed_len *= 2) {
strbuf_grow(sb, guessed_len);
if (getcwd(sb->buf, sb->alloc)) {
+#if defined(__redox__)
+ if (strncmp(sb->buf, "file:", 5) == 0) {
+ char *x = strdup(sb->buf);
+ strcpy(sb->buf, x+5);
+ free(x);
+ }
+#endif
strbuf_setlen(sb, strlen(sb->buf));
return 0;
}