diff options
| author | dacctal <120422854+dacctal@users.noreply.github.com> | 2026-01-21 23:56:39 -0500 |
|---|---|---|
| committer | dacctal <120422854+dacctal@users.noreply.github.com> | 2026-01-21 23:56:39 -0500 |
| commit | 8926f839720471cc86fd4f7c6371d63b8f71b91d (patch) | |
| tree | c14523954085f7b6c428a488f81bfb645dcd2c83 /src/fetch_git.cc | |
| parent | 8fc3b1f6cd1062e15c0aed60a110fb91143cd801 (diff) | |
initial commit
Diffstat (limited to 'src/fetch_git.cc')
| -rw-r--r-- | src/fetch_git.cc | 24 |
1 files changed, 24 insertions, 0 deletions
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 <cstring> + +#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; + } + } +} |
