From: Junio C Hamano Date: Mon, 9 Jul 2012 16:02:06 +0000 (-0700) Subject: Merge branch 'js/fast-export-paths-with-spaces' X-Git-Tag: v1.7.12-rc0~52 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f8a9eafb4895935be6c9debf02a9b04339488bf0?hp=-c Merge branch 'js/fast-export-paths-with-spaces' "git fast-export" produced an input stream for fast-import without properly quoting pathnames when they contain SPs in them. * js/fast-export-paths-with-spaces: fast-export: quote paths with spaces --- f8a9eafb4895935be6c9debf02a9b04339488bf0 diff --combined builtin/fast-export.c index ef7c012094,e8a07c95e1..9ab6db3fb0 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@@ -25,7 -25,7 +25,7 @@@ static const char *fast_export_usage[] static int progress; static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT; -static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT; +static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR; static int fake_missing_tagger; static int use_done_feature; static int no_data; @@@ -51,7 -51,7 +51,7 @@@ static int parse_opt_tag_of_filtered_mo const char *arg, int unset) { if (unset || !strcmp(arg, "abort")) - tag_of_filtered_mode = ABORT; + tag_of_filtered_mode = ERROR; else if (!strcmp(arg, "drop")) tag_of_filtered_mode = DROP; else if (!strcmp(arg, "rewrite")) @@@ -185,6 -185,8 +185,8 @@@ 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 if (strchr(path, ' ')) + printf("\"%s\"", path); else printf("%s", path); } @@@ -610,7 -612,7 +612,7 @@@ static void import_marks(char *input_fi die ("Could not read blob %s", sha1_to_hex(sha1)); if (object->flags & SHOWN) - error("Object %s already has a mark", sha1); + error("Object %s already has a mark", sha1_to_hex(sha1)); mark_object(object, mark); if (last_idnum < mark) @@@ -647,7 -649,9 +649,7 @@@ int cmd_fast_export(int argc, const cha "Output full tree for each commit"), OPT_BOOLEAN(0, "use-done-feature", &use_done_feature, "Use the done feature to terminate the stream"), - { OPTION_NEGBIT, 0, "data", &no_data, NULL, - "Skip output of blob data", - PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 }, + OPT_BOOL(0, "no-data", &no_data, "Skip output of blob data"), OPT_END() }; diff --combined t/t9350-fast-export.sh index 77447b70f4,79deef9887..3e821f958b --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@@ -86,7 -86,7 +86,7 @@@ test_expect_success 'import/export-mark git checkout -b marks master && git fast-export --export-marks=tmp-marks HEAD && test -s tmp-marks && - test $(wc -l < tmp-marks) -eq 3 && + test_line_count = 3 tmp-marks && test $( git fast-export --import-marks=tmp-marks\ --export-marks=tmp-marks HEAD | @@@ -101,7 -101,7 +101,7 @@@ grep ^commit\ | wc -l) \ -eq 1 && - test $(wc -l < tmp-marks) -eq 4 + test_line_count = 4 tmp-marks ' @@@ -424,13 -424,13 +424,13 @@@ test_expect_success 'fast-export quote --cacheinfo 100644 $blob "path with \\backslash" \ --cacheinfo 100644 $blob "path with space" && git commit -m addition && - git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index && + git ls-files -z -s | "$PERL_PATH" -0pe "s{\\t}{$&subdir/}" >index && git read-tree --empty && git update-index -z --index-info export.out && + git fast-export -M HEAD >export.out && git rev-list HEAD >expect && git init result && cd result &&