Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3859ee

Browse files
committed
fixes
1 parent8186159 commita3859ee

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

‎git/index/base.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,26 +353,22 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
353353

354354
# tmp file created in git home directory to be sure renaming
355355
# works - /tmp/ dirs could be on another device
356-
tmp_index=tempfile.mktemp("","",repo.git_dir)
357-
arg_list.append("--index-output=%s"%tmp_index)
358-
arg_list.extend(treeish)
359-
360-
# move current index out of the way - otherwise the merge may fail
361-
# as it considers existing entries. moving it essentially clears the index.
362-
# Unfortunately there is no 'soft' way to do it.
363-
# The TemporaryFileSwap assure the original file get put back
364-
try:
365-
withExitStack()asstack:
366-
ifrepo.git_dir:
367-
stack.enter_context(TemporaryFileSwap(join_path_native(repo.git_dir,"index")))
368-
repo.git.read_tree(*arg_list,**kwargs)
369-
index=cls(repo,tmp_index)
370-
index.entries# force it to read the file as we will delete the temp-file
371-
returnindex
372-
finally:
373-
ifosp.exists(tmp_index):
374-
os.remove(tmp_index)
375-
# END index merge handling
356+
withExitStack()asstack:
357+
tmp_index=stack.enter_context(tempfile.NamedTemporaryFile(dir=repo.git_dir))
358+
arg_list.append("--index-output=%s"%tmp_index.name)
359+
arg_list.extend(treeish)
360+
361+
# move current index out of the way - otherwise the merge may fail
362+
# as it considers existing entries. moving it essentially clears the index.
363+
# Unfortunately there is no 'soft' way to do it.
364+
# The TemporaryFileSwap assure the original file get put back
365+
366+
stack.enter_context(TemporaryFileSwap(join_path_native(repo.git_dir,"index")))
367+
repo.git.read_tree(*arg_list,**kwargs)
368+
index=cls(repo,tmp_index.name)
369+
index.entries# force it to read the file as we will delete the temp-file
370+
returnindex
371+
# END index merge handling
376372

377373
# UTILITIES
378374
@unbare_repo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp