]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-export: add support to delete refs
authorFelipe Contreras <felipe.contreras@gmail.com>
Sun, 20 Apr 2014 18:59:28 +0000 (13:59 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Apr 2014 18:47:34 +0000 (11:47 -0700)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c
t/t9350-fast-export.sh

index ad9c17e8e78bb86066aea807d8e0ce9ba68c5897..ef4481615fd2f4d60cd3cd6a4bbcceaca93c92d5 100644 (file)
@@ -673,6 +673,19 @@ static void import_marks(char *input_file)
        fclose(f);
 }
 
+static void handle_deletes(void)
+{
+       int i;
+       for (i = 0; i < refspecs_nr; i++) {
+               struct refspec *refspec = &refspecs[i];
+               if (*refspec->src)
+                       continue;
+
+               printf("reset %s\nfrom %s\n\n",
+                               refspec->dst, sha1_to_hex(null_sha1));
+       }
+}
+
 int cmd_fast_export(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
@@ -764,6 +777,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
        }
 
        handle_tags_and_duplicates();
+       handle_deletes();
 
        if (export_filename && lastimportid != last_idnum)
                export_marks(export_filename);
index 3d475af173fffbc0b85f8cbc9950bcec58b9daa5..66c8b0a371e37f90cff8da0c92f09c8784ec45a2 100755 (executable)
@@ -511,4 +511,15 @@ test_expect_success 'use refspec' '
        test_cmp expected actual
 '
 
+test_expect_success 'delete refspec' '
+       git branch to-delete &&
+       git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual &&
+       cat > expected <<-EOF &&
+       reset refs/heads/to-delete
+       from 0000000000000000000000000000000000000000
+
+       EOF
+       test_cmp expected actual
+'
+
 test_done