[PATCH v6 09/10] fast-export: add support to delete refs

2013-11-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.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 cf745ec..4b76222 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 
+
+   EOF
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 09/10] fast-export: add support to delete refs

2013-11-11 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.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 cf745ec..4b76222 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 
+
+   EOF
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html