Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand ~ or $(HOME) for the path to diff-highlight #1107

Closed
zaadeh opened this issue May 12, 2021 · 2 comments
Closed

Expand ~ or $(HOME) for the path to diff-highlight #1107

zaadeh opened this issue May 12, 2021 · 2 comments

Comments

@zaadeh
Copy link

zaadeh commented May 12, 2021

Continuing after #313, would it be possible to add support for shell-style expansion of ~ or $(HOME) variables in the
path to diff-highlight in tigrc?

For example when I set:

set diff-highlight = ~/.config/git/diff-highlight

tig cannot find the diff-highlight program. It needs the expanded absolute path to find it or find it in $PATH.

The reason I ask if this is possible is I don't want to change my $PATH from the default and do not want to have root access to put diff-highlight somewhere in system-wide $PATH.

I checked and git itself can expand the program paths set in [pager] section of git config. So this might not be a bad idea after all.

Cheers.

@koutcher
Copy link
Collaborator

Since 2.4.0 (f49fc7c), Tig will find diff-highlight even if it is not in the PATH, when it is installed at the default location in git contrib.
If that doesn't help, enabling ~ expansion wouldn't take much work either:

diff --git a/src/apps.c b/src/apps.c
index 28a4ac0..f25d41b 100644
--- a/src/apps.c
+++ b/src/apps.c
@@ -60,6 +60,9 @@ app_diff_highlight_path_search(char *dest, size_t destlen, const char *query)
 	if (!query || !*query)
 		return false;
 
+	if (strchr(query, '~'))
+		return path_expand(dest, destlen, query);
+
 	if (strchr(query, '/')) {
 		/* can only be interpreted as a fully qualified path */
 		string_ncopy_do(dest, destlen, query, strlen(query));

@zaadeh
Copy link
Author

zaadeh commented May 16, 2021

Thanks @koutcher

I turned your code into a pull request #1110

Cheers.

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

No branches or pull requests

2 participants