From bdeeb809d75b71bc9bdc3ed1b4ebc64e3d965840 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 11 Nov 2012 15:19:57 +0100 Subject: [PATCH] remote-bzr: add support for fecthing special modes Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/git-remote-bzr | 38 +++++++++++++++++++-------- contrib/remote-helpers/test-bzr.sh | 32 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index 5b89a0537..2bae5d034 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -198,23 +198,39 @@ def export_files(tree, files): final = [] for path, fid in files.iteritems(): + kind = tree.kind(fid) + h = tree.get_file_sha1(fid) - mode = '100644' + if kind == 'symlink': + d = tree.get_symlink_target(fid) + mode = '120000' + elif kind == 'file': + + if tree.is_executable(fid): + mode = '100755' + else: + mode = '100644' + + # is the blog already exported? + if h in filenodes: + mark = filenodes[h] + final.append((mode, mark, path)) + continue - # is the blob already exported? - if h in filenodes: - mark = filenodes[h] - else: d = tree.get_file_text(fid) + elif kind == 'directory': + continue + else: + die("Unhandled kind '%s' for path '%s'" % (kind, path)) - mark = marks.next_mark() - filenodes[h] = mark + mark = marks.next_mark() + filenodes[h] = mark - print "blob" - print "mark :%u" % mark - print "data %d" % len(d) - print d + print "blob" + print "mark :%u" % mark + print "data %d" % len(d) + print d final.append((mode, mark, path)) diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh index 7ab7951d5..70aa8a010 100755 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@ -108,4 +108,36 @@ test_expect_success 'roundtrip' ' test_cmp expected actual ' +cat > expected < executable + chmod +x executable && + bzr add executable + bzr commit -m exec && + ln -s content link + bzr add link + bzr commit -m link && + mkdir dir && + bzr add dir && + bzr commit -m dir) && + + (cd gitrepo && + git pull + git ls-tree HEAD > ../actual) && + + test_cmp expected actual && + + (cd gitrepo && + git cat-file -p HEAD:link > ../actual) && + + echo -n content > expected && + test_cmp expected actual +' + test_done -- 2.26.2