Re: [PATCH v2] git-sh-setup: make require_clean_work_tree part of the interface

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v2] git-sh-setup: make require_clean_work_tree part of the interface

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:40

Thomas Rast [off-list ref] writes:
quoted hunk
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 <redacted>
---
 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.

[PATCH v3] git-sh-setup: make require_clean_work_tree part of the interface

From: Thomas Rast <hidden>
Date: 2016-06-15 22:52:40

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 <redacted>
---

Junio C Hamano writes:
Thomas Rast [off-list ref] writes:
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help