◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,5 @@ def register_surrogateescape():

try:
b"100644 \x9f\0aaa".decode(defenc, "surrogateescape")
except:
register_surrogateescape()
3 changes: 2 additions & 1 deletion git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def read(self):
if include_path in seen or not os.access(include_path, os.R_OK):
continue
seen.add(include_path)
files_to_read.append(include_path)
num_read_include_files += 1
# each include path in configuration file
# end handle includes
Expand Down
14 changes: 7 additions & 7 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,20 @@ def __str__(self):
h %= self.b_blob.path

msg = ''
l = None # temp line
ll = 0 # line length
for b, n in zip((self.a_blob, self.b_blob), ('lhs', 'rhs')):
if b:
l = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
else:
l = "\n%s: None" % n
# END if blob is not None
ll = max(len(l), ll)
msg += l
# END for each blob

# add headline
h += '\n' + '=' * ll

if self.deleted_file:
msg += '\nfile deleted in rhs'
Expand Down
2 changes: 1 addition & 1 deletion git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, command, status=None, stderr=None, stdout=None):
else:
try:
status = u'exit code(%s)' % int(status)
except:
s = safe_decode(str(status))
status = u"'%s'" % s if isinstance(status, string_types) else s

Expand Down
2 changes: 1 addition & 1 deletion git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def to_file(self, filepath):
try:
self._serialize(fp)
lfd.commit()
except:
# on failure it rolls back automatically, but we make it clear
lfd.rollback()
raise
Expand Down
8 changes: 5 additions & 3 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,11 @@ def urls(self):
if ' Push URL:' in line:
yield line.split(': ')[-1]
except GitCommandError as ex:
if any([msg in str(ex) for msg in ['correct access rights','cannot run ssh']]):
# If ssh is not setup to access this repository, see issue 694
result = Git().execute(['git','config','--get','remote.%s.url' % self.name])
yield result
else:
raise ex
Expand Down
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __del__(self):
try:
self.close()
except:
pass

def close(self):
Expand Down
12 changes: 8 additions & 4 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import unittest

TestCase = unittest.TestCase

ospd = osp.dirname

Expand All @@ -37,7 +39,9 @@

__all__ = (
'fixture_path', 'fixture', 'StringProcessAdapter',
'with_rw_directory', 'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase',
'GIT_REPO', 'GIT_DAEMON_PORT'
)

Expand Down Expand Up @@ -139,7 +143,7 @@ def repo_creator(self):
try:
try:
return func(self, rw_repo)
except:
log.info("Keeping repo after failure: %s", repo_dir)
repo_dir = None
raise
Expand Down Expand Up @@ -227,7 +231,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
Same as with_rw_repo, but also provides a writable remote repository from which the
rw_repo has been forked as well as a handle for a git-daemon that may be started to
run the remote_repo.
The remote repository was cloned as bare repository from the rorepo, whereas
the rw repo has a working tree and was cloned from the remote repository.

remote_repo has two remotes: origin and daemon_origin. One uses a local url,
Expand Down Expand Up @@ -296,7 +300,7 @@ def remote_repo_creator(self):
with cwd(rw_repo.working_dir):
try:
return func(self, rw_repo, rw_daemon_repo)
except:
log.info("Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
rw_repo_dir, rw_daemon_repo_dir)
rw_repo_dir = rw_daemon_repo_dir = None
Expand Down
3 changes: 1 addition & 2 deletions git/test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ def test_traversal(self):
# at some point, both iterations should stop
self.assertEqual(list(bfirst)[-1], first)
stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(as_edge=True)
l = list(stoptraverse)
self.assertEqual(len(l[0]), 2)

# ignore self
self.assertEqual(next(start.traverse(ignore_self=False)), start)
Expand Down
16 changes: 16 additions & 0 deletions git/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from git.test.lib import (
TestCase,
fixture_path,
)
from git.test.lib import with_rw_directory

Expand Down Expand Up @@ -88,6 +89,21 @@ def test_read_write(self):
assert r_config.get(sname, oname) == val
# END for each filename

@with_rw_directory
def test_lock_reentry(self, rw_dir):
fpl = osp.join(rw_dir, 'l')
2 changes: 1 addition & 1 deletion git/test/test_submodule.py
Original file line number Diff line number Diff line change
@@ -920,4 +920,4 @@ class Repo(object):
submodule_path = 'D:\\submodule_path'
relative_path = Submodule._to_relative_path(super_repo, submodule_path)
msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
assert relative_path == 'submodule_path', msg
Loading
Toggle all file notes Toggle all file annotations