You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use this library to get the file changes by looking at diff.diff, but it's not working, while running what I think is the same command via a subprocess, works.
Code:
# Using this library
uncommitted_diff = repo.index.diff(None, paths=paths)
committed_diff = repo.index.diff(base[0], paths=paths)
for diff in [*uncommitted_diff, *committed_diff]:
print(f"diff: {diff.diff}")
# Using subprocess and running git directly
process1 = subprocess.exec(["git", "diff", paths], capture_output=True)
process2 = subprocess.exec(["git", "diff", base[0].hexsha], capture_output=True)
print("using subprocess:")
print(process1.stdout.decode("utf-8"))subprocess
print(process2.stdout.decode("utf-8"))
Output (with some omiting of info) is:
diff:
using subprocess:
diff --git a******.py
index ******
--- a******.py
+++ b******.py
@@ -1,9 +1,11 @@
from pathlib import Path
-from typing import Any
+from typing import Any, Optional, Tuple, Union
.....
Any ideas what is going on here and why the two results are different?
You could probably debug this by setting the GIT_PYTHON_TRACE environment variable.
As I always have been confused by this API myself I wouldn't be able to tell what's wrong just by looking at it either, and it's definitely easy to get it wrong or to get unintended results.
I will convert this into a discussion in case we get down to the source of the problem, or we create an issue from there once it's clear it's a bug.
Activity
Byron commentedon Oct 28, 2022
You could probably debug this by setting the GIT_PYTHON_TRACE environment variable.
As I always have been confused by this API myself I wouldn't be able to tell what's wrong just by looking at it either, and it's definitely easy to get it wrong or to get unintended results.
I will convert this into a discussion in case we get down to the source of the problem, or we create an issue from there once it's clear it's a bug.