On Fri, 23 Apr 2021 13:42:12 -0600, Luke Shumaker wrote: > "Ignore space change" is probably helpful when viewing this diff. For mailing-list reading, the `git show -w` is --- diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 868e18b9a1..d1ed7f9a6c 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -4,10 +4,7 @@ # # Copyright (C) 2009 Avery Pennarun <apenwarr@xxxxxxxxx> # -if test $# -eq 0 -then - set -- -h -fi + OPTS_SPEC="\ git subtree add --prefix=<prefix> <commit> git subtree add --prefix=<prefix> <repository> <ref> @@ -30,12 +27,8 @@ rejoin merge the new branch back into HEAD options for 'add', 'merge', and 'pull' squash merge subtree changes as a single commit " -eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" PATH=$PATH:$(git --exec-path) -. git-sh-setup - -require_work_tree quiet= branch= @@ -84,6 +77,15 @@ ensure_single_rev () { fi } +main () { + if test $# -eq 0 + then + set -- -h + fi + eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" + . git-sh-setup + require_work_tree + while test $# -gt 0 do opt="$1" @@ -205,6 +207,9 @@ debug "dir: {$dir}" debug "opts: {$*}" debug + "cmd_$command" "$@" +} + cache_setup () { cachedir="$GIT_DIR/subtree-cache/$$" rm -rf "$cachedir" || @@ -898,4 +903,4 @@ cmd_push () { fi } -"cmd_$command" "$@" +main "$@"