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

[PATCH] filter-branch: assume HEAD if no revision supplied

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jan 30, 2008, 19:33 UTC
Message-ID
<47A0D0F0.1020800@nrlssc.navy.mil>

filter-branch previously took the first non-option argument as the name for a new branch. Since dfd05e38, it now takes a revision or a revision range and modifies the current branch. Update to operate on HEAD by default to conform with standard git interface practice.

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

You may think that filter-branch _should_ require the user to specify the revision. If so, then '--default HEAD' should probably be removed from the other two places, and the usage and documentation should be updated to remove the brackets around <rev-list options> so not to imply that it is optional. The test for at least one non-option argument can still be removed since it can currently be circumvented by placing -- as the last argument and because it would allow format-patch to fail with a much nicer message: "Which ref do you want to rewrite?".

fwiw the behavior this patch implements is what I expected.
-brandon
 git-filter-branch.sh |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ebf05ca..cd1eeee 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -114,7 +114,6 @@ orig_namespace=refs/original/
 force=
 while :
 do
-	test $# = 0 && usage
 	case "$1" in
 	--)
 		shift
@@ -210,7 +209,7 @@ GIT_WORK_TREE=.
 export GIT_DIR GIT_WORK_TREE
 
 # The refs should be updated if their heads were rewritten
-git rev-parse --no-flags --revs-only --symbolic-full-name "$@" |
+git rev-parse --no-flags --revs-only --symbolic-full-name --default HEAD "$@" |
 sed -e '/^^/d' >"$tempdir"/heads
 
 test -s "$tempdir"/heads ||
-- 
1.5.4.rc5.14.gaa8fc
Next: Johannes Schindelin
Message 1 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.