aboutsummaryrefslogtreecommitdiff
path: root/builtin/fast-export.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-08-11 11:03:16 -0700
committerJunio C Hamano <gitster@pobox.com>2011-08-11 11:03:16 -0700
commitb81b758d5001c4ebab1a5b8202bb1b0f4cdf3391 (patch)
tree9ab6027c65d759e62f4a3b132fda954a324ef074 /builtin/fast-export.c
parent0e9b12f874955cba820efd786e176be8ba1acc2e (diff)
parent6280dfdc3b22aa821521182781e5a247b19fb515 (diff)
downloadgit-b81b758d5001c4ebab1a5b8202bb1b0f4cdf3391.tar.gz
git-b81b758d5001c4ebab1a5b8202bb1b0f4cdf3391.tar.xz
Merge branch 'jk/fast-export-quote-path'
* jk/fast-export-quote-path: fast-export: quote paths in output
Diffstat (limited to 'builtin/fast-export.c')
-rw-r--r--builtin/fast-export.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index becef8578..9836e6b7c 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -16,6 +16,7 @@
#include "string-list.h"
#include "utf8.h"
#include "parse-options.h"
+#include "quote.h"
static const char *fast_export_usage[] = {
"git fast-export [rev-list-opts]",
@@ -179,6 +180,15 @@ static int depth_first(const void *a_, const void *b_)
return (a->status == 'R') - (b->status == 'R');
}
+static void print_path(const char *path)
+{
+ int need_quote = quote_c_style(path, NULL, NULL, 0);
+ if (need_quote)
+ quote_c_style(path, NULL, stdout, 0);
+ else
+ printf("%s", path);
+}
+
static void show_filemodify(struct diff_queue_struct *q,
struct diff_options *options, void *data)
{
@@ -196,13 +206,18 @@ static void show_filemodify(struct diff_queue_struct *q,
switch (q->queue[i]->status) {
case DIFF_STATUS_DELETED:
- printf("D %s\n", spec->path);
+ printf("D ");
+ print_path(spec->path);
+ putchar('\n');
break;
case DIFF_STATUS_COPIED:
case DIFF_STATUS_RENAMED:
- printf("%c \"%s\" \"%s\"\n", q->queue[i]->status,
- ospec->path, spec->path);
+ printf("%c ", q->queue[i]->status);
+ print_path(ospec->path);
+ putchar(' ');
+ print_path(spec->path);
+ putchar('\n');
if (!hashcmp(ospec->sha1, spec->sha1) &&
ospec->mode == spec->mode)
@@ -217,13 +232,15 @@ static void show_filemodify(struct diff_queue_struct *q,
* output the SHA-1 verbatim.
*/
if (no_data || S_ISGITLINK(spec->mode))
- printf("M %06o %s %s\n", spec->mode,
- sha1_to_hex(spec->sha1), spec->path);
+ printf("M %06o %s ", spec->mode,
+ sha1_to_hex(spec->sha1));
else {
struct object *object = lookup_object(spec->sha1);
- printf("M %06o :%d %s\n", spec->mode,
- get_object_mark(object), spec->path);
+ printf("M %06o :%d ", spec->mode,
+ get_object_mark(object));
}
+ print_path(spec->path);
+ putchar('\n');
break;
default: