[PATCH/RFC] Add --force-seen option to git-fast-export

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've been playing with git-stitch-repo and similar tools all
of which seem to use the fast export to get their input data with.

I have need to provide these tools with a hints file so they can
be given the extra metadata about parents - to do this they need
to be able to decode marks->commit id's reliably. 

git-stitch-repo reads it input direct from git-fast-export in a 
pipe, so I could change that (by reading from saved output files)
or modify git to have a mode to ensure that the mark/commit id map
could be made stable.

I've chosen the later (mainly because it occurred to me first - but
it does seem the simpler to code )

There are no tests yet, and I'm not entirely sure I like the
new options name.

Comments welcome.

-- Patch follows ->

Allow the use of --import/export-marks options to guarantee
stability of the marks assigned to commits for tools that use
the fast-export format to manipulate history.

Signed-off-by: Roger Gammans <rgammans@xxxxxxxxxxxxxxxxxx>
---
 Documentation/git-fast-export.txt |  5 +++++
 builtin/fast-export.c             | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
index 221506b..10f58fa 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -81,6 +81,11 @@ If the backend uses a similar \--import-marks file, this allows for
 incremental bidirectional exporting of the repository by keeping the
 marks the same across runs.
 
+--force-seen::
+	Only meaningful with \--import-marks . This prevents the suppression
+	of commits listed the \--import-marks file from being exported again.
+	The allows multiple runs with a guaranteed marks/commit id stability
+
 --fake-missing-tagger::
 	Some old repositories have tags without a tagger.  The
 	fast-import protocol was pretty strict about that, and did not
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index ef44816..06f0366 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -29,6 +29,7 @@ static enum { ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = ABORT
 static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR;
 static int fake_missing_tagger;
 static int use_done_feature;
+static int force_seen;
 static int no_data;
 static int full_tree;
 static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
@@ -324,13 +325,18 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
 		if (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))
 			export_blob(diff_queued_diff.queue[i]->two->sha1);
 
-	mark_next_object(&commit->object);
+	uint32_t mark = get_object_mark(&commit->object);
+	if (! mark) {
+		mark_next_object(&commit->object);
+		mark = last_idnum;
+	}
+
 	if (!is_encoding_utf8(encoding))
 		reencoded = reencode_string(message, "UTF-8", encoding);
 	if (!commit->parents)
 		printf("reset %s\n", (const char*)commit->util);
 	printf("commit %s\nmark :%"PRIu32"\n%.*s\n%.*s\ndata %u\n%s",
-	       (const char *)commit->util, last_idnum,
+	       (const char *)commit->util, mark,
 	       (int)(author_end - author), author,
 	       (int)(committer_end - committer), committer,
 	       (unsigned)(reencoded
@@ -668,7 +674,8 @@ static void import_marks(char *input_file)
 
 		mark_object(object, mark);
 
-		object->flags |= SHOWN;
+		if (! force_seen )
+			object->flags |= SHOWN;
 	}
 	fclose(f);
 }
@@ -713,6 +720,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 			 N_("Output full tree for each commit")),
 		OPT_BOOL(0, "use-done-feature", &use_done_feature,
 			     N_("Use the done feature to terminate the stream")),
+		OPT_BOOL(0, "force-seen", &force_seen,
+			     N_("Output commit and blobs even if in an imported marks-file")),
 		OPT_BOOL(0, "no-data", &no_data, N_("Skip output of blob data")),
 		OPT_STRING_LIST(0, "refspec", &refspecs_list, N_("refspec"),
 			     N_("Apply refspec to exported refs")),
-- 
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]