]> asedeno.scripts.mit.edu Git - git.git/commitdiff
fast-export: Add a --full-tree option
authorElijah Newren <newren@gmail.com>
Sat, 17 Jul 2010 17:00:51 +0000 (11:00 -0600)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Jul 2010 18:12:22 +0000 (11:12 -0700)
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>
Documentation/git-fast-export.txt
builtin/fast-export.c
t/t9350-fast-export.sh

index 98ec6b5871b8dfb3cee2e1302099536d8b0dcd7f..8a6a3cb255258dddc38f69b20525f8d123683681 100644 (file)
@@ -90,6 +90,12 @@ marks the same across runs.
        resulting stream can only be used by a repository which
        already contains the necessary objects.
 
+--full-tree::
+       This option will cause fast-export to issue a "deleteall"
+       directive for each commit followed by a full list of all files
+       in the commit (as opposed to just listing the files which are
+       different from the commit's first parent).
+
 [git-rev-list-args...]::
        A list of arguments, acceptable to 'git rev-parse' and
        'git rev-list', that specifies the specific objects and references
index 25d13a1f5aaedd0378de7050bacdb028230a8bee..8c7760279d3022b7a47390435ce0d2d407e6ce1d 100644 (file)
@@ -27,7 +27,7 @@ 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 no_data;
-static int full_tree = 0;
+static int full_tree;
 
 static int parse_opt_signed_tag_mode(const struct option *opt,
                                     const char *arg, int unset)
@@ -588,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 },
index 6069e1f8312527f2c3d3d93180543f4ab911b257..d831404fba8d982f4600d6ed310c3acb3b893ac8 100755 (executable)
@@ -364,6 +364,11 @@ test_expect_success 'path limiting with import-marks does not lose unmodified fi
        git fast-export --import-marks=marks simple -- file file0 | grep file0
 '
 
+test_expect_success 'full-tree re-shows unmodified files'        '
+       git checkout -f simple &&
+       test $(git fast-export --full-tree simple | grep -c file0) -eq 3
+'
+
 test_expect_success 'set-up a few more tags for tag export tests' '
        git checkout -f master &&
        HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&