Skip to content

diff: pass endpoints to GIT_EXTERNAL_DIFF#8

Open
jonmathews-ensoft wants to merge 1 commit into
masterfrom
diff-endpoints_v07
Open

diff: pass endpoints to GIT_EXTERNAL_DIFF#8
jonmathews-ensoft wants to merge 1 commit into
masterfrom
diff-endpoints_v07

Conversation

@jonmathews-ensoft
Copy link
Copy Markdown
Owner

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant