From 8926f839720471cc86fd4f7c6371d63b8f71b91d Mon Sep 17 00:00:00 2001 From: dacctal <120422854+dacctal@users.noreply.github.com> Date: Wed, 21 Jan 2026 23:56:39 -0500 Subject: initial commit --- src/fetch_git.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/fetch_git.cc (limited to 'src/fetch_git.cc') diff --git a/src/fetch_git.cc b/src/fetch_git.cc new file mode 100644 index 0000000..3306e42 --- /dev/null +++ b/src/fetch_git.cc @@ -0,0 +1,24 @@ +#include + +#include "vars.cc" + +int fetch_git(Pkg pkg) { + std::string clone_cmds[] = { + "git -c advice.detachedHead=false clone --depth 1 " + pkg.url + " " + + pkg.src.c_str(), + "git -c advice.detachedHead=false clone --branch " + pkg.ver + + " --depth 1 " + pkg.url + " " + pkg.src.c_str()}; + if (strcmp(pkg.ver.c_str(), "HEAD") == 0) { + if (WEXITSTATUS(system(clone_cmds[0].c_str())) == 0x10) { + return 0; + } else { + return 1; + } + } else { + if (WEXITSTATUS(system(clone_cmds[1].c_str())) == 0x10) { + return 0; + } else { + return 1; + } + } +} -- cgit v1.2.3