Edgewall Software
Modify

Opened 2 years ago

Closed 2 years ago

Last modified 15 months ago

#13509 closed defect (fixed)

Git unit test failures on 1.4-stable with git version 2.39.0

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.4.4
Component: plugin/git Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Fixed Git unit test failures when init.defaultBranch is configured and transport 'file' is not allowed.

Description

Several of these can be worked-around by running:

$ git config --global init.defaultBranch master
$ make status

Python: /Users/rjollos/.pyenv/shims/python

  Package        Version
  ----------------------------------------------------------
  Python       : 2.7.18 (default, May 21 2021, 10:46:44)
               : [GCC Apple LLVM 12.0.5 (clang-1205.0.22.9)]
  Setuptools   : 44.1.1
  Pip          : 20.3.4
  Wheel        : 0.36.2
  Jinja2       : 2.11.3
  Genshi       : 0.7.5 (with speedups)
  Babel        : 2.9.1
  sqlite3      : 2.6.0 (3.40.0)
  PySqlite     : not installed
  PyMySQL      : 0.10.1
  Psycopg2     : 2.8.6 (dt dec pq3 ext lo64)
  SVN bindings : 1.13.0 (r1867053)
  Mercurial    : 5.8
  Pygments     : 2.5.2
  Textile      : 3.0.4
  Pytz         : 2021.1
  Docutils     : 0.17.1
  Twill        : 0.9
  LXML         : 4.6.3
  coverage     : 5.5

Variables:
  PATH=/Users/rjollos/Documents/Workspace/trac-dev/bin:/Users/rjollos/.pyenv/shims:/usr/local/opt/sqlite/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/munki:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Users/rjollos/.pyenv/bin
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 8000 -a '*,/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/htdigest.trac,trac' -r -e /Users/rjollos/Documents/Workspace/trac-dev/tracenvs

External dependencies:
  Git version: git version 2.39.0
  Subversion version: 1.13.0
======================================================================
ERROR: test_get_annotations (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 599, in test_get_annotations
    repos.get_node('test.txt', 'HEAD').get_annotations())
  File "tracopt/versioncontrol/git/git_fs.py", line 580, in get_node
    return self._get_node(path, rev)
  File "tracopt/versioncontrol/git/git_fs.py", line 583, in _get_node
    return GitNode(self, path, rev, self.log, ls_tree_info, historian)
  File "tracopt/versioncontrol/git/git_fs.py", line 698, in __init__
    rev = repos.normalize_rev(to_unicode(rev))
  File "tracopt/versioncontrol/git/git_fs.py", line 569, in normalize_rev
    raise NoSuchChangeset(rev)
NoSuchChangeset: No changeset HEAD in the repository

======================================================================
ERROR: test_get_annotations (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 599, in test_get_annotations
    repos.get_node('test.txt', 'HEAD').get_annotations())
  File "trac/versioncontrol/cache.py", line 311, in get_node
    return self.repos.get_node(path, self.normalize_rev(rev))
  File "tracopt/versioncontrol/git/git_fs.py", line 55, in normalize_rev
    raise NoSuchChangeset(rev)
NoSuchChangeset: No changeset HEAD in the repository

======================================================================
FAIL: test_remove_simple_keys (trac.db.tests.sqlite_test.SQLiteConnectionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/db/tests/sqlite_test.py", line 186, in test_remove_simple_keys
    coldef['enabled'], coldef['extra']], columns_0)
AssertionError: Lists differ: [{'column': 'id', 'default': N... != [{'column': u'id', 'default': ...

First differing element 0:
{'column': 'id', 'default': None, 'type': 'integer', 'pk': 1, 'notnull': 0}
{'column': u'id', 'default': None, 'type': u'INTEGER', 'pk': 1, 'notnull': 0}

Diff is 1333 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_get_branches_with_cr_in_commitlog (tracopt.versioncontrol.git.tests.PyGIT.NormalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/PyGIT.py", line 205, in test_get_branches_with_cr_in_commitlog
    self.assertEqual('master', branches[0][0])
AssertionError: 'master' != u'main'

======================================================================
FAIL: test_sync_after_removing_branch (tracopt.versioncontrol.git.tests.PyGIT.NormalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/PyGIT.py", line 258, in test_sync_after_removing_branch
    self._git('checkout', '-b', 'b1', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('checkout', '-b', 'b1', 'master'), kwargs {}, stdout '', stderr "fatal: 'master' is not a commit and a branch 'b1' cannot be created from it\n"

======================================================================
FAIL: test_unicode_branches (tracopt.versioncontrol.git.tests.PyGIT.UnicodeNameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/PyGIT.py", line 364, in test_unicode_branches
    self._git('checkout', '-b', 'tickɇt10980', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('checkout', '-b', 'tick\xc9\x87t10980', 'master'), kwargs {}, stdout '', stderr "fatal: 'master' is not a commit and a branch 'tick\xc9\x87t10980' cannot be created from it\n"

======================================================================
FAIL: test_unicode_tags (tracopt.versioncontrol.git.tests.PyGIT.UnicodeNameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/PyGIT.py", line 380, in test_unicode_tags
    self._git('tag', 'tɐg-t10980', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('tag', 't\xc9\x90g-t10980', 'master'), kwargs {}, stdout '', stderr "fatal: Failed to resolve 'master' as a valid ref.\n"

======================================================================
FAIL: test_unicode_verifyrev (tracopt.versioncontrol.git.tests.PyGIT.UnicodeNameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/PyGIT.py", line 345, in test_unicode_verifyrev
    self.assertIsNotNone(storage.verifyrev(u'master'))
AssertionError: unexpectedly None

======================================================================
FAIL: test_get_node (tracopt.versioncontrol.git.tests.git_fs.GitNormalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 284, in test_get_node
    self._git('branch', u'tïckét10605', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('branch', u't\xefck\xe9t10605', 'master'), kwargs {}, stdout '', stderr "fatal: not a valid object name: 'master'\n"

======================================================================
FAIL: test_branchs (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 429, in test_branchs
    self.assertEqual(['master'], self._get_quickjump_names(repos))
AssertionError: Lists differ: ['master'] != [u'main']

First differing element 0:
'master'
u'main'

- ['master']
+ [u'main']

======================================================================
FAIL: test_changeset_branches_tags (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 442, in test_changeset_branches_tags
    self._git('tag', '0.0.1', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('tag', '0.0.1', 'master'), kwargs {}, stdout '', stderr "fatal: Failed to resolve 'master' as a valid ref.\n"

======================================================================
FAIL: test_parent_child_revs (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 471, in test_parent_child_revs
    self._create_merge_commit()
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 354, in _create_merge_commit
    self._git('checkout', '-b', branch, 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('checkout', '-b', 'alpha', 'master'), kwargs {}, stdout '', stderr "fatal: 'master' is not a commit and a branch 'alpha' cannot be created from it\n"

======================================================================
FAIL: test_submodule (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 861, in test_submodule
    self._git('submodule', 'add', subrepos_path, 'sub')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('submodule', 'add', '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-pI7Rim/subrepos', 'sub'), kwargs {}, stdout '', stderr "Cloning into '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-pI7Rim/gitrepos/sub'...\nfatal: transport 'file' not allowed\nfatal: clone of '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-pI7Rim/subrepos' into submodule path '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-pI7Rim/gitrepos/sub' failed\n"

======================================================================
FAIL: test_tags (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 416, in test_tags
    self.assertEqual(['master'], self._get_quickjump_names(repos))
AssertionError: Lists differ: ['master'] != [u'main']

First differing element 0:
'master'
u'main'

- ['master']
+ [u'main']

======================================================================
FAIL: test_branchs (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 429, in test_branchs
    self.assertEqual(['master'], self._get_quickjump_names(repos))
AssertionError: Lists differ: ['master'] != [u'main']

First differing element 0:
'master'
u'main'

- ['master']
+ [u'main']

======================================================================
FAIL: test_changeset_branches_tags (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 442, in test_changeset_branches_tags
    self._git('tag', '0.0.1', 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('tag', '0.0.1', 'master'), kwargs {}, stdout '', stderr "fatal: Failed to resolve 'master' as a valid ref.\n"

======================================================================
FAIL: test_parent_child_revs (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 471, in test_parent_child_revs
    self._create_merge_commit()
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 354, in _create_merge_commit
    self._git('checkout', '-b', branch, 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('checkout', '-b', 'alpha', 'master'), kwargs {}, stdout '', stderr "fatal: 'master' is not a commit and a branch 'alpha' cannot be created from it\n"

======================================================================
FAIL: test_submodule (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 861, in test_submodule
    self._git('submodule', 'add', subrepos_path, 'sub')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('submodule', 'add', '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-CWF3gS/subrepos', 'sub'), kwargs {}, stdout '', stderr "Cloning into '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-CWF3gS/gitrepos/sub'...\nfatal: transport 'file' not allowed\nfatal: clone of '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-CWF3gS/subrepos' into submodule path '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-CWF3gS/gitrepos/sub' failed\n"

======================================================================
FAIL: test_sync_merge (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 1020, in test_sync_merge
    self._create_merge_commit()
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 354, in _create_merge_commit
    self._git('checkout', '-b', branch, 'master')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('checkout', '-b', 'alpha', 'master'), kwargs {}, stdout '', stderr "fatal: 'master' is not a commit and a branch 'alpha' cannot be created from it\n"

======================================================================
FAIL: test_tags (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 416, in test_tags
    self.assertEqual(['master'], self._get_quickjump_names(repos))
AssertionError: Lists differ: ['master'] != [u'main']

First differing element 0:
'master'
u'main'

- ['master']
+ [u'main']

----------------------------------------------------------------------
Ran 2753 tests in 181.243s

FAILED (failures=18, errors=2)
make: *** [unit-test] Error 1

Attachments (0)

Change History (8)

comment:1 by Ryan J Ollos, 2 years ago

With the workaround, still 3 failures, once of which is #13478.

======================================================================
FAIL: test_remove_simple_keys (trac.db.tests.sqlite_test.SQLiteConnectionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/db/tests/sqlite_test.py", line 186, in test_remove_simple_keys
    coldef['enabled'], coldef['extra']], columns_0)
AssertionError: Lists differ: [{'column': 'id', 'default': N... != [{'column': u'id', 'default': ...

First differing element 0:
{'column': 'id', 'default': None, 'type': 'integer', 'pk': 1, 'notnull': 0}
{'column': u'id', 'default': None, 'type': u'INTEGER', 'pk': 1, 'notnull': 0}

Diff is 1333 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_submodule (tracopt.versioncontrol.git.tests.git_fs.GitRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 861, in test_submodule
    self._git('submodule', 'add', subrepos_path, 'sub')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('submodule', 'add', '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-uUXuU2/subrepos', 'sub'), kwargs {}, stdout '', stderr "Cloning into '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-uUXuU2/gitrepos/sub'...\nfatal: transport 'file' not allowed\nfatal: clone of '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-uUXuU2/subrepos' into submodule path '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-uUXuU2/gitrepos/sub' failed\n"

======================================================================
FAIL: test_submodule (tracopt.versioncontrol.git.tests.git_fs.GitCachedRepositoryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 861, in test_submodule
    self._git('submodule', 'add', subrepos_path, 'sub')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 65, in _git
    (proc.returncode, args, kwargs, stdout, stderr))
AssertionError: git exits with 128, args ('submodule', 'add', '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-nPhrWI/subrepos', 'sub'), kwargs {}, stdout '', stderr "Cloning into '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-nPhrWI/gitrepos/sub'...\nfatal: transport 'file' not allowed\nfatal: clone of '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-nPhrWI/subrepos' into submodule path '/private/var/folders/qf/y5yt86vn54j_sy7dv1f8hb3r0000gp/T/trac-testdir-nPhrWI/gitrepos/sub' failed\n"

----------------------------------------------------------------------
Ran 2753 tests in 188.560s

FAILED (failures=3)
make: *** [unit-test] Error 1

comment:2 by Ryan J Ollos, 2 years ago

Component: generalplugin/git
Summary: Unit test failures on 1.4-stableGit unit test failures on 1.4-stable with git version 2.39.0

comment:3 by Jun Omae, 2 years ago

It seems the issue is caused by init.defaultBranch = main configured in your ~/.gitconfig file.

  • tracopt/versioncontrol/git/tests/git_fs.py

    diff --git a/tracopt/versioncontrol/git/tests/git_fs.py b/tracopt/versioncontrol/git/tests/git_fs.py
    index 109d93be2..52cd4e8e2 100644
    a b class GitCommandMixin(object):  
    4949        return self._git(*args, **kwargs)
    5050
    5151    def _spawn_git(self, *args, **kwargs):
    52         args = map(to_utf8, (self.git_bin,) + args)
     52        args = map(to_utf8, (self.git_bin, '-c', 'init.defaultBranch=master') +
     53                            args)
    5354        kwargs.setdefault('stdin', PIPE)
    5455        kwargs.setdefault('stdout', PIPE)
    5556        kwargs.setdefault('stderr', PIPE)

comment:4 by Jun Omae, 2 years ago

The git submodule add failed with fatal: transport 'file' not allowed. The behavior is introduced in 2.30.x and later for CVE-2022-39253. See https://github.blog/2022-10-18-git-security-vulnerabilities-announced/.

Cloning into '/path/to/tmpdir/trac-testdir-nPhrWI/gitrepos/sub'...
fatal: transport 'file' not allowed
fatal: clone of '/path/to/tmpdir/trac-testdir-nPhrWI/subrepos' into submodule path '/path/to/tmpdir/trac-testdir-nPhrWI/gitrepos/sub' failed

Work around is passing -c protocol.file.allow=always to git command.

  • tracopt/versioncontrol/git/tests/git_fs.py

    diff --git a/tracopt/versioncontrol/git/tests/git_fs.py b/tracopt/versioncontrol/git/tests/git_fs.py
    index 109d93be2..54ab3d92e 100644
    a b class GitCommandMixin(object):  
    5757        return Popen(args, close_fds=close_fds, **kwargs)
    5858
    5959    def _git(self, *args, **kwargs):
     60        args = ('-c', 'init.defaultBranch=master',
     61                '-c', 'protocol.file.allow=always') + args
    6062        with self._spawn_git(*args, **kwargs) as proc:
    6163            stdout, stderr = proc.communicate()
    6264        self.assertEqual(0, proc.returncode,

comment:5 by Ryan J Ollos, 2 years ago

Thanks! The tests pass on macOS with those changes. Do you want to push them?

comment:6 by Jun Omae, 2 years ago

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

Thanks for the testing! Also, I tested with Git 2.20.x - 2.39.0 on Ubuntu 20.04, now.

I just pushed in [17610] and merged into trunk in [17611].

comment:7 by Jun Omae, 2 years ago

Owner: set to Jun Omae
Release Notes: modified (diff)

comment:8 by Ryan J Ollos, 15 months ago

Internal Changes: modified (diff)
Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
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.