git-remote-testgit: import non-HEAD refs
Upon receiving an "import" command, the testgit remote helper would ignore the ref asked for by git and generate a fast-export stream based on HEAD. Instead, we should actually give git the ref it asked for. This requires adding a new parameter to the export_repo method in the remote-helpers python library, which may be used by code outside of git.git. We use a default parameter so that callers without the new parameter will get the same behavior as before. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 16, 2011 at 15:03 UTC
4e51ba238fb92ad732b4d34200fc8f53e29b333f
3 files changed
+9
-4
git-remote-testgit.py
+1
-1
@@ -122,7 +122,7 @@ def do_import(repo, args):
122
die("Need gitdir to import")
123
124
repo = update_local_repo(repo)
125
- repo.exporter.export_repo(repo.gitdir)
125
+ repo.exporter.export_repo(repo.gitdir, args)
126
127
128
def do_export(repo, args):
git_remote_helpers/git/exporter.py
+7
-2
@@ -15,7 +15,7 @@ class GitExporter(object):
15
16
self.repo = repo
17
18
- def export_repo(self, base):
18
+ def export_repo(self, base, refs=None):
19
"""Exports a fast-export stream for the given directory.
20
21
Simply delegates to git fast-epxort and pipes it through sed
@@ -23,8 +23,13 @@ class GitExporter(object):
23
default refs/heads. This is to demonstrate how the export
24
data can be stored under it's own ref (using the refspec
25
capability).
26
+
27
+ If None, refs defaults to ["HEAD"].
28
"""
29
30
+ if not refs:
31
+ refs = ["HEAD"]
32
+
33
dirname = self.repo.get_base_path(base)
34
path = os.path.abspath(os.path.join(dirname, 'testgit.marks'))
35
@@ -42,7 +47,7 @@ class GitExporter(object):
47
if os.path.exists(path):
48
args.append("--import-marks=" + path)
49
45
- args.append("HEAD")
50
+ args.extend(refs)
51
52
p1 = subprocess.Popen(args, stdout=subprocess.PIPE)
53
t/t5800-remote-helpers.sh
+1
-1
@@ -85,7 +85,7 @@ test_expect_success 'pushing remote local repo' '
85
compare_refs clone HEAD server HEAD
86
'
87
88
-test_expect_failure 'fetch new branch' '
88
+test_expect_success 'fetch new branch' '
89
(cd public &&
90
git checkout -b new &&
91
echo content >>file &&