git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] filter-branch: only print usage information when no arguments supplied

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jan 31, 2008, 00:13 UTC
Message-ID
<47A112C5.8010903@nrlssc.navy.mil>
In-Reply-To
<47A109A7.1070502@nrlssc.navy.mil>

Testing for whether command line arguments were supplied was being performed during option parsing. This had the side effect of printing usage information when a more appropriate error message would have been printed had the script been allowed to continue.

Now this:
	git filter-branch
will print usage information.
And these:
	git filter-branch -d /tmp/work-dir
	git filter-branch <non-existant-revision>
	git filter-branch --
	git filter-branch -- <non-existant-revision>

will print a message informing the user that filter-branch did not know which reference to rewrite. Without this patch the one with '-d' would also print usage information.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---

I prefer my original patch since I think it is consistent with the git interface.

-brandon
 git-filter-branch.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ebf05ca..5e3fe70 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -97,6 +97,8 @@ USAGE="[--env-filter <command>] [--tree-filter <command>] \
 OPTIONS_SPEC=
 . git-sh-setup
 
+test $# = 0 && usage
+
 git diff-files --quiet &&
 	git diff-index --cached --quiet HEAD -- ||
 	die "Cannot rewrite branch(es) with a dirty working directory."
@@ -114,7 +116,6 @@ orig_namespace=refs/original/
 force=
 while :
 do
-	test $# = 0 && usage
 	case "$1" in
 	--)
 		shift
-- 
1.5.4.rc5.14.gaa8fc
Previous: Brandon CaseyNext: Junio C Hamano
Message 5 of 21 in “filter-branch: assume HEAD if no revision supplied”
  1. filter-branch: assume HEAD if no revision suppliedBrandon Casey, Jan 30, 2008
  2. Johannes SchindelinJan 30, 2008
  3. Junio C HamanoJan 30, 2008
  4. Brandon CaseyJan 30, 2008
  5. 1/2 filter-branch: only print usage information when no arguments suppliedBrandon Casey, Jan 31, 2008
  6. Junio C HamanoJan 31, 2008
  7. Brandon CaseyJan 31, 2008
  8. Junio C HamanoJan 31, 2008
  9. Johannes SchindelinJan 31, 2008
  10. Brandon CaseyJan 31, 2008
  11. filter-branch docs: remove brackets so not to imply revision arg is optionalBrandon Casey, Jan 31, 2008
  12. Junio C HamanoJan 31, 2008
  13. Johannes SchindelinJan 31, 2008
  14. Brandon CaseyJan 31, 2008
  15. Junio C HamanoJan 31, 2008
  16. 2/2 git-filter-branch.sh: don't use --default when calling rev-listBrandon Casey, Jan 31, 2008
  17. Johannes SchindelinJan 31, 2008
  18. Brandon CaseyJan 31, 2008
  19. Andreas EricssonJan 31, 2008
  20. Junio C HamanoJan 31, 2008
  21. Johannes SchindelinJan 31, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.