summaryrefslogtreecommitdiff
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-06-01 00:27:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-01 18:32:53 (GMT)
commit44431df02459ec6c4d8c705dd15f376015407043 (patch)
tree0096ecbdc8ba778417223f98e647ee0ad5a2c759 /builtin/submodule--helper.c
parentb0f4b4084626ab0f87611acd89030e8bdf0b850e (diff)
downloadgit-44431df02459ec6c4d8c705dd15f376015407043.zip
git-44431df02459ec6c4d8c705dd15f376015407043.tar.gz
git-44431df02459ec6c4d8c705dd15f376015407043.tar.bz2
submodule: remove bashism from shell script
Junio pointed out `relative_path` was using bashisms via the local variables. As the longer term goal is to rewrite most of the submodule code in C, do it now. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index f0b2c4f..926d205 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -831,6 +831,17 @@ static int update_clone(int argc, const char **argv, const char *prefix)
return 0;
}
+static int resolve_relative_path(int argc, const char **argv, const char *prefix)
+{
+ struct strbuf sb = STRBUF_INIT;
+ if (argc != 3)
+ die("submodule--helper relative_path takes exactly 2 arguments, got %d", argc);
+
+ printf("%s", relative_path(argv[1], argv[2], &sb));
+ strbuf_release(&sb);
+ return 0;
+}
+
struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **, const char *);
@@ -841,6 +852,7 @@ static struct cmd_struct commands[] = {
{"name", module_name},
{"clone", module_clone},
{"update-clone", update_clone},
+ {"relative-path", resolve_relative_path},
{"resolve-relative-url", resolve_relative_url},
{"resolve-relative-url-test", resolve_relative_url_test},
{"init", module_init}