summaryrefslogtreecommitdiff
path: root/builtin/pull.c
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-06-14 08:41:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-15 19:40:50 (GMT)
commit1e1ea69fa4e5fb20baefe9e5422527e971d56a86 (patch)
tree747254bde5fa4f5b1fc09cbf2a0672f61b87db8a /builtin/pull.c
parent85b343245b495a47f937007e1c0650f2070b9b4f (diff)
downloadgit-1e1ea69fa4e5fb20baefe9e5422527e971d56a86.zip
git-1e1ea69fa4e5fb20baefe9e5422527e971d56a86.tar.gz
git-1e1ea69fa4e5fb20baefe9e5422527e971d56a86.tar.bz2
pull: implement skeletal builtin pull
For the purpose of rewriting git-pull.sh into a C builtin, implement a skeletal builtin/pull.c that redirects to $GIT_EXEC_PATH/git-pull.sh if the environment variable _GIT_USE_BUILTIN_PULL is not defined. This allows us to fall back on the functional git-pull.sh when running the test suite for tests that depend on a working git-pull implementation. This redirection should be removed when all the features of git-pull.sh have been re-implemented in builtin/pull.c. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pull.c')
-rw-r--r--builtin/pull.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
new file mode 100644
index 0000000..cabeed4
--- /dev/null
+++ b/builtin/pull.c
@@ -0,0 +1,33 @@
+/*
+ * Builtin "git pull"
+ *
+ * Based on git-pull.sh by Junio C Hamano
+ *
+ * Fetch one or more remote refs and merge it/them into the current HEAD.
+ */
+#include "cache.h"
+#include "builtin.h"
+#include "parse-options.h"
+#include "exec_cmd.h"
+
+static const char * const pull_usage[] = {
+ NULL
+};
+
+static struct option pull_options[] = {
+ OPT_END()
+};
+
+int cmd_pull(int argc, const char **argv, const char *prefix)
+{
+ if (!getenv("_GIT_USE_BUILTIN_PULL")) {
+ const char *path = mkpath("%s/git-pull", git_exec_path());
+
+ if (sane_execvp(path, (char **)argv) < 0)
+ die_errno("could not exec %s", path);
+ }
+
+ argc = parse_options(argc, argv, prefix, pull_options, pull_usage, 0);
+
+ return 0;
+}