Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed May 30, 2024
1 parent 94e82e1 commit abd9683
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ def _write_git_file_and_module_config(cls, working_tree_dir: PathLike, module_ab
Absolute path to the bare repository.
"""
git_file = osp.join(working_tree_dir, ".git")
relative_fpath = osp.relpath(module_abspath, start=working_tree_dir)
relative_path = osp.relpath(module_abspath, start=working_tree_dir)
if sys.platform == "win32" and osp.isfile(git_file):
os.remove(git_file)
with open(git_file, "wb") as fp:
fp.write(("gitdir: %s" % relative_fpath).encode(defenc))
fp.write(("gitdir: %s" % relative_path).encode(defenc))

with GitConfigParser(osp.join(module_abspath, "config"), read_only=False, merge_includes=False) as writer:
writer.set_value(
Expand Down
6 changes: 3 additions & 3 deletions git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,11 @@ def addToStack(
yield rval

# Only continue to next level if this is appropriate!
nb = d + 1
if depth > -1 and nb > depth:
next_depth = d + 1
if depth > -1 and next_depth > depth:
continue

addToStack(stack, item, branch_first, nb)
addToStack(stack, item, branch_first, next_depth)
# END for each item on work stack


Expand Down
10 changes: 5 additions & 5 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
:return:
*(str(sha), str(target_ref_path))*, where:
* *sha* is of the file at relative_fpath points to if available, or ``None``.
* *sha* is of the file at relative_path points to if available, or ``None``.
* *target_ref_path* is the reference we point to, or ``None``.
"""
return cls._get_ref_info_helper(repo, ref_path)
Expand Down Expand Up @@ -813,7 +813,7 @@ def _iter_items(
) -> Iterator[T_References]:
if common_path is None:
common_path = cls._common_path_default
relative_fpaths = set()
relative_paths = set()

# Walk loose refs.
# Currently we do not follow links.
Expand All @@ -828,19 +828,19 @@ def _iter_items(
if f == "packed-refs":
continue
abs_path = to_native_path_linux(join_path(root, f))
relative_fpaths.add(abs_path.replace(to_native_path_linux(repo.common_dir) + "/", ""))
relative_paths.add(abs_path.replace(to_native_path_linux(repo.common_dir) + "/", ""))
# END for each file in root directory
# END for each directory to walk

# Read packed refs.
for _sha, relative_fpath in cls._iter_packed_refs(repo):
if relative_fpath.startswith(str(common_path)):
relative_fpaths.add(relative_fpath)
relative_paths.add(relative_fpath)
# END relative path matches common path
# END packed refs reading

# Yield paths in sorted order.
for path in sorted(relative_fpaths):
for path in sorted(relative_paths):
try:
yield cls.from_path(repo, path)
except ValueError:
Expand Down
4 changes: 2 additions & 2 deletions test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,15 @@ def tearDownClass(cls):
cls.rorepo.git.clear_cache()
cls.rorepo.git = None

def _make_file(self, relative_fpath, data, repo=None):
def _make_file(self, relative_path, data, repo=None):
"""
Create a file at the given path relative to our repository, filled with the
given data.
:return: An absolute path to the created file.
"""
repo = repo or self.rorepo
abs_path = osp.join(repo.working_tree_dir, relative_fpath)
abs_path = osp.join(repo.working_tree_dir, relative_path)
with open(abs_path, "w") as fp:
fp.write(data)
return abs_path
Expand Down
4 changes: 2 additions & 2 deletions test/test_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestRefs(TestBase):
def test_from_path(self):
# Should be able to create any reference directly.
for ref_type in (Reference, Head, TagReference, RemoteReference):
for name in ("relative_fpath", "path/rela_name"):
for name in ("relative_name", "path/rela_name"):
full_path = ref_type.to_full_path(name)
instance = ref_type.from_path(self.rorepo, full_path)
assert isinstance(instance, ref_type)
Expand Down Expand Up @@ -454,7 +454,7 @@ def test_head_reset(self, rw_repo):

# Rename it.
orig_obj = ref.object
for name in ("refs/absname", "relative_fpath", "feature/rela_name"):
for name in ("refs/absname", "relative_name", "feature/rela_name"):
ref_new_name = ref.rename(name)
assert isinstance(ref_new_name, Reference)
assert name in ref_new_name.path
Expand Down

0 comments on commit abd9683

Please sign in to comment.