summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-07-28 15:25:45 -0400
committerJunio C Hamano <gitster@pobox.com>2017-07-28 15:51:56 -0700
commit2491f77b90c2e5d47acbe7472c17e7de0af74f63 (patch)
treeba20f55e5f188c839bb952f7b1a8428c370f9374 /cache.h
parent2d90add5ad216807ec1433e5367fae730e74a4cb (diff)
downloadgit-2491f77b90c2e5d47acbe7472c17e7de0af74f63.tar.gz
connect: factor out "looks like command line option" check
We reject hostnames that start with a dash because they may be confused for command-line options. Let's factor out that notion into a helper function, as we'll use it in more places. And while it's simple now, it's not clear if some systems might need more complex logic to handle all cases. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 1a2cec0b88..b9fc3a8e33 100644
--- a/cache.h
+++ b/cache.h
@@ -991,6 +991,14 @@ char *strip_path_suffix(const char *path, const char *suffix);
int daemon_avoid_alias(const char *path);
extern int is_ntfs_dotgit(const char *name);
+/*
+ * Returns true iff "str" could be confused as a command-line option when
+ * passed to a sub-program like "ssh". Note that this has nothing to do with
+ * shell-quoting, which should be handled separately; we're assuming here that
+ * the string makes it verbatim to the sub-program.
+ */
+int looks_like_command_line_option(const char *str);
+
/**
* Return a newly allocated string with the evaluation of
* "$XDG_CONFIG_HOME/git/$filename" if $XDG_CONFIG_HOME is non-empty, otherwise