fast-import: Handle directories changing into symlinks
PATCH 1/2 fast-import: Handle directories changing into symlinks
---
I hesitated a bit to put the testcase in t9350-fast-export.sh instead of t9300-fast-import.sh. However, this patch fixes a bug where
fast-export <args> | fast-import
accidentally munges data, and t9300-fast-import.sh has no calls to fast-export while t9350-fast-export.sh has calls to both fast-export and fast-import. If I should design a test for t9300-fast-import.sh instead of (or in addition to) what I have here, let me know.
fast-import.c | 5 +++++ t/t9350-fast-export.sh | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-)
fast-import.c +5 -0
@@ -1528,6 +1528,11 @@ static int tree_content_remove(for (i =0 ; i < t->entry_count; i++) { e = t->entries[i];if (e->name->str_len == n && !strncmp (p, e->name->str_dat, n)) { +if (slash1 &&S_ISLNK (e->versions[1 ].mode)) +/* p was already removed by an earlier change +* of a parent directory to a symlink. +*/ +return 1 ;if (!slash1 || !S_ISDIR (e->versions[1 ].mode)) goto del_entry;if (!e->tree)
t/t9350-fast-export.sh +24 -0
@@ -376,4 +376,28 @@ test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' +test_expect_success 'directory becomes symlink' ' + git init dirtosymlink && + git init result && + ( + cd dirtosymlink && + mkdir foo && + mkdir bar && + echo hello > foo/world && + echo hello > bar/world && + git add foo/world bar/world && + git commit -q -mone && + git rm -r foo && + ln -s bar foo && + git add foo && + git commit -q -mtwo + ) && + ( + cd dirtosymlink && + git fast-export master -- foo | + (cd ../result && git fast-import --quiet) + ) && + (cd result && git show master:foo) +' + test_done
Signature · 1 line
1.6.6.1
PATCH 2/2 fast-export: Add a --full-tree option
This option can be useful when doing incremental exports/imports when later runs of fast-export are passed a larger list of PATHs (for limiting what to export) than prior runs did.
It's also useful for working around potential bugs in prior incremental exports/imports, such as fast-import ignoring symlinks that used to be directories.
--- Documentation/git-fast-export.txt | 11 +++++++++++ builtin/fast-export.c | 8 +++++++- t/t9350-fast-export.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletions(-)
Documentation/git-fast-export.txt +11 -0
@@ -90,6 +90,17 @@ marks the same across runs. resulting stream can only be used by a repository which already contains the necessary objects. +--full-tree:: + By default, for each commit that has a parent, only the files + that are different between the commit and its parent are + shown. By using --full-tree, a "deleteall" directive will be + sent out with each commit followed by a listing of all files + contained in the commit. This can be useful when doing + incremental exports/imports (making use of --export-marks and + --import-marks) when later runs of fast-export contain a + larger list of PATH limiters in [git-rev-list-args...] than + previous runs do. + [git-rev-list-args...]:: A list of arguments, acceptable to 'git rev-parse' and 'git rev-list', that specifies the specific objects and references
builtin/fast-export.c +7 -1
@@ -26,6 +26,7 @@ static int progress;static enum {ABORT ,VERBATIM ,WARN ,STRIP } signed_tag_mode =ABORT ;static enum {ERROR ,DROP ,REWRITE } tag_of_filtered_mode =ABORT ;static int fake_missing_tagger; +static int full_tree;static int no_data; static int parse_opt_signed_tag_mode(const struct option *opt,
@@ -241,7 +242,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev) message +=2 ;if (commit->parents && -get_object_mark (&commit->parents->item->object) !=0 ) { +get_object_mark (&commit->parents->item->object) !=0 && + !full_tree) {parse_commit (commit->parents->item);diff_tree_sha1 (commit->parents->item->tree->object.sha1, commit->tree->object.sha1,"" , &rev->diffopt);
@@ -281,6 +283,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev) i++; } +if (full_tree) +printf ("deleteall\n" );log_tree_diff_flush (rev); rev->diffopt.output_format = saved_output_format;
@@ -584,6 +588,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) "Import marks from this file"),OPT_BOOLEAN (0 ,"fake-missing-tagger" , &fake_missing_tagger,"Fake a tagger when tags lack one" ), +OPT_BOOLEAN (0 ,"full-tree" , &full_tree, +"Output full tree for each commit" ), { OPTION_NEGBIT, 0, "data", &no_data, NULL,"Skip output of blob data" , PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },
t/t9350-fast-export.sh +35 -0
@@ -400,4 +400,39 @@ test_expect_success 'directory becomes symlink' ' (cd result && git show master:foo) ' +cat >> dirtosymlink/expected << EOF +blob +mark :5 +data 6 +hello + +blob +mark :6 +data 7 +badlink +commit refs/heads/master +mark :7 +author A U Thor <[email protected]> 1112912713 -0700 +committer C O Mitter <[email protected]> 1112912713 -0700 +data 6 +three +from :4 +deleteall +M 100644 :5 bar/world +M 120000 :6 foo + +EOF + +test_expect_success 'full-tree' ' + ( + cd dirtosymlink && + git fast-export --export-marks=marks master -- foo > output1 && + rm foo && + ln -s badlink foo && + git commit -mthree foo && + git fast-export --import-marks=marks --full-tree master -- foo bar > output && + test_cmp output expected + ) +' + test_done
Signature · 1 line
1.6.6.1