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

[PATCH 6/8] fast-export: add support to delete refs

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 20, 2014, 18:59 UTC
Message-ID
<1398020370-11406-7-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1398020370-11406-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/fast-export.c  | 14 ++++++++++++++
 t/t9350-fast-export.sh | 11 +++++++++++
 2 files changed, 25 insertions(+)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index ad9c17e..ef44816 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -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);
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 3d475af..66c8b0a 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -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
-- 
1.9.1+fc3.9.gc73078e
Previous: Felipe ContrerasNext: Felipe Contreras
Message 7 of 9 in “transport-helper: refspec support”
  1. 0/8 transport-helper: refspec supportFelipe Contreras, Apr 20, 2014
  2. 1/8 fast-export: improve argument parsingFelipe Contreras, Apr 20, 2014
  3. 2/8 fast-export: add new --refspec optionFelipe Contreras, Apr 20, 2014
  4. 3/8 transport-helper: add support for old:new refspecFelipe Contreras, Apr 20, 2014
  5. 4/8 transport-helper: add support to push symbolic refsFelipe Contreras, Apr 20, 2014
  6. 5/8 fast-import: add support to delete refsFelipe Contreras, Apr 20, 2014
  7. 6/8 fast-export: add support to delete refsFelipe Contreras, Apr 20, 2014
  8. 7/8 transport-helper: add support to delete branchesFelipe Contreras, Apr 20, 2014
  9. 8/8 transport-helper: remove unnecessary strbuf resetsFelipe Contreras, Apr 20, 2014

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.