diff options
author | Stefan Beller <sbeller@google.com> | 2016-05-31 17:27:59 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-01 11:32:53 -0700 |
commit | 44431df02459ec6c4d8c705dd15f376015407043 (patch) | |
tree | 0096ecbdc8ba778417223f98e647ee0ad5a2c759 /builtin | |
parent | submodule--helper: offer a consistent API (diff) | |
download | tgif-44431df02459ec6c4d8c705dd15f376015407043.tar.xz |
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')
-rw-r--r-- | builtin/submodule--helper.c | 12 |
1 files changed, 12 insertions, 0 deletions
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} |