Skip to content

Commit 1253164

Browse files
committed
Merge branch 'en/fast-export-fix'
* en/fast-export-fix: fast-export: Add a --full-tree option fast-export: Fix dropping of files with --import-marks and path limiting
2 parents a621859 + 7f40ab0 commit 1253164

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

Documentation/git-fast-export.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ marks the same across runs.
9090
resulting stream can only be used by a repository which
9191
already contains the necessary objects.
9292

93+
--full-tree::
94+
This option will cause fast-export to issue a "deleteall"
95+
directive for each commit followed by a full list of all files
96+
in the commit (as opposed to just listing the files which are
97+
different from the commit's first parent).
98+
9399
[git-rev-list-args...]::
94100
A list of arguments, acceptable to 'git rev-parse' and
95101
'git rev-list', that specifies the specific objects and references

builtin/fast-export.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
2727
static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
2828
static int fake_missing_tagger;
2929
static int no_data;
30+
static int full_tree;
3031

3132
static int parse_opt_signed_tag_mode(const struct option *opt,
3233
const char *arg, int unset)
@@ -241,7 +242,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
241242
message += 2;
242243

243244
if (commit->parents &&
244-
get_object_mark(&commit->parents->item->object) != 0) {
245+
get_object_mark(&commit->parents->item->object) != 0 &&
246+
!full_tree) {
245247
parse_commit(commit->parents->item);
246248
diff_tree_sha1(commit->parents->item->tree->object.sha1,
247249
commit->tree->object.sha1, "", &rev->diffopt);
@@ -281,6 +283,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
281283
i++;
282284
}
283285

286+
if (full_tree)
287+
printf("deleteall\n");
284288
log_tree_diff_flush(rev);
285289
rev->diffopt.output_format = saved_output_format;
286290

@@ -584,6 +588,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
584588
"Import marks from this file"),
585589
OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
586590
"Fake a tagger when tags lack one"),
591+
OPT_BOOLEAN(0, "full-tree", &full_tree,
592+
"Output full tree for each commit"),
587593
{ OPTION_NEGBIT, 0, "data", &no_data, NULL,
588594
"Skip output of blob data",
589595
PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },
@@ -608,6 +614,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
608614
if (import_filename)
609615
import_marks(import_filename);
610616

617+
if (import_filename && revs.prune_data)
618+
full_tree = 1;
619+
611620
get_tags_and_duplicates(&revs.pending, &extra_refs);
612621

613622
if (prepare_revision_walk(&revs))

t/t9350-fast-export.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,20 @@ test_expect_failure 'no exact-ref revisions included' '
355355
)
356356
'
357357

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 'full-tree re-shows unmodified files' '
368+
git checkout -f simple &&
369+
test $(git fast-export --full-tree simple | grep -c file0) -eq 3
370+
'
371+
358372
test_expect_success 'set-up a few more tags for tag export tests' '
359373
git checkout -f master &&
360374
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&

0 commit comments

Comments
 (0)