From 44431df02459ec6c4d8c705dd15f376015407043 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 31 May 2016 17:27:59 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'builtin/submodule--helper.c') diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f0b2c4fe0b..926d205162 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} -- cgit v1.2.3