Edgewall Software
Modify

Opened 2 years ago

Closed 2 years ago

#12557 closed defect (fixed)

Incorrect file in zip archive for git repository

Reported by: roand@… Owned by: Jun Omae
Priority: normal Milestone: 1.0.13
Component: plugin/git Version: 1.0.12
Severity: normal Keywords:
Cc:
Release Notes:

Fixed using incorrect revisions when downloading a zip file via browser page with Git repository.

API 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)

test_git.tar.gz (11.1 KB ) - added by anonymous 2 years ago.
20160810T123503.png (10.3 KB ) - added by Jun Omae 2 years ago.

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by anonymous

Attachment: test_git.tar.gz added

Changed 2 years ago by Jun Omae

Attachment: 20160810T123503.png added

comment:1 Changed 2 years ago by Jun Omae

Resolution: worksforme
Status: newclosed

Works for me. Please post how to reproduce it and what you expect if you have the issue.

comment:2 Changed 2 years ago by Jun Omae

Resolution: worksforme
Status: closedreopened

Okay. Reproduced it:

  1. Extract test_git.tar.gz to /tmp
  2. Execute repository add t12557 /tmp/test_git/.git git
  3. Set /* to [browser] downloadable_paths
  4. Visit /browser/t12557
  5. Download a zip file via Zip Archive link in Download in other formats
  6. A/a1.txt file contains a1 in the zip file, that should be a1-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 Changed 2 years ago by Jun Omae

Milestone: next-stable-1.0.x1.0.13
Owner: set to Jun Omae
Status: reopenedassigned

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):  
    645645            rev = repos.normalize_rev(to_unicode(rev))
    646646        else:
    647647            rev = repos.youngest_rev
     648        created_rev = rev
    648649
    649650        kind = Node.DIRECTORY
    650651        p = path.strip('/')
    class GitNode(Node):  
    662663            self.fs_perm, k, self.fs_sha, self.fs_size, fname = ls_tree_info
    663664
    664665            # 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)
    666667
    667668            if k == 'tree':
    668669                pass
    class GitNode(Node):  
    677678                                  "kind '%(kind)s')", kind=k))
    678679
    679680        self.created_path = path
    680         self.created_rev = rev
     681        self.created_rev = created_rev
    681682
    682683        Node.__init__(self, repos, path, rev, kind)
    683684

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:4 Changed 2 years ago by Jun Omae

Proposed changes in [7320f2e28/jomae.git].

comment:5 Changed 2 years ago by roand@…

The patch works. Thank you for operational patch!

comment:6 Changed 2 years ago by Jun Omae

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [15044] and merged in [15045-15046].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.