git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add '-P' as a synonym for '--no-pager' in the git command
  2011-12-13 22:35 [PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD Joe Ratterman
@ 2011-12-13 22:35 ` Joe Ratterman
  2011-12-14  7:44   ` Johannes Sixt
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Ratterman @ 2011-12-13 22:35 UTC (permalink / raw)
  To: git; +Cc: Joe Ratterman

  Also, add both -P|--no-pager to the existing -p|--paginate in bash
  completion.

Signed-off-by: Joe Ratterman <jratt0@gmail.com>
---
 Documentation/git.txt                  |    3 ++-
 contrib/completion/git-completion.bash |    2 +-
 git.c                                  |    4 ++--
 t/t7006-pager.sh                       |    8 ++++++++
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index e869032..c7f8445 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
-    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
+    [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
     [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
     [-c <name>=<value>]
     [--help] <command> [<args>]
@@ -329,6 +329,7 @@ help ...`.
 	configuration options (see the "Configuration Mechanism" section
 	below).
 
+-P::
 --no-pager::
 	Do not pipe git output into a pager.
 
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index cc1bdf9..8b9ea1b 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2640,7 +2640,7 @@ _git ()
 		case "$i" in
 		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
 		--bare)      __git_dir="." ;;
-		--version|-p|--paginate) ;;
+		--version|-p|--paginate|-P|--no-pager) ;;
 		--help) command="help"; break ;;
 		*) command="$i"; break ;;
 		esac
diff --git a/git.c b/git.c
index 8e34903..baa1613 100644
--- a/git.c
+++ b/git.c
@@ -7,7 +7,7 @@
 
 const char git_usage_string[] =
 	"git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
-	"           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n"
+	"           [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]\n"
 	"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 	"           [-c name=value] [--help]\n"
 	"           <command> [<args>]";
@@ -103,7 +103,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			exit(0);
 		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			use_pager = 1;
-		} else if (!strcmp(cmd, "--no-pager")) {
+		} else if (!strcmp(cmd, "-P") || !strcmp(cmd, "--no-pager")) {
 			use_pager = 0;
 			if (envchanged)
 				*envchanged = 1;
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 320e1d1..783915e 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -84,6 +84,14 @@ test_expect_success 'no pager even with --paginate when stdout is a pipe' '
 	! test -e paginated.out
 '
 
+test_expect_success TTY 'no pager with -P' '
+	rm -f paginated.out ||
+	cleanup_fail &&
+
+	test_terminal git -P log &&
+	! test -e paginated.out
+'
+
 test_expect_success TTY 'no pager with --no-pager' '
 	rm -f paginated.out ||
 	cleanup_fail &&
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add '-P' as a synonym for '--no-pager' in the git command
  2011-12-13 22:35 ` [PATCH] Add '-P' as a synonym for '--no-pager' in the git command Joe Ratterman
@ 2011-12-14  7:44   ` Johannes Sixt
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Sixt @ 2011-12-14  7:44 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Joe Ratterman, git

Am 12/13/2011 23:35, schrieb Joe Ratterman:
> +test_expect_success TTY 'no pager with -P' '
> +	rm -f paginated.out ||
> +	cleanup_fail &&
> +
> +	test_terminal git -P log &&
> +	! test -e paginated.out
> +'
> +
>  test_expect_success TTY 'no pager with --no-pager' '
>  	rm -f paginated.out ||
>  	cleanup_fail &&

What kind of bogosity do I see in the context of this hunk (and in the new
text as well, but it is not entirely your fault, Joe, since you obviously
have only copied an existing test snippet)?

Wouldn't rm -f always succeed under normal circumstances, and then the
rest of the test would be skipped? This use of || was introduced by
fdf1bc48 (t7006: guard cleanup with test_expect_success).

-- Hannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Add '-P' as a synonym for '--no-pager' in the git command
@ 2011-12-15 20:55 Joe Ratterman
  2011-12-15 21:41 ` Junio C Hamano
  2011-12-16  9:30 ` Matthieu Moy
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Ratterman @ 2011-12-15 20:55 UTC (permalink / raw)
  To: gitster, git; +Cc: Joe Ratterman

  Also, add both -P|--no-pager to the existing -p|--paginate in bash
  completion.

Signed-off-by: Joe Ratterman <jratt0@gmail.com>
---
 Documentation/git.txt                  |    3 ++-
 contrib/completion/git-completion.bash |    2 +-
 git.c                                  |    4 ++--
 t/t7006-pager.sh                       |    8 ++++++++
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index e869032..c7f8445 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
-    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
+    [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
     [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
     [-c <name>=<value>]
     [--help] <command> [<args>]
@@ -329,6 +329,7 @@ help ...`.
 	configuration options (see the "Configuration Mechanism" section
 	below).
 
+-P::
 --no-pager::
 	Do not pipe git output into a pager.
 
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index cc1bdf9..8b9ea1b 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2640,7 +2640,7 @@ _git ()
 		case "$i" in
 		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
 		--bare)      __git_dir="." ;;
-		--version|-p|--paginate) ;;
+		--version|-p|--paginate|-P|--no-pager) ;;
 		--help) command="help"; break ;;
 		*) command="$i"; break ;;
 		esac
diff --git a/git.c b/git.c
index 8e34903..baa1613 100644
--- a/git.c
+++ b/git.c
@@ -7,7 +7,7 @@
 
 const char git_usage_string[] =
 	"git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
-	"           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n"
+	"           [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]\n"
 	"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 	"           [-c name=value] [--help]\n"
 	"           <command> [<args>]";
@@ -103,7 +103,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			exit(0);
 		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			use_pager = 1;
-		} else if (!strcmp(cmd, "--no-pager")) {
+		} else if (!strcmp(cmd, "-P") || !strcmp(cmd, "--no-pager")) {
 			use_pager = 0;
 			if (envchanged)
 				*envchanged = 1;
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 320e1d1..783915e 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -84,6 +84,14 @@ test_expect_success 'no pager even with --paginate when stdout is a pipe' '
 	! test -e paginated.out
 '
 
+test_expect_success TTY 'no pager with -P' '
+	rm -f paginated.out ||
+	cleanup_fail &&
+
+	test_terminal git -P log &&
+	! test -e paginated.out
+'
+
 test_expect_success TTY 'no pager with --no-pager' '
 	rm -f paginated.out ||
 	cleanup_fail &&
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add '-P' as a synonym for '--no-pager' in the git command
  2011-12-15 20:55 [PATCH] Add '-P' as a synonym for '--no-pager' in the git command Joe Ratterman
@ 2011-12-15 21:41 ` Junio C Hamano
  2011-12-16  9:30 ` Matthieu Moy
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2011-12-15 21:41 UTC (permalink / raw)
  To: Joe Ratterman; +Cc: git

Sorry, but why was I listed on the To: line?

I do not recall there was a list concensus that this is a must-have or
even good-to-have, and I am not personally interested in this. I hesitate
to accept a patch that lets a feature without clear advantage squat on a
short-and-sweet single-letter option, generally speaking.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add '-P' as a synonym for '--no-pager' in the git command
  2011-12-15 20:55 [PATCH] Add '-P' as a synonym for '--no-pager' in the git command Joe Ratterman
  2011-12-15 21:41 ` Junio C Hamano
@ 2011-12-16  9:30 ` Matthieu Moy
  1 sibling, 0 replies; 5+ messages in thread
From: Matthieu Moy @ 2011-12-16  9:30 UTC (permalink / raw)
  To: Joe Ratterman; +Cc: gitster, git

Joe Ratterman <jratt0@gmail.com> writes:

>   Also, add both -P|--no-pager to the existing -p|--paginate in bash
>   completion.

A good commit message should always answer the question "why?". In this
case, I really don't see why this is needed. If you don't like Git's
auto-paginate feature, turn it off with core.pager or pager.<cmd>. If
you like it, you very rarely need --no-pager (IIRC, I'm the one who
introduced --no-pager, and I don't think I've ever used it outside a
script).

So, I'd rather keep -P free in case we need it later for something
really useful (or possibly a better commit message).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-16  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15 20:55 [PATCH] Add '-P' as a synonym for '--no-pager' in the git command Joe Ratterman
2011-12-15 21:41 ` Junio C Hamano
2011-12-16  9:30 ` Matthieu Moy
  -- strict thread matches above, loose matches on Subject: below --
2011-12-13 22:35 [PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD Joe Ratterman
2011-12-13 22:35 ` [PATCH] Add '-P' as a synonym for '--no-pager' in the git command Joe Ratterman
2011-12-14  7:44   ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).