Files
RedBear-OS/recipes/dev/git/git.patch
T
vasilito 45696b918b git: re-port git.patch onto 2.55.0
The patch was written against git 2.13.1 (2017) while the recipe fetches
2.55.0 — eight years of drift, seven of eight files rejecting. Rebased by
applying what still fit, hand-porting every reject against the current
source, and regenerating the whole patch from a pristine-vs-ported diff so
it is a coherent 2.55.0 patch rather than a 2.13 patch with fixups.

Per file, preserving the original Redox intent:
  compat/bswap.h      <machine/endian.h> for ntohl/htonl
  compat/terminal.c   __redox__ git_terminal_prompt branch; the file was
                      restructured, so it now precedes the generic #else
  configure           NO_IPV6=YesPlease
  daemon.c            logreport is a switch over LOG_DESTINATION_* in
                      2.55.0; guard the syslog arm and openlog instead of
                      the old if/else
  git-compat-util.h   SIG_DFL/SIG_IGN/SIG_ERR fallbacks
  Makefile            EXTLIBS=-lnghttp2; drop the three hardlink fallbacks
  run-command.c       dup_devnull is gone in 2.55.0; the four /dev/null
                      opens it replaced now use DEV_NULL directly
  setup.c             sanitize_stdfds uses xopen/xdup, which die
                      internally, so the old die_errno hunk is obsolete

Applies at --fuzz=0 with zero rejects across all eight files.

Also ac_cv_iconv_omits_bom=no: the 'iconv omits bom for utf-16 and
utf-32' probe is a RUN test and cannot execute while cross compiling.
Same mechanism as the neighbouring ac_cv_fread_reads_directories and
ac_cv_snprintf_returns_bogus entries.

One trap worth recording: a blanket '*.orig' cleanup before regenerating
the diff silently deleted t/t4256/1/mailinfo.c.orig, a real git test
fixture, which would have shipped as a deletion in the patch. Restored.
2026-08-03 20:16:12 +03:00

243 lines
6.3 KiB
Diff

diff -ruwN git-2.55.0/compat/bswap.h source/compat/bswap.h
--- git-2.55.0/compat/bswap.h 2026-06-29 19:32:26.000000000 +0300
+++ source/compat/bswap.h 2026-08-03 20:12:56.784770887 +0300
@@ -1,3 +1,7 @@
+#if defined(__redox__)
+#include <machine/endian.h>
+#endif
+
#ifndef COMPAT_BSWAP_H
#define COMPAT_BSWAP_H
diff -ruwN git-2.55.0/compat/terminal.c source/compat/terminal.c
--- git-2.55.0/compat/terminal.c 2026-06-29 19:32:26.000000000 +0300
+++ source/compat/terminal.c 2026-08-03 20:13:34.879634242 +0300
@@ -581,6 +581,18 @@
return 0;
}
+#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
int save_term(enum save_term_flags flags)
diff -ruwN git-2.55.0/configure source/configure
--- git-2.55.0/configure 2026-06-29 19:32:26.000000000 +0300
+++ source/configure 2026-08-03 20:12:56.785551812 +0300
@@ -6743,7 +6743,7 @@
if test "$ac_res" != no
then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- NO_IPV6=
+ NO_IPV6=YesPlease
else case e in #(
e) NO_IPV6=YesPlease ;;
esac
diff -ruwN git-2.55.0/daemon.c source/daemon.c
--- git-2.55.0/daemon.c 2026-06-29 19:32:26.000000000 +0300
+++ source/daemon.c 2026-08-03 20:14:13.921828994 +0300
@@ -98,7 +98,9 @@
case LOG_DESTINATION_SYSLOG: {
char buf[1024];
vsnprintf(buf, sizeof(buf), err, params);
+#if !defined(__redox__)
syslog(priority, "%s", buf);
+#endif
break;
}
case LOG_DESTINATION_STDERR:
@@ -937,8 +939,12 @@
if (!reuseaddr)
return 0;
+#if defined(__redox__)
+ return 0;
+#else
return setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on));
+#endif
}
struct socketlist {
@@ -1227,11 +1233,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;
@@ -1425,7 +1427,9 @@
}
if (log_destination == LOG_DESTINATION_SYSLOG) {
+#if !defined(__redox__)
openlog("git-daemon", LOG_PID, LOG_DAEMON);
+#endif
set_die_routine(daemon_die);
} else
/* avoid splitting a message in the middle */
diff -ruwN git-2.55.0/git-compat-util.h source/git-compat-util.h
--- git-2.55.0/git-compat-util.h 2026-06-29 19:32:26.000000000 +0300
+++ source/git-compat-util.h 2026-08-03 20:12:56.784854904 +0300
@@ -1,6 +1,18 @@
#ifndef GIT_COMPAT_UTIL_H
#define GIT_COMPAT_UTIL_H
+#ifndef SIG_DFL
+#define SIG_DFL ((void (*)(int))0)
+#endif
+
+#ifndef SIG_IGN
+#define SIG_IGN ((void (*)(int))1)
+#endif
+
+#ifndef SIG_ERR
+#define SIG_ERR ((void (*)(int))-1)
+#endif
+
#if __STDC_VERSION__ - 0 < 199901L
/*
* Git is in a testing period for mandatory C99 support in the compiler. If
@@ -202,6 +214,14 @@
#define PATH_SEP ':'
#endif
+#ifndef DEV_NULL
+#if defined(__redox__)
+#define DEV_NULL "/scheme/null"
+#else
+#define DEV_NULL "/dev/null"
+#endif
+#endif
+
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
diff -ruwN git-2.55.0/Makefile source/Makefile
--- git-2.55.0/Makefile 2026-06-29 19:32:26.000000000 +0300
+++ source/Makefile 2026-08-03 20:13:34.880603012 +0300
@@ -952,7 +952,7 @@
endif
GITLIBS = common-main.o $(LIB_FILE)
-EXTLIBS =
+EXTLIBS = -lnghttp2
GIT_USER_AGENT = git/$(GIT_VERSION)
@@ -2688,7 +2688,6 @@
$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && \
- ln $< $@ 2>/dev/null || \
ln -s $< $@ 2>/dev/null || \
cp $< $@
@@ -3002,7 +3001,6 @@
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
$(QUIET_LNCP)$(RM) $@ && \
- ln $< $@ 2>/dev/null || \
ln -s $< $@ 2>/dev/null || \
cp $< $@
@@ -3701,7 +3699,6 @@
test -n "$(INSTALL_SYMLINKS)" && \
ln -s "git$X" "$$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 && \
@@ -3712,7 +3709,6 @@
test -n "$(INSTALL_SYMLINKS)" && \
ln -s "$$destdir_from_execdir_SQ/$(bindir_relative_SQ)/git$X" "$$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; }; \
fi \
@@ -3723,7 +3719,6 @@
test -n "$(INSTALL_SYMLINKS)" && \
ln -s "git-remote-http$X" "$$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 -ruwN git-2.55.0/run-command.c source/run-command.c
--- git-2.55.0/run-command.c 2026-06-29 19:32:26.000000000 +0300
+++ source/run-command.c 2026-08-03 20:13:34.879491326 +0300
@@ -768,7 +768,7 @@
notify_pipe[0] = notify_pipe[1] = -1;
if (cmd->no_stdin || cmd->no_stdout || cmd->no_stderr) {
- null_fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
+ null_fd = xopen(DEV_NULL, O_RDWR | O_CLOEXEC);
set_cloexec(null_fd);
}
@@ -915,21 +915,21 @@
struct strvec nargv = STRVEC_INIT;
if (cmd->no_stdin)
- fhin = open("/dev/null", O_RDWR);
+ fhin = open(DEV_NULL, O_RDWR);
else if (need_in)
fhin = dup(fdin[0]);
else if (cmd->in)
fhin = dup(cmd->in);
if (cmd->no_stderr)
- fherr = open("/dev/null", O_RDWR);
+ fherr = open(DEV_NULL, O_RDWR);
else if (need_err)
fherr = dup(fderr[1]);
else if (cmd->err > 2)
fherr = dup(cmd->err);
if (cmd->no_stdout)
- fhout = open("/dev/null", O_RDWR);
+ fhout = open(DEV_NULL, O_RDWR);
else if (cmd->stdout_to_stderr)
fhout = dup(fherr);
else if (need_out)
diff -ruwN git-2.55.0/setup.c source/setup.c
--- git-2.55.0/setup.c 2026-06-29 19:32:26.000000000 +0300
+++ source/setup.c 2026-08-03 20:11:54.415632841 +0300
@@ -2176,7 +2176,7 @@
/* if any standard file descriptor is missing open it to /dev/null */
void sanitize_stdfds(void)
{
- int fd = xopen("/dev/null", O_RDWR);
+ int fd = xopen(DEV_NULL, O_RDWR);
while (fd < 2)
fd = xdup(fd);
if (fd > 2)
@@ -2211,8 +2211,10 @@
reassign_tempfile_ownership(parent_pid, child_pid);
exit(0);
}
+#if !defined(__redox__)
if (setsid() == -1)
die_errno(_("setsid failed"));
+#endif
close(0);
close(1);
close(2);