diff: pass endpoints to GIT_EXTERNAL_DIFF#8
Open
jonmathews-ensoft wants to merge 1 commit into
Open
Conversation
Git diff is about comparing two endpoints. Pass endpoints as determined by diff argument parsing to external tools via environment variables. External tools receive a path and the contents to compare in temporary files. Tools are unable to display the commits being compared, nor the paths if one was renamed. A common scenario is a GUI client invoking an external tool via difftool. The GUI client knows the selected commits, but few if any clients pass that information to the external tool. Git receives the commits to compare, and is in a position to share the endpoints with the external tool. External tools should be able to display endpoints that enable users to locate the content being compared, ideally in terms of commit objects and paths. Address this problem by exporting the following variables: GIT_DIFF_ENDPOINT_A GIT_DIFF_ENDPOINT_B GIT_DIFF_PATH_A GIT_DIFF_PATH_B The ENDPOINT_* variables are the endpoints as determined by the builtin diff argument parsing. Ideally the values are object ids for commits, but will degrade to tree objects if the arguments are trees. A PATH_* variable is the path of the contents in the corresponding endpoint. For clarity, both variables are set even if the paths are the same. When a blob is added or deleted, the other path is /dev/null. If --relative is specified, the paths are relative. Out of scope: - diffs vs the index, working tree, or no-index: these could be handled in the future by indicating the endpoint is 'index', 'working-tree' or 'no-index'. - merge-commits: the current approach does not consider how to handle more than two endpoints. Environment variables will not be set. - GIT_EXTERNAL_DIFF does not support --submodule=diff, and therefore is not considered at this time. - difftool --dir-diff invokes the external tool on two directories. This is achieved by invoking diff to find the differences. This prevents environment variables from being passed back to difftool.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Git diff is about comparing two endpoints. Pass endpoints as determined by diff argument parsing to external tools via environment variables.
External tools receive a path and the contents to compare in temporary files. Tools are unable to display the commits being compared, nor the paths if one was renamed. A common scenario is a GUI client invoking an external tool via difftool. The GUI client knows the selected commits, but few if any clients pass that information to the external tool. Git receives the commits to compare, and is in a position to share the endpoints with the external tool.
External tools should be able to display endpoints that enable users to locate the content being compared, ideally in terms of commit objects and paths.
Address this problem by exporting the following variables:
GIT_DIFF_ENDPOINT_A
GIT_DIFF_ENDPOINT_B
GIT_DIFF_PATH_A
GIT_DIFF_PATH_B
The ENDPOINT_* variables are the endpoints as determined by the builtin diff argument parsing. Ideally the values are object ids for commits, but will degrade to tree objects if the arguments are trees.
A PATH_* variable is the path of the contents in the corresponding endpoint. For clarity, both variables are set even if the paths are the same. When a blob is added or deleted, the other path is /dev/null.
If --relative is specified, the paths are relative.
Out of scope:
diffs vs the index, working tree, or no-index: these could be handled in the future by indicating the endpoint is 'index', 'working-tree' or 'no-index'.
merge-commits: the current approach does not consider how to handle more than two endpoints. Environment variables will not be set.
GIT_EXTERNAL_DIFF does not support --submodule=diff, and therefore is not considered at this time.
difftool --dir-diff invokes the external tool on two directories. This is achieved by invoking diff to find the differences. This prevents environment variables from being passed back to difftool.