merge-recursive: make "CONFLICT (rename/delete)" message show both paths
[gitweb.git] / tmp-objdir.c
index 9443868be1e0918d7855cd3e409941526adcefc9..b2d9280f104aec7095dd2b37ff1f7165355b5388 100644 (file)
@@ -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)
@@ -147,6 +163,8 @@ struct tmp_objdir *tmp_objdir_create(void)
        env_append(&t->env, ALTERNATE_DB_ENVIRONMENT,
                   absolute_path(get_object_directory()));
        env_replace(&t->env, DB_ENVIRONMENT, absolute_path(t->path.buf));
+       env_replace(&t->env, GIT_QUARANTINE_ENVIRONMENT,
+                   absolute_path(t->path.buf));
 
        return t;
 }
@@ -186,7 +204,7 @@ static int read_dir_paths(struct string_list *out, const char *path)
                return -1;
 
        while ((de = readdir(dh)))
-               if (!is_dot_or_dotdot(de->d_name))
+               if (de->d_name[0] != '.')
                        string_list_append(out, de->d_name);
 
        closedir(dh);