{"thread":{"id":"37035","subject":"[PATCH/RFC] Add --force-seen option to git-fast-export","startedAt":"2014-07-01T16:28:08Z","lastAt":"2014-07-01T16:28:08Z","messageCount":1,"participants":["Roger Gammans"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"245254","messageId":"S1758643AbaGATZM/20140701192515Z+27@vger.kernel.org","threadId":"37035","inReplyTo":null,"subject":"[PATCH/RFC] Add --force-seen option to git-fast-export","fromName":"Roger Gammans","fromEmail":"rgammans@gammascience.co.uk","sentAt":"2014-07-01T16:28:08Z","receivedAt":"2014-07-01T16:28:08Z","isPatch":true,"sender":{"key":"rgammans@gammascience.co.uk","avatar":null},"body":"I've been playing with git-stitch-repo and similar tools all\nof which seem to use the fast export to get their input data with.\n\nI have need to provide these tools with a hints file so they can\nbe given the extra metadata about parents - to do this they need\nto be able to decode marks->commit id's reliably. \n\ngit-stitch-repo reads it input direct from git-fast-export in a \npipe, so I could change that (by reading from saved output files)\nor modify git to have a mode to ensure that the mark/commit id map\ncould be made stable.\n\nI've chosen the later (mainly because it occurred to me first - but\nit does seem the simpler to code )\n\nThere are no tests yet, and I'm not entirely sure I like the\nnew options name.\n\nComments welcome.\n\n-- Patch follows ->\n\nAllow the use of --import/export-marks options to guarantee\nstability of the marks assigned to commits for tools that use\nthe fast-export format to manipulate history.\n\nSigned-off-by: Roger Gammans <rgammans@gammascience.co.uk>\n---\n Documentation/git-fast-export.txt |  5 +++++\n builtin/fast-export.c             | 15 ++++++++++++---\n 2 files changed, 17 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt\nindex 221506b..10f58fa 100644\n--- a/Documentation/git-fast-export.txt\n+++ b/Documentation/git-fast-export.txt\n@@ -81,6 +81,11 @@ If the backend uses a similar \\--import-marks file, this allows for\n incremental bidirectional exporting of the repository by keeping the\n marks the same across runs.\n \n+--force-seen::\n+\tOnly meaningful with \\--import-marks . This prevents the suppression\n+\tof commits listed the \\--import-marks file from being exported again.\n+\tThe allows multiple runs with a guaranteed marks/commit id stability\n+\n --fake-missing-tagger::\n \tSome old repositories have tags without a tagger.  The\n \tfast-import protocol was pretty strict about that, and did not\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex ef44816..06f0366 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -29,6 +29,7 @@ static enum { ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = ABORT\n static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR;\n static int fake_missing_tagger;\n static int use_done_feature;\n+static int force_seen;\n static int no_data;\n static int full_tree;\n static struct string_list extra_refs = STRING_LIST_INIT_NODUP;\n@@ -324,13 +325,18 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)\n \t\tif (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))\n \t\t\texport_blob(diff_queued_diff.queue[i]->two->sha1);\n \n-\tmark_next_object(&commit->object);\n+\tuint32_t mark = get_object_mark(&commit->object);\n+\tif (! mark) {\n+\t\tmark_next_object(&commit->object);\n+\t\tmark = last_idnum;\n+\t}\n+\n \tif (!is_encoding_utf8(encoding))\n \t\treencoded = reencode_string(message, \"UTF-8\", encoding);\n \tif (!commit->parents)\n \t\tprintf(\"reset %s\\n\", (const char*)commit->util);\n \tprintf(\"commit %s\\nmark :%\"PRIu32\"\\n%.*s\\n%.*s\\ndata %u\\n%s\",\n-\t       (const char *)commit->util, last_idnum,\n+\t       (const char *)commit->util, mark,\n \t       (int)(author_end - author), author,\n \t       (int)(committer_end - committer), committer,\n \t       (unsigned)(reencoded\n@@ -668,7 +674,8 @@ static void import_marks(char *input_file)\n \n \t\tmark_object(object, mark);\n \n-\t\tobject->flags |= SHOWN;\n+\t\tif (! force_seen )\n+\t\t\tobject->flags |= SHOWN;\n \t}\n \tfclose(f);\n }\n@@ -713,6 +720,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"Output full tree for each commit\")),\n \t\tOPT_BOOL(0, \"use-done-feature\", &use_done_feature,\n \t\t\t     N_(\"Use the done feature to terminate the stream\")),\n+\t\tOPT_BOOL(0, \"force-seen\", &force_seen,\n+\t\t\t     N_(\"Output commit and blobs even if in an imported marks-file\")),\n \t\tOPT_BOOL(0, \"no-data\", &no_data, N_(\"Skip output of blob data\")),\n \t\tOPT_STRING_LIST(0, \"refspec\", &refspecs_list, N_(\"refspec\"),\n \t\t\t     N_(\"Apply refspec to exported refs\")),\n-- \n1.8.5.1\n"}]}