aboutsummaryrefslogtreecommitdiff
path: root/src/fetch_git.c
diff options
context:
space:
mode:
authordacctal <dacctal@symlinx.net>2026-05-29 09:17:31 +0000
committerdacctal <dacctal@symlinx.net>2026-05-29 09:17:31 +0000
commit205d99d4c243c8f5ab60e61469d01c12b3cfcf88 (patch)
tree58952edb6a10d97c496a68177239d609a33ba65b /src/fetch_git.c
parent4b9bdde6d7fefbf988160d26b376d330de48c5bd (diff)
quiet mode
Diffstat (limited to 'src/fetch_git.c')
-rw-r--r--src/fetch_git.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/fetch_git.c b/src/fetch_git.c
index 85275d3..deb94ac 100644
--- a/src/fetch_git.c
+++ b/src/fetch_git.c
@@ -1,3 +1,4 @@
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -8,31 +9,39 @@
#include "vars.h"
int fetch_git(Pkg pkg) {
- pid_t pid = fork();
- if (pid == 0) {
- const char *argv[8];
- int i = 0;
- argv[i++] = "git";
- argv[i++] = "-c";
- argv[i++] = "advice.detachedHead=false";
- argv[i++] = "clone";
- if (strcmp(pkg.ver, "HEAD") != 0) {
- argv[i++] = "--branch";
- argv[i++] = pkg.ver;
- }
- argv[i++] = pkg.url;
- argv[i++] = pkg.src;
- argv[i] = NULL;
- execvp("git", (char *const *)argv);
- _exit(127);
+ pid_t pid = fork();
+ if (pid == 0) {
+ if (!is_verbose) {
+ int nullfd = open("/dev/null", O_WRONLY);
+ if (nullfd >= 0) {
+ dup2(nullfd, STDOUT_FILENO);
+ dup2(nullfd, STDERR_FILENO);
+ close(nullfd);
+ }
}
-
- int status;
- waitpid(pid, &status, 0);
- int result = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
- if (result != 0) {
- printf("clone failed\n");
+ const char *argv[8];
+ int i = 0;
+ argv[i++] = "git";
+ argv[i++] = "-c";
+ argv[i++] = "advice.detachedHead=false";
+ argv[i++] = "clone";
+ if (strcmp(pkg.ver, "HEAD") != 0) {
+ argv[i++] = "--branch";
+ argv[i++] = pkg.ver;
}
+ argv[i++] = pkg.url;
+ argv[i++] = pkg.src;
+ argv[i] = NULL;
+ execvp("git", (char *const *)argv);
+ _exit(127);
+ }
+
+ int status;
+ waitpid(pid, &status, 0);
+ int result = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+ if (result != 0) {
+ printf("clone failed\n");
+ }
- return result;
+ return result;
} \ No newline at end of file