Merge branch 'di/fast-import-doc'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Aug 2011 23:00:32 +0000 (16:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Aug 2011 23:00:32 +0000 (16:00 -0700)
* di/fast-import-doc:
doc/fast-import: document feature import-marks-if-exists

1  2 
Documentation/git-fast-import.txt
t/t9300-fast-import.sh
index 2969388880a6d827a9970dd9d67fd81224a5bc34,605ab9eea5fa3a4c223cfdf490d6073ed15fa02d..db0d75fdbccc1cb3afc1333c5308a9d494eaa2c4
@@@ -8,7 -8,6 +8,7 @@@ git-fast-import - Backend for fast Git 
  
  SYNOPSIS
  --------
 +[verse]
  frontend | 'git fast-import' [options]
  
  DESCRIPTION
@@@ -102,12 -101,6 +102,12 @@@ OPTION
        when the `cat-blob` command is encountered in the stream.
        The default behaviour is to write to `stdout`.
  
 +--done::
 +      Require a `done` command at the end of the stream.
 +      This option might be useful for detecting errors that
 +      cause the frontend to terminate before it has started to
 +      write a stream.
 +
  --export-pack-edges=<file>::
        After creating a packfile, print a line of data to
        <file> listing the filename of the packfile and the last
@@@ -337,11 -330,6 +337,11 @@@ and control the current import process
        standard output.  This command is optional and is not needed
        to perform an import.
  
 +`done`::
 +      Marks the end of the stream. This command is optional
 +      unless the `done` feature was requested using the
 +      `--done` command line option or `feature done` command.
 +
  `cat-blob`::
        Causes fast-import to print a blob in 'cat-file --batch'
        format to the file descriptor set with `--cat-blob-fd` or
@@@ -660,14 -648,9 +660,14 @@@ paths for a commit are encouraged to d
  
  `notemodify`
  ^^^^^^^^^^^^
 -Included in a `commit` command to add a new note (annotating a given
 -commit) or change the content of an existing note.  This command has
 -two different means of specifying the content of the note.
 +Included in a `commit` `<notes_ref>` command to add a new note
 +annotating a `<committish>` or change this annotation contents.
 +Internally it is similar to filemodify 100644 on `<committish>`
 +path (maybe split into subdirectories). It's not advised to
 +use any other commands to write to the `<notes_ref>` tree except
 +`filedeleteall` to delete all existing notes in this tree.
 +This command has two different means of specifying the content
 +of the note.
  
  External data format::
        The data content for the note was already supplied by a prior
@@@ -1012,10 -995,14 +1012,14 @@@ force:
        (see OPTIONS, above).
  
  import-marks::
+ import-marks-if-exists::
        Like --import-marks except in two respects: first, only one
-       "feature import-marks" command is allowed per stream;
-       second, an --import-marks= command-line option overrides
-       any "feature import-marks" command in the stream.
+       "feature import-marks" or "feature import-marks-if-exists"
+       command is allowed per stream; second, an --import-marks=
+       or --import-marks-if-exists command-line option overrides
+       any of these "feature" commands in the stream; third,
+       "feature import-marks-if-exists" like a corresponding
+       command-line option silently skips a nonexistent file.
  
  cat-blob::
  ls::
@@@ -1032,11 -1019,6 +1036,11 @@@ notes:
        Versions of fast-import not supporting notes will exit
        with a message indicating so.
  
 +done::
 +      Error out if the stream ends without a 'done' command.
 +      Without this feature, errors causing the frontend to end
 +      abruptly at a convenient point in the stream can go
 +      undetected.
  
  `option`
  ~~~~~~~~
@@@ -1066,15 -1048,6 +1070,15 @@@ not be passed as option
  * cat-blob-fd
  * force
  
 +`done`
 +~~~~~~
 +If the `done` feature is not in use, treated as if EOF was read.
 +This can be used to tell fast-import to finish early.
 +
 +If the `--done` command line option or `feature done` command is
 +in use, the `done` command is mandatory and marks the end of the
 +stream.
 +
  Crash Reports
  -------------
  If fast-import is supplied invalid input it will terminate with a
diff --combined t/t9300-fast-import.sh
index f256475020549a157297481e21859e235a5cfcc1,7588dcc809019a092737035e68006353a619073f..2cb44942624689cfaf4d3a77bd8428fba82ef729
@@@ -1882,6 -1882,53 +1882,53 @@@ test_expect_success 'R: --import-marks-
        test_cmp expect io.marks
  '
  
+ test_expect_success 'R: feature import-marks-if-exists' '
+       rm -f io.marks &&
+       >expect &&
+       git fast-import --export-marks=io.marks <<-\EOF &&
+       feature import-marks-if-exists=not_io.marks
+       EOF
+       test_cmp expect io.marks &&
+       blob=$(echo hi | git hash-object --stdin) &&
+       echo ":1 $blob" >io.marks &&
+       echo ":1 $blob" >expect &&
+       echo ":2 $blob" >>expect &&
+       git fast-import --export-marks=io.marks <<-\EOF &&
+       feature import-marks-if-exists=io.marks
+       blob
+       mark :2
+       data 3
+       hi
+       EOF
+       test_cmp expect io.marks &&
+       echo ":3 $blob" >>expect &&
+       git fast-import --import-marks=io.marks \
+                       --export-marks=io.marks <<-\EOF &&
+       feature import-marks-if-exists=not_io.marks
+       blob
+       mark :3
+       data 3
+       hi
+       EOF
+       test_cmp expect io.marks &&
+       >expect &&
+       git fast-import --import-marks-if-exists=not_io.marks \
+                       --export-marks=io.marks <<-\EOF
+       feature import-marks-if-exists=io.marks
+       EOF
+       test_cmp expect io.marks
+ '
  cat >input << EOF
  feature import-marks=marks.out
  feature export-marks=marks.new
@@@ -2197,48 -2244,6 +2244,48 @@@ test_expect_success 'R: quiet option re
      test_cmp empty output
  '
  
 +test_expect_success 'R: feature done means terminating "done" is mandatory' '
 +      echo feature done | test_must_fail git fast-import &&
 +      test_must_fail git fast-import --done </dev/null
 +'
 +
 +test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
 +      git fast-import <<-\EOF &&
 +      feature done
 +      done
 +      trailing gibberish
 +      EOF
 +      git fast-import <<-\EOF
 +      done
 +      more trailing gibberish
 +      EOF
 +'
 +
 +test_expect_success 'R: terminating "done" within commit' '
 +      cat >expect <<-\EOF &&
 +      OBJID
 +      :000000 100644 OBJID OBJID A    hello.c
 +      :000000 100644 OBJID OBJID A    hello2.c
 +      EOF
 +      git fast-import <<-EOF &&
 +      commit refs/heads/done-ends
 +      committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
 +      data <<EOT
 +      Commit terminated by "done" command
 +      EOT
 +      M 100644 inline hello.c
 +      data <<EOT
 +      Hello, world.
 +      EOT
 +      C hello.c hello2.c
 +      done
 +      EOF
 +      git rev-list done-ends |
 +      git diff-tree -r --stdin --root --always |
 +      sed -e "s/$_x40/OBJID/g" >actual &&
 +      test_cmp expect actual
 +'
 +
  cat >input <<EOF
  option git non-existing-option
  EOF