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

[PATCH v3 6/7] remote-bzr: add support for fecthing special modes

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 11, 2012, 14:19 UTC
Message-ID
<1352643598-8500-7-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1352643598-8500-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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 5b89a05..2bae5d0 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 8594ffc..c92d0c6 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 <<EOF
+100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
+100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
+120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
+EOF
+
+test_expect_success 'special modes' '
+  (cd bzrrepo &&
+  echo exec > 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
-- 
1.8.0
Previous: Junio C HamanoNext: Felipe Contreras
Message 13 of 26 in “New remote-bzr remote helper”
  1. 0/7 New remote-bzr remote helperFelipe Contreras, Nov 11, 2012
  2. 1/7 Add new remote-bzr transport helperFelipe Contreras, Nov 11, 2012
  3. 2/7 remote-bzr: add support for pushingFelipe Contreras, Nov 11, 2012
  4. 3/7 remote-bzr: add support for remote repositoriesFelipe Contreras, Nov 11, 2012
  5. 4/7 remote-bzr: update working treeFelipe Contreras, Nov 11, 2012
  6. Junio C HamanoNov 28, 2012
  7. Felipe ContrerasDec 13, 2012
  8. Junio C HamanoDec 13, 2012
  9. Junio C HamanoDec 13, 2012
  10. Felipe ContrerasDec 14, 2012
  11. 5/7 remote-bzr: add simple testsFelipe Contreras, Nov 11, 2012
  12. Junio C HamanoNov 28, 2012
  13. 6/7 remote-bzr: add support for fecthing special modesFelipe Contreras, Nov 11, 2012
  14. 7/7 remote-bzr: add support to push special modesFelipe Contreras, Nov 11, 2012
  15. Felipe ContrerasNov 24, 2012
  16. Junio C HamanoNov 26, 2012
  17. Felipe ContrerasNov 26, 2012
  18. Junio C HamanoNov 27, 2012
  19. Felipe ContrerasNov 28, 2012
  20. Junio C HamanoNov 28, 2012
  21. Felipe ContrerasNov 28, 2012
  22. Junio C HamanoNov 28, 2012
  23. Felipe ContrerasNov 28, 2012
  24. Junio C HamanoNov 28, 2012
  25. Felipe ContrerasNov 28, 2012
  26. Felipe ContrerasNov 28, 2012

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.