diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2025-12-28 10:41:48 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2025-12-28 10:41:48 +0100 |
| commit | 71b67d680d9324b6b29c0cd73e04c15be5a96770 (patch) | |
| tree | a1598d8989ba4b8dd05a70a06c276767fc787727 /bin | |
| parent | dc3f34978376ff066892e369ccb287851581042c (diff) | |
| download | git-deli-71b67d680d9324b6b29c0cd73e04c15be5a96770.tar.gz git-deli-71b67d680d9324b6b29c0cd73e04c15be5a96770.tar.bz2 | |
implement head making
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/git-deli | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/bin/git-deli b/bin/git-deli index 60b5ff0..54101b3 100755 --- a/bin/git-deli +++ b/bin/git-deli @@ -101,14 +101,26 @@ main() { # cmd_head () { + # we're making a new head msg="$1" branch="$2" - # TODO one extra optional commit arg - # if the arg is there, this is "rebase" mode that picks up a deli view - # from the history and separates the commits into branches below it - # - # if it's not there, we make a new head on the current branch, possibly - # making a new one in the process + shift 2 + if [ $# -gt 1 ] + then die "too many arguments" + fi + + default_msg="delinearized head view" + if [ -n "$branch" ] + then + git checkout -b "$branch" "$@" || die "git-checkout failed" + default_msg="$commit_msg on $branch" + fi + new_head=$(git commit-tree HEAD^{tree} -p HEAD -m "${msg:-$default_msg}" || die "git-commit-tree failed") + git reset --soft "$new_head" || die "git-reset failed to set the new HEAD" +} + +cmd_go () { + # we're squashing whatever has been done atop of a given head view } cmd_commit () { @@ -133,22 +145,26 @@ cmd_merge () { # of the new head become all (latest) parents of all original heads. If # there is any actual merging required, it must be resolved elsewhere # and recorded in the history so that branches merge cleanly. + true } cmd_push () { # TODO like git-push but actually force-pushes the current multihead. # Uses a force-with-lease by default. + true } cmd_pull () { # TODO like a normal git fetch followed by git deli merge + true } # -# PRUNING ANCESTORS +# FINDING INDEPENDENT COMMIT SETS +# (by pruning ancestors) # -add_to_merge_points () { +add_to_independent_commit_set () { shas="$1" new="$2" for sha in $shas ; do @@ -177,10 +193,10 @@ add_to_merge_points () { [ $old = no ] && echo "$new" } -prune_merge_points () { +prune_independent_commit_set () { mps= while read sha trailing_garbage - do mps=$( add_to_merge_points "$mps" "$sha" ) + do mps=$( add_to_independent_commit_set "$mps" "$sha" ) done for sha in $mps do echo "$sha" |
