fast-import: allow for multiple --import-marks= arguments
The --import-marks= option may be specified multiple times on the commandline and should result in all marks being read in. Only one import-marks feature may be specified in the stream, which is overriden by any --import-marks= commandline options. If one wishes to specify import-marks files in addition to the one specified in the stream, it is easy to repeat the stream option as a --import-marks= commandline option. Also verify this behavior with tests. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
2792f26c3e
commit
081751c882
@ -867,7 +867,8 @@ it does not.
|
|||||||
The <feature> part of the command may be any string matching
|
The <feature> part of the command may be any string matching
|
||||||
^[a-zA-Z][a-zA-Z-]*$ and should be understood by fast-import.
|
^[a-zA-Z][a-zA-Z-]*$ and should be understood by fast-import.
|
||||||
|
|
||||||
Feature work identical as their option counterparts.
|
Feature work identical as their option counterparts with the
|
||||||
|
exception of the import-marks feature, see below.
|
||||||
|
|
||||||
The following features are currently supported:
|
The following features are currently supported:
|
||||||
|
|
||||||
@ -876,6 +877,11 @@ The following features are currently supported:
|
|||||||
* export-marks
|
* export-marks
|
||||||
* force
|
* force
|
||||||
|
|
||||||
|
The import-marks behaves differently from when it is specified as
|
||||||
|
commandline option in that only one "feature import-marks" is allowed
|
||||||
|
per stream. Also, any --import-marks= specified on the commandline
|
||||||
|
will override those from the stream (if any).
|
||||||
|
|
||||||
`option`
|
`option`
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
Processes the specified option so that git fast-import behaves in a
|
Processes the specified option so that git fast-import behaves in a
|
||||||
|
@ -322,6 +322,7 @@ static struct object_entry *object_table[1 << 16];
|
|||||||
static struct mark_set *marks;
|
static struct mark_set *marks;
|
||||||
static const char *export_marks_file;
|
static const char *export_marks_file;
|
||||||
static const char *import_marks_file;
|
static const char *import_marks_file;
|
||||||
|
static int import_marks_file_from_stream;
|
||||||
|
|
||||||
/* Our last blob */
|
/* Our last blob */
|
||||||
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
|
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
|
||||||
@ -2469,9 +2470,19 @@ static void parse_progress(void)
|
|||||||
skip_optional_lf();
|
skip_optional_lf();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void option_import_marks(const char *marks)
|
static void option_import_marks(const char *marks, int from_stream)
|
||||||
{
|
{
|
||||||
|
if (import_marks_file) {
|
||||||
|
if (from_stream)
|
||||||
|
die("Only one import-marks command allowed per stream");
|
||||||
|
|
||||||
|
/* read previous mark file */
|
||||||
|
if(!import_marks_file_from_stream)
|
||||||
|
read_marks();
|
||||||
|
}
|
||||||
|
|
||||||
import_marks_file = xstrdup(marks);
|
import_marks_file = xstrdup(marks);
|
||||||
|
import_marks_file_from_stream = from_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void option_date_format(const char *fmt)
|
static void option_date_format(const char *fmt)
|
||||||
@ -2538,12 +2549,12 @@ static int parse_one_option(const char *option)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_one_feature(const char *feature)
|
static int parse_one_feature(const char *feature, int from_stream)
|
||||||
{
|
{
|
||||||
if (!prefixcmp(feature, "date-format=")) {
|
if (!prefixcmp(feature, "date-format=")) {
|
||||||
option_date_format(feature + 12);
|
option_date_format(feature + 12);
|
||||||
} else if (!prefixcmp(feature, "import-marks=")) {
|
} else if (!prefixcmp(feature, "import-marks=")) {
|
||||||
option_import_marks(feature + 13);
|
option_import_marks(feature + 13, from_stream);
|
||||||
} else if (!prefixcmp(feature, "export-marks=")) {
|
} else if (!prefixcmp(feature, "export-marks=")) {
|
||||||
option_export_marks(feature + 13);
|
option_export_marks(feature + 13);
|
||||||
} else if (!prefixcmp(feature, "force")) {
|
} else if (!prefixcmp(feature, "force")) {
|
||||||
@ -2562,7 +2573,7 @@ static void parse_feature(void)
|
|||||||
if (seen_data_command)
|
if (seen_data_command)
|
||||||
die("Got feature command '%s' after data command", feature);
|
die("Got feature command '%s' after data command", feature);
|
||||||
|
|
||||||
if (parse_one_feature(feature))
|
if (parse_one_feature(feature, 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
die("This version of fast-import does not support feature %s.", feature);
|
die("This version of fast-import does not support feature %s.", feature);
|
||||||
@ -2618,7 +2629,7 @@ static void parse_argv(void)
|
|||||||
if (parse_one_option(a + 2))
|
if (parse_one_option(a + 2))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (parse_one_feature(a + 2))
|
if (parse_one_feature(a + 2, 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
die("unknown option %s", a);
|
die("unknown option %s", a);
|
||||||
|
@ -1285,6 +1285,15 @@ test_expect_success 'R: abort on receiving feature after data command' '
|
|||||||
test_must_fail git fast-import <input
|
test_must_fail git fast-import <input
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >input << EOF
|
||||||
|
feature import-marks=git.marks
|
||||||
|
feature import-marks=git2.marks
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'R: only one import-marks feature allowed per stream' '
|
||||||
|
test_must_fail git fast-import <input
|
||||||
|
'
|
||||||
|
|
||||||
cat >input << EOF
|
cat >input << EOF
|
||||||
feature export-marks=git.marks
|
feature export-marks=git.marks
|
||||||
blob
|
blob
|
||||||
@ -1324,6 +1333,19 @@ test_expect_success \
|
|||||||
'cat input | git fast-import --import-marks=marks.out &&
|
'cat input | git fast-import --import-marks=marks.out &&
|
||||||
test_cmp marks.out marks.new'
|
test_cmp marks.out marks.new'
|
||||||
|
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
feature import-marks=nonexistant.marks
|
||||||
|
feature export-marks=combined.marks
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'R: multiple --import-marks= should be honoured' '
|
||||||
|
head -n2 marks.out > one.marks &&
|
||||||
|
tail -n +3 marks.out > two.marks &&
|
||||||
|
git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
|
||||||
|
test_cmp marks.out combined.marks
|
||||||
|
'
|
||||||
|
|
||||||
cat >input << EOF
|
cat >input << EOF
|
||||||
option git quiet
|
option git quiet
|
||||||
blob
|
blob
|
||||||
|
Reference in New Issue
Block a user