aboutsummaryrefslogtreecommitdiff
path: root/tmp-objdir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-01-17 15:11:06 -0800
committerJunio C Hamano <gitster@pobox.com>2017-01-17 15:11:06 -0800
commitbcaf277b4ad5b7173a011d93a2ea1827f990f466 (patch)
tree9297f77eb13e7cc7291fb07006b18d2faf902ae9 /tmp-objdir.c
parentfdfec7af4617f63e671e638ba79d79a75c3d481b (diff)
parent5e74824fac646e2ebe335a00bcecd91641a7f7ca (diff)
downloadgit-bcaf277b4ad5b7173a011d93a2ea1827f990f466.tar.gz
git-bcaf277b4ad5b7173a011d93a2ea1827f990f466.tar.xz
Merge branch 'jk/quote-env-path-list-component' into maint
A recent update to receive-pack to make it easier to drop garbage objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot have a pathname with a colon in it (no surprise!), and this in turn made it impossible to push into a repository at such a path. This has been fixed by introducing a quoting mechanism used when appending such a path to the colon-separated list. * jk/quote-env-path-list-component: t5615-alternate-env: double-quotes in file names do not work on Windows t5547-push-quarantine: run the path separator test on Windows, too tmp-objdir: quote paths we add to alternates alternates: accept double-quoted paths
Diffstat (limited to 'tmp-objdir.c')
-rw-r--r--tmp-objdir.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tmp-objdir.c b/tmp-objdir.c
index 64435f23a..b2d9280f1 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -5,6 +5,7 @@
#include "string-list.h"
#include "strbuf.h"
#include "argv-array.h"
+#include "quote.h"
struct tmp_objdir {
struct strbuf path;
@@ -79,12 +80,27 @@ static void remove_tmp_objdir_on_signal(int signo)
*/
static void env_append(struct argv_array *env, const char *key, const char *val)
{
- const char *old = getenv(key);
+ struct strbuf quoted = STRBUF_INIT;
+ const char *old;
+ /*
+ * Avoid quoting if it's not necessary, for maximum compatibility
+ * with older parsers which don't understand the quoting.
+ */
+ if (*val == '"' || strchr(val, PATH_SEP)) {
+ strbuf_addch(&quoted, '"');
+ quote_c_style(val, &quoted, NULL, 1);
+ strbuf_addch(&quoted, '"');
+ val = quoted.buf;
+ }
+
+ old = getenv(key);
if (!old)
argv_array_pushf(env, "%s=%s", key, val);
else
argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
+
+ strbuf_release(&quoted);
}
static void env_replace(struct argv_array *env, const char *key, const char *val)