mirror of
https://github.com/git/git.git
synced 2024-11-01 23:07:55 +01:00
New --branch option to split command.
This is just a handy way to create a new branch from the newly-split subtree.
This commit is contained in:
parent
f96bc79019
commit
43a3951243
2 changed files with 29 additions and 7 deletions
|
@ -19,15 +19,17 @@ d show debug messages
|
||||||
prefix= the name of the subdir to split out
|
prefix= the name of the subdir to split out
|
||||||
options for 'split'
|
options for 'split'
|
||||||
annotate= add a prefix to commit message of new commits
|
annotate= add a prefix to commit message of new commits
|
||||||
|
b,branch= create a new branch from the split subtree
|
||||||
|
ignore-joins ignore prior --rejoin commits
|
||||||
onto= try connecting new tree to an existing one
|
onto= try connecting new tree to an existing one
|
||||||
rejoin merge the new branch back into HEAD
|
rejoin merge the new branch back into HEAD
|
||||||
ignore-joins ignore prior --rejoin commits
|
|
||||||
"
|
"
|
||||||
eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
|
eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
require_work_tree
|
require_work_tree
|
||||||
|
|
||||||
quiet=
|
quiet=
|
||||||
|
branch=
|
||||||
debug=
|
debug=
|
||||||
command=
|
command=
|
||||||
onto=
|
onto=
|
||||||
|
@ -69,6 +71,7 @@ while [ $# -gt 0 ]; do
|
||||||
-d) debug=1 ;;
|
-d) debug=1 ;;
|
||||||
--annotate) annotate="$1"; shift ;;
|
--annotate) annotate="$1"; shift ;;
|
||||||
--no-annotate) annotate= ;;
|
--no-annotate) annotate= ;;
|
||||||
|
-b) branch="$1"; shift ;;
|
||||||
--prefix) prefix="$1"; shift ;;
|
--prefix) prefix="$1"; shift ;;
|
||||||
--no-prefix) prefix= ;;
|
--no-prefix) prefix= ;;
|
||||||
--onto) onto="$1"; shift ;;
|
--onto) onto="$1"; shift ;;
|
||||||
|
@ -78,6 +81,7 @@ while [ $# -gt 0 ]; do
|
||||||
--ignore-joins) ignore_joins=1 ;;
|
--ignore-joins) ignore_joins=1 ;;
|
||||||
--no-ignore-joins) ignore_joins= ;;
|
--no-ignore-joins) ignore_joins= ;;
|
||||||
--) break ;;
|
--) break ;;
|
||||||
|
*) die "Unexpected option: $opt" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -139,12 +143,21 @@ cache_set()
|
||||||
echo "$newrev" >"$cachedir/$oldrev"
|
echo "$newrev" >"$cachedir/$oldrev"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev_exists()
|
||||||
|
{
|
||||||
|
if git rev-parse "$1" >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# if a commit doesn't have a parent, this might not work. But we only want
|
# if a commit doesn't have a parent, this might not work. But we only want
|
||||||
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
||||||
# be there anyway, so do nothing in that case.
|
# be there anyway, so do nothing in that case.
|
||||||
try_remove_previous()
|
try_remove_previous()
|
||||||
{
|
{
|
||||||
if git rev-parse "$1^" >/dev/null 2>&1; then
|
if rev_exists "$1^"; then
|
||||||
echo "^$1^"
|
echo "^$1^"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -344,6 +357,10 @@ cmd_add()
|
||||||
|
|
||||||
cmd_split()
|
cmd_split()
|
||||||
{
|
{
|
||||||
|
if [ -n "$branch" ] && rev_exists "refs/heads/$branch"; then
|
||||||
|
die "Branch '$branch' already exists."
|
||||||
|
fi
|
||||||
|
|
||||||
debug "Splitting $dir..."
|
debug "Splitting $dir..."
|
||||||
cache_setup || exit $?
|
cache_setup || exit $?
|
||||||
|
|
||||||
|
@ -408,6 +425,11 @@ cmd_split()
|
||||||
-m "$(merge_msg $dir $latest_old $latest_new)" \
|
-m "$(merge_msg $dir $latest_old $latest_new)" \
|
||||||
$latest_new >&2 || exit $?
|
$latest_new >&2 || exit $?
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$branch" ]; then
|
||||||
|
git update-ref -m 'subtree split' "refs/heads/$branch" \
|
||||||
|
$latest_new "" || exit $?
|
||||||
|
say "Created branch '$branch'"
|
||||||
|
fi
|
||||||
echo $latest_new
|
echo $latest_new
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
10
todo
10
todo
|
@ -3,18 +3,18 @@
|
||||||
|
|
||||||
delete tempdir
|
delete tempdir
|
||||||
|
|
||||||
--annotate-sometimes: only annotate if the patch also changes files
|
|
||||||
outside the subdir?
|
|
||||||
|
|
||||||
'git subtree rejoin' option to do the same as --rejoin, eg. after a
|
'git subtree rejoin' option to do the same as --rejoin, eg. after a
|
||||||
rebase
|
rebase
|
||||||
|
|
||||||
|
--prefix doesn't force the subtree correctly in merge/pull:
|
||||||
"-s subtree" should be given an explicit subtree option?
|
"-s subtree" should be given an explicit subtree option?
|
||||||
|
There doesn't seem to be a way to do this. We'd have to
|
||||||
--prefix doesn't force the subtree correctly in merge/pull
|
patch git-merge-subtree. Ugh.
|
||||||
|
|
||||||
add a 'push' subcommand to parallel 'pull'
|
add a 'push' subcommand to parallel 'pull'
|
||||||
|
|
||||||
|
add a 'log' subcommand to see what's new in a subtree?
|
||||||
|
|
||||||
add a --squash option so we don't merge histories but can still split
|
add a --squash option so we don't merge histories but can still split
|
||||||
|
|
||||||
add to-submodule and from-submodule commands
|
add to-submodule and from-submodule commands
|
||||||
|
|
Loading…
Reference in a new issue