{"thread":{"id":"28139","subject":"[PATCH v3] doc/fast-import: document feature import-marks-if-exists","startedAt":"2011-08-17T10:42:58Z","lastAt":"2011-08-17T10:42:58Z","messageCount":1,"participants":["Dmitry Ivankov"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"173669","messageId":"1313577778-14716-1-git-send-email-divanorama@gmail.com","threadId":"28139","inReplyTo":null,"subject":"[PATCH v3] doc/fast-import: document feature import-marks-if-exists","fromName":"Dmitry Ivankov","fromEmail":"divanorama@gmail.com","sentAt":"2011-08-17T10:42:58Z","receivedAt":"2011-08-17T10:42:58Z","isPatch":true,"sender":{"key":"divanorama@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158999?v=4"},"body":"fast-import command-line option --import-marks-if-exists was introduced\nin commit dded4f1 (fast-import: Introduce --import-marks-if-exists, 2011-01-15)\n\n--import-marks option can be set via a \"feature\" command in a fast-import\nstream and --import-marks-if-exists had support for such specification\nfrom the very beginning too due to some shared codebase. Though the\ndocumentation for this feature wasn't written in dded4f1.\n\nAdd the documentation for \"feature import-marks-if-exists=<file>\". Also add\na minimalistic test for it.\n\nSigned-off-by: Dmitry Ivankov <divanorama@gmail.com>\n---\nThis is a new round for 2/3 from [1]. 1/3 and 3/3 are already in master.\nThe only change from v2 is more tests, now there are:\n\n- feature import-marks-if-exists=nonexisting.marks\n- feature import-marks-if-exists=existing.marks\n- --import-marks=existing.marks & feature=nonexisting.marks\n- --import-marks-if-exists=nonexisting.marks & feature=existing.marks\n\nThese seem to cover most cases: feature works and is overriden by command line arguments.\nHaving more than one feature specified isn't tested to fail, imo it'd be better to support\nspecifying multiple marks files via features anyway. It's not yet done because unlike other\nsimple options are easy to override on the fly (we first parse the stream for features and\nthen parse argv. So argv overrides things), while import marks are more tricky:\n- overriding rule is more complex, any command line option should discard all feature ones.\n- reading them could be expensive (we do lookup objects they refer to).\n- if the lookup fails or file is otherwise corrupt/bad, we die. So we shouldn't read marks\nfiles given by features if they are to be overriden by command line options.\n\n Documentation/git-fast-import.txt |   10 +++++--\n t/t9300-fast-import.sh            |   47 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 54 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt\nindex 2969388..db0d75f 100644\n--- a/Documentation/git-fast-import.txt\n+++ b/Documentation/git-fast-import.txt\n@@ -1012,10 +1012,14 @@ force::\n \t(see OPTIONS, above).\n \n import-marks::\n+import-marks-if-exists::\n \tLike --import-marks except in two respects: first, only one\n-\t\"feature import-marks\" command is allowed per stream;\n-\tsecond, an --import-marks= command-line option overrides\n-\tany \"feature import-marks\" command in the stream.\n+\t\"feature import-marks\" or \"feature import-marks-if-exists\"\n+\tcommand is allowed per stream; second, an --import-marks=\n+\tor --import-marks-if-exists command-line option overrides\n+\tany of these \"feature\" commands in the stream; third,\n+\t\"feature import-marks-if-exists\" like a corresponding\n+\tcommand-line option silently skips a nonexistent file.\n \n cat-blob::\n ls::\ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex f256475..2cb4494 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -1882,6 +1882,53 @@ test_expect_success 'R: --import-marks-if-exists' '\n \ttest_cmp expect io.marks\n '\n \n+test_expect_success 'R: feature import-marks-if-exists' '\n+\trm -f io.marks &&\n+\t>expect &&\n+\n+\tgit fast-import --export-marks=io.marks <<-\\EOF &&\n+\tfeature import-marks-if-exists=not_io.marks\n+\tEOF\n+\ttest_cmp expect io.marks &&\n+\n+\tblob=$(echo hi | git hash-object --stdin) &&\n+\n+\techo \":1 $blob\" >io.marks &&\n+\techo \":1 $blob\" >expect &&\n+\techo \":2 $blob\" >>expect &&\n+\n+\tgit fast-import --export-marks=io.marks <<-\\EOF &&\n+\tfeature import-marks-if-exists=io.marks\n+\tblob\n+\tmark :2\n+\tdata 3\n+\thi\n+\n+\tEOF\n+\ttest_cmp expect io.marks &&\n+\n+\techo \":3 $blob\" >>expect &&\n+\n+\tgit fast-import --import-marks=io.marks \\\n+\t\t\t--export-marks=io.marks <<-\\EOF &&\n+\tfeature import-marks-if-exists=not_io.marks\n+\tblob\n+\tmark :3\n+\tdata 3\n+\thi\n+\n+\tEOF\n+\ttest_cmp expect io.marks &&\n+\n+\t>expect &&\n+\n+\tgit fast-import --import-marks-if-exists=not_io.marks \\\n+\t\t\t--export-marks=io.marks <<-\\EOF\n+\tfeature import-marks-if-exists=io.marks\n+\tEOF\n+\ttest_cmp expect io.marks\n+'\n+\n cat >input << EOF\n feature import-marks=marks.out\n feature export-marks=marks.new\n-- \n1.7.3.4\n"}]}