Skip to content

Commit

Permalink
fast-export: add support to delete refs
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 21, 2014
1 parent 4ee1b22 commit 60ed264
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions t/t9350-fast-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 60ed264

Please sign in to comment.