All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u."
@ 2009-01-13 16:11 Ted Pavlic
  2009-01-13 16:45 ` Shawn O. Pearce
  0 siblings, 1 reply; 7+ messages in thread
From: Ted Pavlic @ 2009-01-13 16:11 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano


Third in a series of patches that make bash completions more robust to
different interactive shell configurations and editors.

[PATCH 3/3] Adds a #!bash to the top of bash completions so that editors 
can recognize
  it as a bash script. Also adds a few simple comments above commands that
  take arguments. The comments are meant to remind editors of potential
  problems that can occur when the script is sourced on systems with "set
  -u."

Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
---
  contrib/completion/git-completion.bash |   15 +++++++++++++++
  1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 201f9a6..f8b845a 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1,3 +1,4 @@
+#!bash
  #
  # bash completion support for core Git.
  #
@@ -50,6 +51,8 @@ case "$COMP_WORDBREAKS" in
  *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
  esac

+# __gitdir accepts 0 or 1 arguments (i.e., location)
+# returns location of .git repo
  __gitdir ()
  {
  	if [ -z "${1-}" ]; then
@@ -67,6 +70,8 @@ __gitdir ()
  	fi
  }

+# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
+# returns text to add to bash PS1 prompt (includes branch name)
  __git_ps1 ()
  {
  	local g="$(git rev-parse --git-dir 2>/dev/null)"
@@ -119,6 +124,7 @@ __git_ps1 ()
  	fi
  }

+# __gitcomp_1 requires 2 arguments
  __gitcomp_1 ()
  {
  	local c IFS=' '$'\t'$'\n'
@@ -131,6 +137,8 @@ __gitcomp_1 ()
  	done
  }

+# __gitcomp accepts 1, 2, 3, or 4 arguments
+# generates completion reply with compgen
  __gitcomp ()
  {
  	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -150,6 +158,7 @@ __gitcomp ()
  	esac
  }

+# __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
  __git_heads ()
  {
  	local cmd i is_hash=y dir="$(__gitdir "${1-}")"
@@ -168,6 +177,7 @@ __git_heads ()
  	done
  }

+# __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
  __git_tags ()
  {
  	local cmd i is_hash=y dir="$(__gitdir "${1-}")"
@@ -186,6 +196,7 @@ __git_tags ()
  	done
  }

+# __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
  __git_refs ()
  {
  	local i is_hash=y dir="$(__gitdir "${1-}")"
@@ -218,6 +229,7 @@ __git_refs ()
  	done
  }

+# __git_refs2 requires 1 argument (to pass to __git_refs)
  __git_refs2 ()
  {
  	local i
@@ -226,6 +238,7 @@ __git_refs2 ()
  	done
  }

+# __git_refs_remotes requires 1 argument (to pass to ls-remote)
  __git_refs_remotes ()
  {
  	local cmd i is_hash=y
@@ -470,6 +483,7 @@ __git_aliases ()
  	done
  }

+# __git_aliased_command requires 1 argument
  __git_aliased_command ()
  {
  	local word cmdline=$(git --git-dir="$(__gitdir)" \
@@ -482,6 +496,7 @@ __git_aliased_command ()
  	done
  }

+# __git_find_subcommand requires 1 argument
  __git_find_subcommand ()
  {
  	local word subcommand c=1
-- 
1.6.1.87.g15624

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

* Re: [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u."
  2009-01-13 16:11 [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u." Ted Pavlic
@ 2009-01-13 16:45 ` Shawn O. Pearce
  2009-01-13 20:03   ` Boyd Stephen Smith Jr.
  0 siblings, 1 reply; 7+ messages in thread
From: Shawn O. Pearce @ 2009-01-13 16:45 UTC (permalink / raw)
  To: Ted Pavlic; +Cc: git, Junio C Hamano

Ted Pavlic <ted@tedpavlic.com> wrote:
>
> Third in a series of patches that make bash completions more robust to
> different interactive shell configurations and editors.
>
> [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors  
> can recognize
>  it as a bash script. Also adds a few simple comments above commands that
>  take arguments. The comments are meant to remind editors of potential
>  problems that can occur when the script is sourced on systems with "set
>  -u."

Aside from the message format... OK.  The message really should
have looked like this from an mbox point of view:

	From: Ted Pavlic <ted@tedpavlic.com>
	To: git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
	Cc: "Shawn O. Pearce" <spearce@spearce.org>
	Bcc: 
	Subject: [PATCH 3/3] bash-completion: Add internal function documentation

	Slightly document the internal functions of the bash
	completion package, so callers are more easily able to
	determine the expected arguments.

	Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
	---

	 Third in a series to improve the bash completion package,
	 so it sucks less.

	 contrib/completion/git-completion.bash |   15 +++++++++++++++
	 1 files changed, 15 insertions(+), 0 deletions(-)

	diff --git a/contrib/completion/git-completion.bash  

See how the stuff that doesn't matter to the commit message itself
goes after the "---" line?  And how the subject is a niceshort, one
line summary of the module impacted and the change?  These show up in
gitk and git shortlog, and thus in the "What's changed in git.git"
newsletters Junio publishes.  Its important that the subject be
really short and sweet.  You can put more detail above the "---"
line, and it will be included in the commit when Junio applies it.

This is all based on the formatting at the time of commit.
Anything up to the first "\n\n" in a commit message goes into the
email subject line.  The rest goes into the email body, but above the
"---" line.  You can then edit the buffer before sending to insert
non-commit message text after the "---" and before the diff stat.

You can include my Ack'd by line below your Signed-off-by when you
resend it.

Acked-by: Shawn O. Pearce <spearce@spearce.org>

> ---
>  contrib/completion/git-completion.bash |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)

-- 
Shawn.

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

* Re: [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u."
  2009-01-13 16:45 ` Shawn O. Pearce
@ 2009-01-13 20:03   ` Boyd Stephen Smith Jr.
  2009-01-13 20:10     ` Adeodato Simó
  0 siblings, 1 reply; 7+ messages in thread
From: Boyd Stephen Smith Jr. @ 2009-01-13 20:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Ted Pavlic, git, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]

On Tuesday 2009 January 13 10:45:18 Shawn O. Pearce wrote:
>See [...] how the subject is a niceshort, one
>line summary of the module impacted and the change?

My rule for this is absolutely no more than 80 characters.  Generally, you 
wouldn't want more than 60 or so, since it is used as the Subject: header and 
generally has some prefix added.

As shown says, details can go in the rest of the commit message.  If you are 
using more than 60-80 characters even without details, you might think about 
splitting the patch.

>This is all based on the formatting at the time of commit.
>Anything up to the first "\n\n" in a commit message goes into the
>email subject line.

IIRC, multiple "-m" options to "git commit" will be separated by "\n\n", so 
that's one way to do it if you don't like your $EDITOR for some reason.
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u."
  2009-01-13 20:03   ` Boyd Stephen Smith Jr.
@ 2009-01-13 20:10     ` Adeodato Simó
  2009-01-13 20:24       ` Commit messages Teemu Likonen
  2009-01-15 22:56       ` [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u." Markus Heidelberg
  0 siblings, 2 replies; 7+ messages in thread
From: Adeodato Simó @ 2009-01-13 20:10 UTC (permalink / raw)
  To: Boyd Stephen Smith Jr.; +Cc: Shawn O. Pearce, Ted Pavlic, git, Junio C Hamano

* Boyd Stephen Smith Jr. [Tue, 13 Jan 2009 14:03:11 -0600]:

> On Tuesday 2009 January 13 10:45:18 Shawn O. Pearce wrote:
> >See [...] how the subject is a niceshort, one
> >line summary of the module impacted and the change?

> My rule for this is absolutely no more than 80 characters.

My rule for *all* of the commit message is "absolutely no more than 76
characters". With more than 76, `git log` wraps in a 80-column terminal.

Just my 2¢,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
La música es de los que la quieren escuchar y de nadie más.
                -- Andrés Calamaro

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

* Commit messages
  2009-01-13 20:10     ` Adeodato Simó
@ 2009-01-13 20:24       ` Teemu Likonen
  2009-01-14 16:55         ` Ted Pavlic
  2009-01-15 22:56       ` [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u." Markus Heidelberg
  1 sibling, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2009-01-13 20:24 UTC (permalink / raw)
  To: Adeodato Simó
  Cc: Boyd Stephen Smith Jr., Shawn O. Pearce, Ted Pavlic, git, Junio C Hamano

Adeodato Simó (2009-01-13 21:10 +0100) wrote:

> * Boyd Stephen Smith Jr. [Tue, 13 Jan 2009 14:03:11 -0600]:
>
>> My rule for this is absolutely no more than 80 characters.
>
> My rule for *all* of the commit message is "absolutely no more than 76
> characters". With more than 76, `git log` wraps in a 80-column terminal.

Here's my rule:


(add-to-list 'auto-mode-alist
             '("/\\.git/\\(COMMIT\\|TAG\\)_EDITMSG\\'" .
               vcs-message-mode))

(define-derived-mode vcs-message-mode text-mode "VCS-message"
  "Major mode for editing commit and tag messages." 
  (auto-fill-mode 1)
  (set (make-local-variable 'tab-stop-list)
       (number-sequence 4 100 4))
  (setq indent-tabs-mode nil
        fill-column 72
        truncate-lines t))

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

* Re: Commit messages
  2009-01-13 20:24       ` Commit messages Teemu Likonen
@ 2009-01-14 16:55         ` Ted Pavlic
  0 siblings, 0 replies; 7+ messages in thread
From: Ted Pavlic @ 2009-01-14 16:55 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: git

That rule could be modified to support .stgit-edit.txt as well.

> (add-to-list 'auto-mode-alist
>               '("/\\.git/\\(COMMIT\\|TAG\\)_EDITMSG\\'" .
>                 vcs-message-mode))

-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

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

* Re: [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u."
  2009-01-13 20:10     ` Adeodato Simó
  2009-01-13 20:24       ` Commit messages Teemu Likonen
@ 2009-01-15 22:56       ` Markus Heidelberg
  1 sibling, 0 replies; 7+ messages in thread
From: Markus Heidelberg @ 2009-01-15 22:56 UTC (permalink / raw)
  To: Adeodato Simó
  Cc: Boyd Stephen Smith Jr., Shawn O. Pearce, Ted Pavlic, git, Junio C Hamano

Adeodato Simó, 13.01.2009:
> * Boyd Stephen Smith Jr. [Tue, 13 Jan 2009 14:03:11 -0600]:
> 
> > On Tuesday 2009 January 13 10:45:18 Shawn O. Pearce wrote:
> > >See [...] how the subject is a niceshort, one
> > >line summary of the module impacted and the change?
> 
> > My rule for this is absolutely no more than 80 characters.
> 
> My rule for *all* of the commit message is "absolutely no more than 76
> characters". With more than 76, `git log` wraps in a 80-column terminal.

What about the 50 character limit proposed in the documentation
(git-commit, gittutorial, user-manual)?

At the beginning I tried to fulfil this limit, but often it's not easy.
So should it be adjusted to a slightly higher value in the documentation
or even split into a recommended limit (e.g. 50) and a recommended
absolute maximum (e.g. 76)? Hmm, the split wouldn't make sense, I think.

Markus

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

end of thread, other threads:[~2009-01-15 22:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-13 16:11 [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u." Ted Pavlic
2009-01-13 16:45 ` Shawn O. Pearce
2009-01-13 20:03   ` Boyd Stephen Smith Jr.
2009-01-13 20:10     ` Adeodato Simó
2009-01-13 20:24       ` Commit messages Teemu Likonen
2009-01-14 16:55         ` Ted Pavlic
2009-01-15 22:56       ` [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that can occur when the script is sourced on systems with "set, -u." Markus Heidelberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.