Skip to content

Commit 7f40ab0

Browse files
newrengitster
authored andcommitted
fast-export: Add a --full-tree option
This option adds symmetry with fast-import, enabling it to also work with complete trees instead of just incremental changes. 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. Note that this functionality is automatically turned on when using --import-marks together with path limiting in order to avoid dropping important but unchanged files. This functionality is desired when using hand-written filters along with 'fast-export | some-filter | fast-import' as it can be easier to write <some-filter> in terms of complete trees than incremental changes. We could avoid the need to add this option by simply always turning it on. While the end result would be identical, it would slow things down slightly by printing many more filenames per commit which goes somewhat against the 'fast' in 'fast-export'. Signed-off-by: Elijah Newren <newren@gmail.com> Acked-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4087a02 commit 7f40ab0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +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 = 0;
30+
static int full_tree;
3131

3232
static int parse_opt_signed_tag_mode(const struct option *opt,
3333
const char *arg, int unset)
@@ -588,6 +588,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
588588
"Import marks from this file"),
589589
OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
590590
"Fake a tagger when tags lack one"),
591+
OPT_BOOLEAN(0, "full-tree", &full_tree,
592+
"Output full tree for each commit"),
591593
{ OPTION_NEGBIT, 0, "data", &no_data, NULL,
592594
"Skip output of blob data",
593595
PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },

t/t9350-fast-export.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ test_expect_success 'path limiting with import-marks does not lose unmodified fi
364364
git fast-export --import-marks=marks simple -- file file0 | grep file0
365365
'
366366

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+
367372
test_expect_success 'set-up a few more tags for tag export tests' '
368373
git checkout -f master &&
369374
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&

0 commit comments

Comments
 (0)