@matheusbsbs / matheus-bagliano / commits / 4087a02e45
Fork 0

fast-export: Fix dropping of files with --import-marks and path limiting

Since fast-export operates by listing file changes since the (first) parent commit, when using --import-marks and path limiting and using a wider list of paths than in previous runs, files from the new path(s) will silently be omitted from the result unless or until a commit which explicitly changes those files. The resulting repository in such cases is broken and makes no sense. This commit fixes this by having fast-export work with complete trees instead of incremental changes (when both --import-marks and path limiting are used). It works by issuing a 'deleteall' directive with each commit and then listing the full set of files that make up that commit, rather than just showing the list of files that have changed since the (first) parent commit. Signed-off-by: Elijah Newren <newren@gmail.com> Acked-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jul 17, 2010 at 11:00 UTC 4087a02e452aafd0e9a6c3471c40fe76d6aafbe4
2 files changed +17 -1
builtin/fast-export.c
+8 -1
@@ -27,6 +27,7 @@ static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
27 static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
28 static int fake_missing_tagger;
29 static int no_data;
30 +static int full_tree = 0;
31
32 static int parse_opt_signed_tag_mode(const struct option *opt,
33 const char *arg, int unset)
@@ -241,7 +242,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
242 message += 2;
243
244 if (commit->parents &&
244 - get_object_mark(&commit->parents->item->object) != 0) {
245 + get_object_mark(&commit->parents->item->object) != 0 &&
246 + !full_tree) {
247 parse_commit(commit->parents->item);
248 diff_tree_sha1(commit->parents->item->tree->object.sha1,
249 commit->tree->object.sha1, "", &rev->diffopt);
@@ -281,6 +283,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
283 i++;
284 }
285
286 + if (full_tree)
287 + printf("deleteall\n");
288 log_tree_diff_flush(rev);
289 rev->diffopt.output_format = saved_output_format;
290
@@ -608,6 +612,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
612 if (import_filename)
613 import_marks(import_filename);
614
615 + if (import_filename && revs.prune_data)
616 + full_tree = 1;
617 +
618 get_tags_and_duplicates(&revs.pending, &extra_refs);
619
620 if (prepare_revision_walk(&revs))
t/t9350-fast-export.sh
+9
@@ -355,6 +355,15 @@ test_expect_failure 'no exact-ref revisions included' '
355 )
356 '
357
358 +test_expect_success 'path limiting with import-marks does not lose unmodified files' '
359 + git checkout -b simple marks~2 &&
360 + git fast-export --export-marks=marks simple -- file > /dev/null &&
361 + echo more content >> file &&
362 + test_tick &&
363 + git commit -mnext file &&
364 + git fast-export --import-marks=marks simple -- file file0 | grep file0
365 +'
366 +
367 test_expect_success 'set-up a few more tags for tag export tests' '
368 git checkout -f master &&
369 HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&