[PATCH] filter-branch: assume HEAD if no revision supplied
From: Brandon Casey <hidden>
Date: 2016-06-15 22:44:09
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 <redacted> --- 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