git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] doc/fast-import: document feature import-marks-if-exists

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2011, 17:00 UTC
Message-ID
<7voc0z8mdd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1310483428-29833-3-git-send-email-divanorama@gmail.com>
Dmitry Ivankov <divanorama@gmail.com> writes:
Show 9 quoted lines
> fast-import parameter --import-marks-if-exists was introduced in
> commit dded4.. --import-marks can be set via a "feature" command in
> a fast-import stream and --import-marks-if-exists has support for
> such specification too, for free.
>
> Document "feature import-marks-if-exists=<file>" command and add a
> minimalistic test for it.
>
> Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Thanks.
Show 16 quoted lines
>  Documentation/git-fast-import.txt |    5 +++++
>  t/t9300-fast-import.sh            |   15 +++++++++++++++
>  2 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
> index 3f5b912..bdcc81c 100644
> --- a/Documentation/git-fast-import.txt
> +++ b/Documentation/git-fast-import.txt
> @@ -1005,6 +1005,11 @@ import-marks::
>  	second, an --import-marks= command-line option overrides
>  	any "feature import-marks" command in the stream.
>  
> +import-marks-if-exists::
> +	Like import-marks but instead of erroring out, silently
> +	skips the file if it does not exist. Differences from --
> +	version are the same as with import-marks feature above.

Wouldn't it be more concise and complete to do it this way instead? It avoids duplication and also clarifies you cannot mix these two.

diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 249249a..e939e74 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -995,10 +995,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;
+	"feature import-marks" command or "feature import-marks-if-exists"
+	is allowed per stream;
 	second, an --import-marks= command-line option overrides
-	any "feature import-marks" command in the stream.
+	any "feature import-marks" command in the stream. Similarly,
+	import-marks-if-exists corresponds to --import-marks-if-exists
+	from the command line.
 
 cat-blob::
 ls::

>  
> +test_expect_success 'R: feature import-marks-if-exists' '
> +	rm -f io.marks &&
> +	blob=$(echo hi | git hash-object --stdin) &&
> +	echo ":1 $blob" >expect &&
> +	git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
> +	feature import-marks-if-exists=io.marks
> +	blob
> +	mark :1
> +	data 3
> +	hi
> +
> +	EOF
> +	test_cmp expect io.marks
> +'

Do you really want both the command line option and feature in this test?

There are at least four cases [*1*] you would want to test (a part of
blame lies in the original test you copied this from).

 - "if exists" should not fail if the marks file does not exist;
 - "if exists" reads marks if exists (not tested in this patch);
 - having "feature import-marks-if-exists" will trigger this feature
   without command line option (not tested in this patch); and
 - having "feature import-marks-if-exists" will be overridden by
   the command line option (not tested in this patch).




[Footnote]

*1* Ideally, the test should also cover these 16 combinations:

  io.marks file (2 cases: exists or missing)

times

  --import-mark-if-exists (2 cases: exists or missing)

times

 feature import-marks-if-exists (4 cases: missing,
 				same as command line,
                                different from command line,
				given more than one)
Previous: Dmitry IvankovNext: Ramkumar Ramachandra
Message 4 of 14 in “doc/{fast-import,remote-helpers}: few clarifications”
  1. 0/3 doc/{fast-import,remote-helpers}: few clarificationsDmitry Ivankov, Jul 12, 2011
  2. 1/3 doc/fast-import: clarify notemodify commandDmitry Ivankov, Jul 12, 2011
  3. 2/3 doc/fast-import: document feature import-marks-if-existsDmitry Ivankov, Jul 12, 2011
  4. Junio C HamanoJul 12, 2011
  5. Ramkumar RamachandraJul 13, 2011
  6. 3/3 doc/remote-helpers: document the gitdir featureDmitry Ivankov, Jul 12, 2011
  7. Sverre RabbelierJul 13, 2011
  8. 1/3 doc/fast-import: clarify notemodify commandDmitry Ivankov, Jul 13, 2011
  9. Johan HerlandJul 22, 2011
  10. 2/3 doc/fast-import: document feature import-marks-if-existsDmitry Ivankov, Jul 13, 2011
  11. 3/3 remote-helpers: export GIT_DIR variable to helpersDmitry Ivankov, Jul 13, 2011
  12. Dmitry IvankovJul 13, 2011
  13. Sverre RabbelierJul 13, 2011
  14. Dmitry IvankovJul 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.