summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 60b9004)
raw | patch | inline | side by side (parent: 60b9004)
author | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 7 Mar 2007 23:07:26 +0000 (18:07 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 7 Mar 2007 23:07:26 +0000 (18:07 -0500) |
I'm giving fast-import a lesson on how to reload the marks table
using the same format it outputs with --export-marks. This way
a frontend can reload the marks table from a prior import, making
incremental imports less painful.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
using the same format it outputs with --export-marks. This way
a frontend can reload the marks table from a prior import, making
incremental imports less painful.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Documentation/git-fast-import.txt | patch | blob | history | |
fast-import.c | patch | blob | history | |
t/t9300-fast-import.sh | patch | blob | history |
index 77a14bb076b6d8be624345ee10e4bd14cfb2c359..7e3d2b1a96a3ef6819a0f3ccebf8f717de9d32dc 100644 (file)
Dumps the internal marks table to <file> when complete.
Marks are written one per line as `:markid SHA-1`.
Frontends can use this file to validate imports after they
- have been completed.
+ have been completed, or to save the marks table across
+ incremental runs. As <file> is only opened and truncated
+ at checkpoint (or completion) the same path can also be
+ safely given to \--import-marks.
+
+--import-marks=<file>::
+ Before processing any input, load the marks specified in
+ <file>. The input file must exist, must be readable, and
+ must use the same format as produced by \--export-marks.
+ Multiple options may be supplied to import more than one
+ set of marks. If a mark is defined to different values,
+ the last file wins.
--export-pack-edges=<file>::
After creating a packfile, print a line of data to
diff --git a/fast-import.c b/fast-import.c
index a09221242e3866d8b5f01d21ca2e27adbb1558e4..fbed8e4e89cb5cd8bb1d8f666de8a19c71912136 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
read_next_command();
}
+static void import_marks(const char *input_file)
+{
+ char line[512];
+ FILE *f = fopen(input_file, "r");
+ if (!f)
+ die("cannot read %s: %s", input_file, strerror(errno));
+ while (fgets(line, sizeof(line), f)) {
+ uintmax_t mark;
+ char *end;
+ unsigned char sha1[20];
+ struct object_entry *e;
+
+ end = strchr(line, '\n');
+ if (line[0] != ':' || !end)
+ die("corrupt mark line: %s", line);
+ *end = 0;
+ mark = strtoumax(line + 1, &end, 10);
+ if (!mark || end == line + 1
+ || *end != ' ' || get_sha1(end + 1, sha1))
+ die("corrupt mark line: %s", line);
+ e = find_object(sha1);
+ if (!e) {
+ enum object_type type = sha1_object_info(sha1, NULL);
+ if (type < 0)
+ die("object not found: %s", sha1_to_hex(sha1));
+ e = insert_object(sha1);
+ e->type = type;
+ e->pack_id = MAX_PACK_ID;
+ }
+ insert_mark(mark, e);
+ }
+ fclose(f);
+}
+
static const char fast_import_usage[] =
"git-fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
max_depth = strtoul(a + 8, NULL, 0);
else if (!prefixcmp(a, "--active-branches="))
max_active_branches = strtoul(a + 18, NULL, 0);
+ else if (!prefixcmp(a, "--import-marks="))
+ import_marks(a + 15);
else if (!prefixcmp(a, "--export-marks="))
mark_file = a + 15;
else if (!prefixcmp(a, "--export-pack-edges=")) {
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 970d683650f5ee6b99a07ff10063710292b28ed1..2e1a09ff2db29421629b038a3374449c49bdc79d 100755 (executable)
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
'A: verify marks output' \
'diff -u expect marks.out'
+test_expect_success \
+ 'A: verify marks import' \
+ 'git-fast-import \
+ --import-marks=marks.out \
+ --export-marks=marks.new \
+ </dev/null &&
+ diff -u expect marks.new'
+
###
### series B
###