Opened 8 years ago
Closed 8 years ago
#12557 closed defect (fixed)
Incorrect file in zip archive for git repository
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.13 |
Component: | plugin/git | Version: | 1.0.12 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Fixed using incorrect revisions when downloading a zip file via browser page with Git repository. |
||
API Changes: | |||
Internal Changes: |
Description
Incorrect file in zip archive for git repository. In repository "test_git.tar.gz" a file "A/a1.txt" of last commit must contains:
a1-1
A file "A/a1.txt" of zip archive for git repository contains:
a1
Attachments (2)
Change History (8)
by , 8 years ago
Attachment: | test_git.tar.gz added |
---|
by , 8 years ago
Attachment: | 20160810T123503.png added |
---|
comment:1 by , 8 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Okay. Reproduced it:
- Extract test_git.tar.gz to /tmp
- Execute
repository add t12557 /tmp/test_git/.git git
- Set
/*
to[browser] downloadable_paths
- Visit
/browser/t12557
- Download a zip file via
Zip Archive
link in Download in other formats A/a1.txt
file containsa1
in the zip file, that should bea1-1
$ curl -s 'http://127.0.0.1/browser/t12557/?rev=add4fc1ec1d3237ad1cf585bb122c88fcefc23cc&format=zip' > /tmp/t12557.zip $ unzip -l /tmp/t12557.zip Archive: /tmp/t12557.zip Length Date Time Name --------- ---------- ----- ---- 0 1980-01-01 00:00 A/ 2 2016-08-09 21:04 A/a1.txt 4 2016-08-09 21:10 A/a2.txt 0 1980-01-01 00:00 B/ 4 2016-08-09 21:05 B/b1.txt 4 2016-08-09 21:12 B/b2.txt --------- ------- 14 6 files $ unzip -p /tmp/t12557.zip A/a1.txt | od -c 0000000 a 1 0000002
However, the A/a1.txt
file in zip file downloaded from A
directory is correct.
$ curl -s 'http://127.0.0.1/browser/t12557/A?rev=add4fc1ec1d3237ad1cf585bb122c88fcefc23cc&format=zip' > /tmp/t12557-A.zip $ unzip -l /tmp/t12557-A.zip Archive: /tmp/t12557-A.zip Length Date Time Name --------- ---------- ----- ---- 4 2016-08-09 21:08 A/a1.txt 4 2016-08-09 21:10 A/a2.txt --------- ------- 8 2 files $ unzip -p /tmp/t12557-A.zip A/a1.txt | od -c 0000000 a 1 - 1 0000004
comment:3 by , 8 years ago
Milestone: | next-stable-1.0.x → 1.0.13 |
---|---|
Owner: | set to |
Status: | reopened → assigned |
It seems this issue occurs when GitNode.get_entries()
is recursively called via BrowserModule._iter_nodes()
. The _iter_nodes()
is used only in generating zip files.
>>> for node in BrowserModule(env)._iter_nodes(repos.get_node('')): ... node.rev, node.created_rev, node.path ... ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', u'') ('4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', '4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', u'A') ('7585aec50c0b0472e5a69b7f97bc045f9078c638', '7585aec50c0b0472e5a69b7f97bc045f9078c638', u'A/a1.txt') ('4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', '4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', u'A/a2.txt') ('f62fd985f264fa02f86605bd89f5fc3e7bd7941c', 'f62fd985f264fa02f86605bd89f5fc3e7bd7941c', u'B') ('cab4b75bbcdaf0b69e8f99feef07a7c63fe10b89', 'cab4b75bbcdaf0b69e8f99feef07a7c63fe10b89', u'B/b1.txt') ('f62fd985f264fa02f86605bd89f5fc3e7bd7941c', 'f62fd985f264fa02f86605bd89f5fc3e7bd7941c', u'B/b2.txt')
The created_rev
attribute of node A/a1.txt
should be eb818d752971e1bc5f8311bae49850a3f1d34da5
, not 7585aec50c0b0472e5a69b7f97bc045f9078c638
.
$ git log --oneline --no-abbrev-commit --name-status --graph -- * add4fc1ec1d3237ad1cf585bb122c88fcefc23cc Merge branch 'A' |\ | * 940380b367d996b384b82315ea581e13e0c55b18 Merge branch 'B' into A | |\ | | * eb818d752971e1bc5f8311bae49850a3f1d34da5 Changed a1 | | | M A/a1.txt | * | 4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185 Changed a2 | | | M A/a2.txt * | | f62fd985f264fa02f86605bd89f5fc3e7bd7941c Changed b2 | |/ |/| | | M B/b2.txt * | bd7ecb85de78c7790f942355da3a619676a694e5 Changed b2 | | M B/b2.txt * | cab4b75bbcdaf0b69e8f99feef07a7c63fe10b89 Changed b1 |/ | M B/b1.txt * 7585aec50c0b0472e5a69b7f97bc045f9078c638 First commit A A/a1.txt A A/a2.txt A B/b1.txt A B/b2.txt
Please try the following patch. I'll add unit test for this issue.
-
tracopt/versioncontrol/git/git_fs.py
diff --git a/tracopt/versioncontrol/git/git_fs.py b/tracopt/versioncontrol/git/git_fs.py index 77bc95013..333324303 100644
a b class GitNode(Node): 645 645 rev = repos.normalize_rev(to_unicode(rev)) 646 646 else: 647 647 rev = repos.youngest_rev 648 created_rev = rev 648 649 649 650 kind = Node.DIRECTORY 650 651 p = path.strip('/') … … class GitNode(Node): 662 663 self.fs_perm, k, self.fs_sha, self.fs_size, fname = ls_tree_info 663 664 664 665 # fix-up to the last commit-rev that touched this node 665 rev = repos.git.last_change(rev, p, historian)666 created_rev = repos.git.last_change(rev, p, historian) 666 667 667 668 if k == 'tree': 668 669 pass … … class GitNode(Node): 677 678 "kind '%(kind)s')", kind=k)) 678 679 679 680 self.created_path = path 680 self.created_rev = rev681 self.created_rev = created_rev 681 682 682 683 Node.__init__(self, repos, path, rev, kind) 683 684
After the patch:
>>> for node in BrowserModule(env)._iter_nodes(repos.get_node('')): ... node.rev, node.created_rev, node.path ... ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', u'') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', '4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', u'A') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'eb818d752971e1bc5f8311bae49850a3f1d34da5', u'A/a1.txt') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', '4b3ce925a1af49aca2b5f2397b9a35f8bc4c4185', u'A/a2.txt') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'f62fd985f264fa02f86605bd89f5fc3e7bd7941c', u'B') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'cab4b75bbcdaf0b69e8f99feef07a7c63fe10b89', u'B/b1.txt') ('add4fc1ec1d3237ad1cf585bb122c88fcefc23cc', 'f62fd985f264fa02f86605bd89f5fc3e7bd7941c', u'B/b2.txt')
comment:6 by , 8 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed in [15044] and merged in [15045-15046].
Works for me. Please post how to reproduce it and what you expect if you have the issue.