All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface
@ 2011-12-20 11:09 Thomas Rast
  2011-12-20 11:09 ` [PATCH 2/2] Documentation: make git-sh-setup docs less scary Thomas Rast
  2011-12-20 19:25 ` [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2011-12-20 11:09 UTC (permalink / raw)
  To: git

92c62a3 (Porcelain scripts: Rewrite cryptic "needs update" error
message, 2010-10-19) refactored git's own checking to a function in
git-sh-setup.  This is a very useful thing for script writers, so
document it.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Noticed while helping ribasushi on IRC.

 Documentation/git-sh-setup.txt |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index a2f346c..bbfefca 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -68,6 +68,15 @@ require_work_tree_exists::
 	cd_to_toplevel, which is impossible to do if there is no
 	working tree.
 
+require_clean_work_tree <action> [<hint>]::
+	checks if the working tree associated with the repository is
+	clean.  Otherwise it emits an error message of the form
+	`Cannot <action>: <reason>. <hint>`, and dies.  Example:
++
+----------------
+require_clean_work_tree rebase "Please commit or stash them."
+----------------
+
 get_author_ident_from_commit::
 	outputs code for use with eval to set the GIT_AUTHOR_NAME,
 	GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
-- 
1.7.8.484.gdad4270

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

* [PATCH 2/2] Documentation: make git-sh-setup docs less scary
  2011-12-20 11:09 [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Thomas Rast
@ 2011-12-20 11:09 ` Thomas Rast
  2011-12-20 19:20   ` Junio C Hamano
  2011-12-20 19:45   ` Ævar Arnfjörð Bjarmason
  2011-12-20 19:25 ` [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Junio C Hamano
  1 sibling, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2011-12-20 11:09 UTC (permalink / raw)
  To: git

At least one IRC user was scared away by the introductory "This is not
a command the end user would want to run.  Ever." to the point of not
reading on.

Reword it in a more matter-of-fact way that does not intentionally try
to scare the user away.  Since 46bac90 (Do not install shell libraries
executable, 2010-01-31) it is not executable anyway, so the end user
would get

  $ git sh-setup
  fatal: cannot exec 'git-sh-setup': Permission denied

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 Documentation/git-sh-setup.txt |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index bbfefca..612fb50 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -13,13 +13,10 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-This is not a command the end user would want to run.  Ever.
-This documentation is meant for people who are studying the
-Porcelain-ish scripts and/or are writing new ones.
-
-The 'git sh-setup' scriptlet is designed to be sourced (using
-`.`) by other shell scripts to set up some variables pointing at
-the normal git directories and a few helper shell functions.
+This command cannot be run by the end user.  Shell scripts can
+source it (using `.` as indicated above) to set up some variables
+pointing at the normal git directories and a few helper shell
+functions.
 
 Before sourcing it, your script should set up a few variables;
 `USAGE` (and `LONG_USAGE`, if any) is used to define message
-- 
1.7.8.484.gdad4270

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

* Re: [PATCH 2/2] Documentation: make git-sh-setup docs less scary
  2011-12-20 11:09 ` [PATCH 2/2] Documentation: make git-sh-setup docs less scary Thomas Rast
@ 2011-12-20 19:20   ` Junio C Hamano
  2011-12-20 19:45   ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2011-12-20 19:20 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git

Thomas Rast <trast@student.ethz.ch> writes:

> At least one IRC user was scared away by the introductory "This is not
> a command the end user would want to run.  Ever." to the point of not
> reading on.

You would need to say what that IRC user needed to find out. Depending on
that, letting the user know that there is no point reading on early and
not waste his or her time may be a good thing. That was what the paragraph
was designed for. IOW, it is not to "scare" away, but to allow the users
to decide if they are intended audiences.

The reworded version does avoid sounding scary, but loses the "this
document is for people who want to write new or understand existing
Porcelain scripts", which is a documentation regression.

> Reword it in a more matter-of-fact way that does not intentionally try
> to scare the user away.  Since 46bac90 (Do not install shell libraries
> executable, 2010-01-31) it is not executable anyway, so the end user
> would get
>
>   $ git sh-setup
>   fatal: cannot exec 'git-sh-setup': Permission denied
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>  Documentation/git-sh-setup.txt |   11 ++++-------
>  1 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
> index bbfefca..612fb50 100644
> --- a/Documentation/git-sh-setup.txt
> +++ b/Documentation/git-sh-setup.txt
> @@ -13,13 +13,10 @@ SYNOPSIS
>  DESCRIPTION
>  -----------
>  
> -This is not a command the end user would want to run.  Ever.
> -This documentation is meant for people who are studying the
> -Porcelain-ish scripts and/or are writing new ones.
> -
> -The 'git sh-setup' scriptlet is designed to be sourced (using
> -`.`) by other shell scripts to set up some variables pointing at
> -the normal git directories and a few helper shell functions.
> +This command cannot be run by the end user.  Shell scripts can
> +source it (using `.` as indicated above) to set up some variables
> +pointing at the normal git directories and a few helper shell
> +functions.
>  
>  Before sourcing it, your script should set up a few variables;
>  `USAGE` (and `LONG_USAGE`, if any) is used to define message

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

* Re: [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface
  2011-12-20 11:09 [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Thomas Rast
  2011-12-20 11:09 ` [PATCH 2/2] Documentation: make git-sh-setup docs less scary Thomas Rast
@ 2011-12-20 19:25 ` Junio C Hamano
  2011-12-20 20:29   ` [PATCH v2] " Thomas Rast
  1 sibling, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2011-12-20 19:25 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git

Thomas Rast <trast@student.ethz.ch> writes:

> 92c62a3 (Porcelain scripts: Rewrite cryptic "needs update" error
> message, 2010-10-19) refactored git's own checking to a function in
> git-sh-setup.  This is a very useful thing for script writers, so
> document it.

Can we avoid explaining "clean" with the same word "clean", which adds no
new information? IOW, what does "clean" mean in the context of this helper
shell function? No untracked cruft? No un-added changes? What are the kind
of dirtiness being checked?

> +require_clean_work_tree <action> [<hint>]::
> +	checks if the working tree associated with the repository is
> +	clean.  Otherwise it emits an error message of the form
> +	`Cannot <action>: <reason>. <hint>`, and dies.  Example:
> ++
> +----------------
> +require_clean_work_tree rebase "Please commit or stash them."
> +----------------
> +
>  get_author_ident_from_commit::
>  	outputs code for use with eval to set the GIT_AUTHOR_NAME,
>  	GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.

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

* Re: [PATCH 2/2] Documentation: make git-sh-setup docs less scary
  2011-12-20 11:09 ` [PATCH 2/2] Documentation: make git-sh-setup docs less scary Thomas Rast
  2011-12-20 19:20   ` Junio C Hamano
@ 2011-12-20 19:45   ` Ævar Arnfjörð Bjarmason
  2011-12-20 20:27     ` Thomas Rast
  1 sibling, 1 reply; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2011-12-20 19:45 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git

On Tue, Dec 20, 2011 at 12:09, Thomas Rast <trast@student.ethz.ch> wrote:
> At least one IRC user was scared away by the introductory "This is not
> a command the end user would want to run.  Ever." to the point of not
> reading on.

Arguably that's the point isn't it? To not have people who aren't
maintaining Git itself waste time on reading it.

Anyway I don't care how it's worded, but if you're going to patch it
you should probably do these too for consistency, since they
copy/paste this same blurb:

    $ git --no-pager grep -l 'This is not a command the end user would
want to run.  Ever.'
    Documentation/git-mergetool--lib.txt
    Documentation/git-sh-i18n--envsubst.txt
    Documentation/git-sh-i18n.txt
    Documentation/git-sh-setup.txt

And actually we might want to do all those with some asciidoc include
mechanism.

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

* Re: [PATCH 2/2] Documentation: make git-sh-setup docs less scary
  2011-12-20 19:45   ` Ævar Arnfjörð Bjarmason
@ 2011-12-20 20:27     ` Thomas Rast
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Rast @ 2011-12-20 20:27 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> On Tue, Dec 20, 2011 at 12:09, Thomas Rast <trast@student.ethz.ch> wrote:
>> At least one IRC user was scared away by the introductory "This is not
>> a command the end user would want to run.  Ever." to the point of not
>> reading on.
>
> Arguably that's the point isn't it? To not have people who aren't
> maintaining Git itself waste time on reading it.

Junio C Hamano writes:
> You would need to say what that IRC user needed to find out. Depending on
> that, letting the user know that there is no point reading on early and
> not waste his or her time may be a good thing. That was what the paragraph
> was designed for. IOW, it is not to "scare" away, but to allow the users
> to decide if they are intended audiences.

Well, the original question was [*]

  <ribasushi> how do I write a batch-test (goes in a script, exit value matters only) to test if the current workdir is clean?
  <ribasushi> i.e. nothing staged/unstaged to commit
  <shruggar> last I looked, there was no "all in one" method :/
  <shruggar> git diff -q && git diff —cached -q, perhaps
  <charon> ribasushi: . "$(git --exec-path)/git-sh-setup" ; require_clean_worktree
  <shruggar> but I think that's ignoring something
  <ribasushi> lack of output of `git status -s` seems to be what I want
  <ribasushi> hmmm
  <ribasushi> charon: git-gh-setup's manpage does not seem to list what you gave me
  <ribasushi> and the manpage says that I should not be touching it...

Leaving aside my worktree vs. work_tree mistake, he concluded that he
should not be using it even though he is a script writer.

Regardless, I don't really care enough about this one; let's just do the
first patch (v2 upcoming) so that we have documentation to point people
at.


[*] http://colabti.org/irclogger/irclogger_log/git?date=2011-12-20#l1284

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

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

* [PATCH v2] git-sh-setup: make require_clean_work_tree part of the interface
  2011-12-20 19:25 ` [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Junio C Hamano
@ 2011-12-20 20:29   ` Thomas Rast
  2011-12-20 20:52     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Rast @ 2011-12-20 20:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

92c62a3 (Porcelain scripts: Rewrite cryptic "needs update" error
message, 2010-10-19) refactored git's own checking to a function in
git-sh-setup.  This is a very useful thing for script writers, so
document it.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 Documentation/git-sh-setup.txt |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index a2f346c..9a0e574 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -68,6 +68,16 @@ require_work_tree_exists::
 	cd_to_toplevel, which is impossible to do if there is no
 	working tree.
 
+require_clean_work_tree <action> [<hint>]::
+	checks that the working tree associated with the repository
+	has no uncommitted changes to tracked files.  Otherwise it
+	emits an error message of the form `Cannot <action>:
+	<reason>. <hint>`, and dies.  Example:
++
+----------------
+require_clean_work_tree rebase "Please commit or stash them."
+----------------
+
 get_author_ident_from_commit::
 	outputs code for use with eval to set the GIT_AUTHOR_NAME,
 	GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
-- 
1.7.8.484.gdad4270

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

* Re: [PATCH v2] git-sh-setup: make require_clean_work_tree part of the interface
  2011-12-20 20:29   ` [PATCH v2] " Thomas Rast
@ 2011-12-20 20:52     ` Junio C Hamano
  2011-12-20 21:42       ` [PATCH v3] " Thomas Rast
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2011-12-20 20:52 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git, Junio C Hamano

Thomas Rast <trast@student.ethz.ch> writes:

> 92c62a3 (Porcelain scripts: Rewrite cryptic "needs update" error
> message, 2010-10-19) refactored git's own checking to a function in
> git-sh-setup.  This is a very useful thing for script writers, so
> document it.
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>  Documentation/git-sh-setup.txt |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
> index a2f346c..9a0e574 100644
> --- a/Documentation/git-sh-setup.txt
> +++ b/Documentation/git-sh-setup.txt
> @@ -68,6 +68,16 @@ require_work_tree_exists::
>  	cd_to_toplevel, which is impossible to do if there is no
>  	working tree.
>  
> +require_clean_work_tree <action> [<hint>]::
> +	checks that the working tree associated with the repository
> +	has no uncommitted changes to tracked files.  Otherwise it
> +	emits an error message of the form `Cannot <action>:
> +	<reason>. <hint>`, and dies.  Example:

Doesn't it also enforce cleanliness on the index, not just the working tree?

> ++
> +----------------
> +require_clean_work_tree rebase "Please commit or stash them."
> +----------------
> +
>  get_author_ident_from_commit::
>  	outputs code for use with eval to set the GIT_AUTHOR_NAME,
>  	GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.

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

* [PATCH v3] git-sh-setup: make require_clean_work_tree part of the interface
  2011-12-20 20:52     ` Junio C Hamano
@ 2011-12-20 21:42       ` Thomas Rast
  2011-12-20 22:05         ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Rast @ 2011-12-20 21:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

92c62a3 (Porcelain scripts: Rewrite cryptic "needs update" error
message, 2010-10-19) refactored git's own checking to a function in
git-sh-setup.  This is a very useful thing for script writers, so
document it.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Junio C Hamano writes:

> Thomas Rast <trast@student.ethz.ch> writes:
> 
> > +require_clean_work_tree <action> [<hint>]::
> > +	checks that the working tree associated with the repository
> > +	has no uncommitted changes to tracked files.  Otherwise it
> > +	emits an error message of the form `Cannot <action>:
> > +	<reason>. <hint>`, and dies.  Example:
> 
> Doesn't it also enforce cleanliness on the index, not just the working tree?

Of course.  Here's the "and index" update.

BTW neither gitglossary(7) nor git-cherry-pick(1) get this right.


 Documentation/git-sh-setup.txt |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index a2f346c..eb08ba6 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -68,6 +68,16 @@ require_work_tree_exists::
 	cd_to_toplevel, which is impossible to do if there is no
 	working tree.
 
+require_clean_work_tree <action> [<hint>]::
+	checks that the working tree and index associated with the
+	repository have no uncommitted changes to tracked files.
+	Otherwise it emits an error message of the form `Cannot
+	<action>: <reason>. <hint>`, and dies.  Example:
++
+----------------
+require_clean_work_tree rebase "Please commit or stash them."
+----------------
+
 get_author_ident_from_commit::
 	outputs code for use with eval to set the GIT_AUTHOR_NAME,
 	GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
-- 
1.7.8.484.gdad4270

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

* Re: [PATCH v3] git-sh-setup: make require_clean_work_tree part of the interface
  2011-12-20 21:42       ` [PATCH v3] " Thomas Rast
@ 2011-12-20 22:05         ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2011-12-20 22:05 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git

Thanks, will queue.

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

end of thread, other threads:[~2011-12-20 22:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 11:09 [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Thomas Rast
2011-12-20 11:09 ` [PATCH 2/2] Documentation: make git-sh-setup docs less scary Thomas Rast
2011-12-20 19:20   ` Junio C Hamano
2011-12-20 19:45   ` Ævar Arnfjörð Bjarmason
2011-12-20 20:27     ` Thomas Rast
2011-12-20 19:25 ` [PATCH 1/2] git-sh-setup: make require_clean_work_tree part of the interface Junio C Hamano
2011-12-20 20:29   ` [PATCH v2] " Thomas Rast
2011-12-20 20:52     ` Junio C Hamano
2011-12-20 21:42       ` [PATCH v3] " Thomas Rast
2011-12-20 22:05         ` Junio C Hamano

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.