Skip to contentSkip to conversation

Add grep.fullName config variable

PATCH In review Andreas Schwab 2 participants 7 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add grep.fullName config variable

This configuration variable sets the default for the --full-name option.

---
 Documentation/git-grep.txt | 3 +++
 grep.c                     | 5 +++++
 2 files changed, 8 insertions(+)
Documentation/git-grep.txt +3 -0
index f837334..31811f1 100644
@@ -53,6 +53,9 @@ grep.extendedRegexp::
 	option is ignored when the 'grep.patternType' option is set to a value
 	other than 'default'.
 
+grep.fullName::
+	If set to true, enable '--full-name' option by default.
+
 
 OPTIONS
 -------
grep.c +5 -0
index c668034..ece04bf 100644
@@ -86,6 +86,11 @@ int grep_config(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (!strcmp(var, "grep.fullname")) {
+		opt->relative = !git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "color.grep"))
 		opt->color = git_config_colorbool(var, value);
 	else if (!strcmp(var, "color.grep.context"))
Signature · 6 lines
1.9.0

-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw
Quoted 4 lines · Andreas Schwab

This configuration variable sets the default for the --full-name option.

---

Would this change break Porcelains (e.g. Emacs modes) and force them to be updated to explicitly pass --no-full-name to unbreak them?

Quoted 36 lines
 Documentation/git-grep.txt | 3 +++
 grep.c                     | 5 +++++
 2 files changed, 8 insertions(+)
Documentation/git-grep.txt +3 -0
index f837334..31811f1 100644
@@ -53,6 +53,9 @@ grep.extendedRegexp::
 	option is ignored when the 'grep.patternType' option is set to a value
 	other than 'default'.
 
+grep.fullName::
+	If set to true, enable '--full-name' option by default.
+
 
 OPTIONS
 -------
grep.c +5 -0
index c668034..ece04bf 100644
@@ -86,6 +86,11 @@ int grep_config(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (!strcmp(var, "grep.fullname")) {
+		opt->relative = !git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "color.grep"))
 		opt->color = git_config_colorbool(var, value);
 	else if (!strcmp(var, "color.grep.context"))
Signature · 1 line
1.9.0
#2 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Andreas Schwab

This configuration variable sets the default for the --full-name option.

---

Would this change break Porcelains (e.g. Emacs modes) and force them to be updated to explicitly pass --no-full-name to unbreak them?

Yes, that would be required. On the other hand, currently it is impossible to cut-n-paste a file name without --full-name, since the pager is always started in top-level. Perhaps it is better to fix the latter?

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#3 lore raw
Quoted 9 lines · Andreas Schwab
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Andreas Schwab

This configuration variable sets the default for the --full-name option.

---

Quoted 7 lines
Quoted 2 lines

Would this change break Porcelains (e.g. Emacs modes) and force them to be updated to explicitly pass --no-full-name to unbreak them?

Yes, that would be required. On the other hand, currently it is impossible to cut-n-paste a file name without --full-name, since the pager is always started in top-level. Perhaps it is better to fix the latter?

On the third hand, git grep isn't plumbing, so variation of output is to be expected? We already have grep.lineNumber and grep.patternType / grep.extendedRegexp (vc-git-grep uses -n itself, but does not protect against grep.patternType).

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#4 lore raw
In reply to Andreas Schwab
Quoted 4 lines · Andreas Schwab

Yes, that would be required. On the other hand, currently it is impossible to cut-n-paste a file name without --full-name, since the pager is always started in top-level. Perhaps it is better to fix the latter?

So far we never cared where the pager runs, but as a principle, I think it would be nice if we run it in the original subdirectory, not at the top of the working tree (unless we have to bend backwards to make the codepath involved too ugly, that is).

Don't we have the exact same issue for the editor, by the way? Shouldn't we be running it in the original subdirectory as well?

#5 lore raw
Quoted 2 lines · Junio C Hamano

Don't we have the exact same issue for the editor, by the way? Shouldn't we be running it in the original subdirectory as well?

It's called with an absolute name, so it shouldn't care.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#6 lore raw
Quoted 6 lines · Andreas Schwab
Quoted 2 lines · Junio C Hamano

Don't we have the exact same issue for the editor, by the way? Shouldn't we be running it in the original subdirectory as well?

It's called with an absolute name, so it shouldn't care.

But we should not have to call with absolute paths when a short and sweet pathname relative to the user's current directory. That is the primary point of my comment.