]> Kevux Git Server - rit/commitdiff
fast-import: allow tags to be identified by mark labels
authorElijah Newren <newren@gmail.com>
Thu, 3 Oct 2019 20:27:04 +0000 (13:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Oct 2019 22:33:21 +0000 (07:33 +0900)
Mark identifiers are used in fast-export and fast-import to provide a
label to refer to earlier content.  Blobs are given labels because they
need to be referenced in the commits where they first appear with a
given filename, and commits are given labels because they can be the
parents of other commits.  Tags were never given labels, probably
because they were viewed as unnecessary, but that presents two problems:

   1. It leaves us without a way of referring to previous tags if we
      want to create a tag of a tag (or higher nestings).
   2. It leaves us with no way of recording that a tag has already been
      imported when using --export-marks and --import-marks.

Fix these problems by allowing an optional mark label for tags.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fast-import.txt
fast-import.c
t/t9300-fast-import.sh

index 0bb2762..4977869 100644 (file)
@@ -774,6 +774,7 @@ lightweight (non-annotated) tags see the `reset` command below.
 
 ....
        'tag' SP <name> LF
+       mark?
        'from' SP <commit-ish> LF
        original-oid?
        'tagger' (SP <name>)? SP LT <email> GT SP <when> LF
index caae081..5b9e9e3 100644 (file)
@@ -2713,6 +2713,7 @@ static void parse_new_tag(const char *arg)
                first_tag = t;
        last_tag = t;
        read_next_command();
+       parse_mark();
 
        /* from ... */
        if (!skip_prefix(command_buf.buf, "from ", &from))
@@ -2769,7 +2770,7 @@ static void parse_new_tag(const char *arg)
        strbuf_addbuf(&new_data, &msg);
        free(tagger);
 
-       if (store_object(OBJ_TAG, &new_data, NULL, &t->oid, 0))
+       if (store_object(OBJ_TAG, &new_data, NULL, &t->oid, next_mark))
                t->pack_id = MAX_PACK_ID;
        else
                t->pack_id = pack_id;
index 74bc413..3ad2b2f 100755 (executable)
@@ -94,6 +94,23 @@ test_expect_success 'A: create pack from stdin' '
        reset refs/tags/to-be-deleted
        from 0000000000000000000000000000000000000000
 
+       tag nested
+       mark :6
+       from :4
+       data <<EOF
+       Tag of our lovely commit
+       EOF
+
+       reset refs/tags/nested
+       from 0000000000000000000000000000000000000000
+
+       tag nested
+       mark :7
+       from :6
+       data <<EOF
+       Tag of tag of our lovely commit
+       EOF
+
        INPUT_END
        git fast-import --export-marks=marks.out <input &&
        git whatchanged master
@@ -176,6 +193,8 @@ test_expect_success 'A: verify marks output' '
        :3 $(git rev-parse --verify master:file3)
        :4 $(git rev-parse --verify master:file4)
        :5 $(git rev-parse --verify master^0)
+       :6 $(git cat-file tag nested | grep object | cut -d" " -f 2)
+       :7 $(git rev-parse --verify nested)
        EOF
        test_cmp expect marks.out
 '