From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
A selection of updates to git-subtree were offered to the list in May of
last year ($gmane/196667) by Herman van Rink.
At the time the commits were available as either a single commit or a
large collection of commits and merges to the git-subtree prior to it's
inclusion in contrib/subtree.
The following patches take a selection of these commits and rebase them
against the tip of master.
The git-subtree tests work (make test), but they don't cover any of
the new commands added nor the use of the .gittrees file for storing
the subtree metadata.
If I could ask the original contributors to add their Signed-off-by, I
would appreciate it.
However I don't have current email addresses for four of them: Peter
Jaros, Michael Hart, Paul Cartwright and James Roper. If anyone has
current email address for any of these, please either forward the
relevant patch(es) to them or let me know so I can do so.
Herman van Rink (8):
contrib/subtree: Add prune command to OPTS_SPEC
contrib/subtree: Remove trailing slash from prefix parameter
contrib/subtree: Teach from-submodule to add new subtree to .gittrees
contrib/subtree: Document pull-all and push-all
contrib/subtree: Document from-submodule and prune commands
contrib/subtree: Add missing commands to SYNOPSIS
contrib/subtree: Document list command
contrib/subtree: Convert spaces to tabs and remove some trailing
whitespace
James Roper (1):
contrib/subtree: Teach push to use --force option
Matt Hoffman (6):
contrib/subtree: Teach add to store repository & branch in .gittrees
contrib/subtree: Rename commands push_all/pull_all to
push-all/pull-all
contrib/subtree: Teach push and pull to use .gittrees if needed
contrib/subtree: Replace invisible carriage return with a visible \r
contrib/subtree: Add command diff
contrib/subtree: Add command list
Michael Hart (1):
contrib/subtree: Teach push to abort if split fails
Nate Jones (1):
contrib/subtree: Add command prune
Paul Campbell (2):
contrib/subtree: Parameters repository/branch for push/pull are
optional
contrib/subtree: Fix order of case switches so default case is last
Paul Cartwright (1):
contrib/subtree: Fix typo (s/incldued/included/)
Peter Jaros (1):
contrib/subtree: Add command from-submodule
bibendi (2):
contrib/subtree: Teach push and pull to use .gittrees for defaults
contrib/subtree: Add commands pull_all and push_all
contrib/subtree/git-subtree.sh | 203 ++++++++++++++++++++++++++++++++++++----
contrib/subtree/git-subtree.txt | 46 +++++++--
2 files changed, 222 insertions(+), 27 deletions(-)
--
1.8.2.rc1
@@ -270,7 +270,7 @@ git-extensions repository in ~/git-extensions/: name You can omit the --squash flag, but doing so will increase the number-of commits that are incldued in your local repository.+of commits that are included in your local repository. We now have a ~/git-extensions/git-subtree directory containing code from the master branch of git://github.com/apenwarr/git-subtree.git
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Matt Hoffman <redacted>
The repository and branch of a subtree added with the add command is
stored in the .gittrees file.
Signed-off-by: Paul Campbell <redacted>
---
contrib/subtree/git-subtree.sh | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -528,6 +528,14 @@ cmd_add_repository()revs=FETCH_HEADset--$revscmd_add_commit"$@"++# now add it to our list of repos +gitconfig-f.gittrees--unsetsubtree.$dir.url+gitconfig-f.gittrees--addsubtree.$dir.url$repository+gitconfig-f.gittrees--unsetsubtree.$dir.path+gitconfig-f.gittrees--addsubtree.$dir.path$dir+gitconfig-f.gittrees--unsetsubtree.$dir.branch+gitconfig-f.gittrees--addsubtree.$dir.branch$refspec} cmd_add_commit()
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: bibendi <redacted>
Look in the config file .gittrees for a default repository and
refspec or commit when they are not provided on the command line.
Uses the .gittrees config file in a similar way to how git-submodule
uses the .gitmodules file.
Signed-off-by: Paul Campbell <redacted>
---
contrib/subtree/git-subtree.sh | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
@@ -708,21 +708,31 @@ cmd_merge() cmd_pull(){-ensure_clean-gitfetch"$@"||exit$?-revs=FETCH_HEAD-set--$revs-cmd_merge"$@"+if[$#-ne1];then+die"You must provide <branch>"+fi+if[-e"$dir"];then+ensure_clean+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+gitfetch$repository$refspec||exit$?+echo"git fetch using: "$repository$refspec+revs=FETCH_HEAD+set--$revs+cmd_merge"$@"+else+die"'$dir' must already exist. Try 'git subtree add'."+fi} cmd_push(){-if[$#-ne2];then-die"You must provide <repository> <refspec>"+if[$#-ne1];then+die"You must provide <branch>"fiif[-e"$dir"];then-repository=$1-refspec=$2+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1echo"git push using: "$repository$refspecgitpush$repository$(gitsubtreesplit--prefix=$prefix):refs/heads/$refspecelse
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: bibendi <redacted>
For each subtree listed in .gittrees perform a push or a pull.
Signed-off-by: Paul Campbell <redacted>
Conflicts:
contrib/subtree/git-subtree.sh
---
contrib/subtree/git-subtree.sh | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Matt Hoffman <redacted>
Only when a repository and/or branch are not supplied on the command
line will push and pull look for them in the .gittrees file.
Signed-off-by: Paul Campbell <redacted>
---
contrib/subtree/git-subtree.sh | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
@@ -712,13 +712,21 @@ cmd_merge() cmd_pull(){-if[$#-ne1];then-die"You must provide <branch>"+if[$#-gt2];then+die"You should provide either <refspec> or <repository> <refspec>"fiif[-e"$dir"];thenensure_clean-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$1+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+figitfetch$repository$refspec||exit$?echo"git fetch using: "$repository$refspecrevs=FETCH_HEAD
@@ -731,12 +739,20 @@ cmd_pull() cmd_push(){-if[$#-ne1];then-die"You must provide <branch>"+if[$#-gt2];then+die"You shold provide either <refspec> or <repository> <refspec>"fiif[-e"$dir"];then-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$1+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+fiecho"git push using: "$repository$refspecgitpush$repository$(gitsubtreesplit--prefix=$prefix):refs/heads/$refspecelse
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Matt Hoffman <redacted>
The ctrl-M (^M) character used for the carriage return (CR) is not visible
in all (most) text editors and is often silently converted to a new
line (NL) or CR/NL combo.
'say' is a wrapper for echo with accepts the option -e to interperet
escaped characters. \r becomes a CR, yet is not munged by text
editors.
Signed-off-by: Paul Campbell <redacted>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Michael Hart <redacted>
Added a check to ensure that split succeeds before trying to push.
Signed-off-by: Paul Campbell <redacted>
---
contrib/subtree/git-subtree.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Matt Hoffman <redacted>
Fetches the remote repo as a temporary git-remote then uses
git-diff-tree to do comparison before removing the temporary
git-remote.
Signed-off-by: Paul Campbell <redacted>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
@@ -737,6 +738,37 @@ cmd_pull()fi}+cmd_diff()+{+if[-e"$dir"];then+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+fi+# this is ugly, but I don't know of a better way to do it. My git-fu is weak. +# git diff-tree expects a treeish, but I have only a repository and branch name.+# I don't know how to turn that into a treeish without creating a remote.+# Please change this if you know a better way! +tmp_remote=__diff-tmp+gitremoterm$tmp_remote>/dev/null2>&1+gitremoteadd-t$refspec$tmp_remote$repository>/dev/null+# we fetch as a separate step so we can pass -q (quiet), which isn't an option for "git remote"+# could this instead be "git fetch -q $repository $refspec" and leave aside creating the remote?+# Still need a treeish for the diff-tree command...+gitfetch-q$tmp_remote+gitdiff-tree-prefs/remotes/$tmp_remote/$refspec+gitremoterm$tmp_remote>/dev/null2>&1+else+die"Cannot resolve directory '$dir'. Please point to an existing subtree directory to diff. Try 'git subtree add' to add a subtree."+fi+}+ cmd_push(){if[$#-gt2];then
@@ -107,10 +107,10 @@ shiftcase"$command"inadd|merge|pull|from-submodule|pull-all|push-all)default=;;*)die"Unknown command '$command'";;-split|push|diff)default="--default HEAD";;+split|push|diff|list)default="--default HEAD";;esac-if[-z"$prefix"-a"$command"!="pull-all"-a"$command"!="push-all"];then+if[-z"$prefix"-a"$command"!="pull-all"-a"$command"!="push-all"-a"$command"!="list"];thendie"You must provide the --prefix option."fi
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Nate Jones <redacted>
Removes entries in .gittrees where the subtree files are
no longer present on disk.
Signed-off-by: Paul Campbell <redacted>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
@@ -105,12 +105,12 @@ donecommand="$1"shiftcase"$command"in-add|merge|pull|from-submodule|pull-all|push-all)default=;;+add|merge|pull|from-submodule|pull-all|push-all|prune)default=;;*)die"Unknown command '$command'";;split|push|diff|list)default="--default HEAD";;esac-if[-z"$prefix"-a"$command"!="pull-all"-a"$command"!="push-all"-a"$command"!="list"];then+if[-z"$prefix"-a"$command"!="pull-all"-a"$command"!="push-all"-a"$command"!="list"-a"$command"!="prune"];thendie"You must provide the --prefix option."fi
@@ -806,6 +806,7 @@ cmd_from-submodule()ensure_cleanlocalsubmodule_sha=$(gitsubmodulestatus$prefix|cut-d' '-f2)+localsubmodule_orig_repo=$(gitconfig--file.gitmodulessubmodule.$prefix.url)# Remove references to submodule.gitconfig--remove-sectionsubmodule.$prefix
@@ -824,6 +825,10 @@ cmd_from-submodule()# subtree add from submodule repo.cmd_add_repository$tmp_repoHEAD+# Update .gittrees with the original repo url+gitconfig--file.gittrees--unsetsubtree.$prefix.url+gitconfig--file.gittreessubtree.$prefix.url$submodule_orig_repo+# Remove submodule repo.rm-rf$tmp_repo}
@@ -92,13 +92,19 @@ pull:: Exactly like 'merge', but parallels 'git pull' in that it fetches the given commit from the specified remote repository.-++pull-all::+ Perform a pull operation on all in .gittrees registered subtrees.+ push:: Does a 'split' (see below) using the <prefix> supplied and then does a 'git push' to push the result to the repository and refspec. This can be used to push your subtree to different branches of the remote repository.+push-all::+ Perform a pull operation on all in .gittrees registered subtrees.+ split:: Extract a new, synthetic project history from the history of the <prefix> subtree. The new history
@@ -129,6 +129,16 @@ split:: Note that if you use '--squash' when you merge, you should usually not just '--rejoin' when you split.+from-submodule::+ Convert a git submodule to a subtree.+ The module is removed from the .gitmodules file and+ the repo contents are integrated as a subtree.++prune::+ Cleanup .gittrees entries for which the subtree nolonger exists.++diff::+ TO BE DOCUMENTED OPTIONS -------
@@ -108,6 +109,9 @@ push:: push-all:: Perform a pull operation on all in .gittrees registered subtrees.+list::+ Show a list of the in .gittrees registered subtrees+ split:: Extract a new, synthetic project history from the history of the <prefix> subtree. The new history
@@ -32,6 +32,8 @@ b,branch= create a new branch from the split subtree ignore-joinsignoreprior--rejoincommitsonto=tryconnectingnewtreetoanexistingone rejoinmergethenewbranchbackintoHEAD+optionsfor'push'+f,forceuseforcepushoptionsfor'add','merge','pull'and'push' squashmergesubtreechangesasasinglecommit"
@@ -278,6 +278,11 @@ OPTIONS FOR split '--rejoin' when you split, because you don't want the subproject's history to be part of your project anyway.+OPTIONS FOR push+----------------+-f::+--force::+ Uses 'git push --force'. EXAMPLE 1. Add command ----------------------
From: Paul Campbell <hidden> Date: 2016-06-15 22:56:21
From: Herman van Rink <redacted>
Signed-off-by: Paul Campbell <redacted>
Conflicts:
contrib/subtree/.gitignore
contrib/subtree/git-subtree.sh
contrib/subtree/test.sh
---
It's a nasty formatting only patch and I won't be surprised or too dissappiointed
if this doesn't make it. Or are the rules for this more lax for contrib? How else
can contrib be brought in-line with coding standards?
contrib/subtree/git-subtree.sh | 213 +++++++++++++++++++++--------------------
1 file changed, 109 insertions(+), 104 deletions(-)
@@ -123,8 +123,10 @@ if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" != "push-all" -a "$cficase"$command"in-pull-all);;-push-all);;+pull-all);;+push-all);;+list);;+prune);;add)[-e"$prefix"]&&die"prefix '$prefix' already exists.";;*)[-e"$prefix"]||
@@ -541,14 +543,14 @@ cmd_add_repository()revs=FETCH_HEADset--$revscmd_add_commit"$@"--# now add it to our list of repos -gitconfig-f.gittrees--unsetsubtree.$dir.url-gitconfig-f.gittrees--addsubtree.$dir.url$repository-gitconfig-f.gittrees--unsetsubtree.$dir.path-gitconfig-f.gittrees--addsubtree.$dir.path$dir-gitconfig-f.gittrees--unsetsubtree.$dir.branch-gitconfig-f.gittrees--addsubtree.$dir.branch$refspec++# now add it to our list of repos+gitconfig-f.gittrees--unsetsubtree.$dir.url+gitconfig-f.gittrees--addsubtree.$dir.url$repository+gitconfig-f.gittrees--unsetsubtree.$dir.path+gitconfig-f.gittrees--addsubtree.$dir.path$dir+gitconfig-f.gittrees--unsetsubtree.$dir.branch+gitconfig-f.gittrees--addsubtree.$dir.branch$refspec} cmd_add_commit()
@@ -721,89 +723,91 @@ cmd_merge() cmd_pull(){-if[$#-gt2];then-die"You should provide either <refspec> or <repository> <refspec>"+if[$#-gt2];then+die"You should provide either <refspec> or <repository> <refspec>"fiif[-e"$dir"];then-ensure_clean-if[$#-eq1];then-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$1-elif[$#-eq2];then-repository=$1-refspec=$2-else-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)-fi-gitfetch$repository$refspec||exit$?-echo"git fetch using: "$repository$refspec-revs=FETCH_HEAD-set--$revs-cmd_merge"$@"+ensure_clean+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+fi+gitfetch$repository$refspec||exit$?+echo"git fetch using: "$repository$refspec+revs=FETCH_HEAD+set--$revs+cmd_merge"$@"else-die"'$dir' must already exist. Try 'git subtree add'."+die"'$dir' must already exist. Try 'git subtree add'."fi}-cmd_diff()-{-if[-e"$dir"];then-if[$#-eq1];then-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$1-elif[$#-eq2];then-repository=$1-refspec=$2-else-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)-fi-# this is ugly, but I don't know of a better way to do it. My git-fu is weak. -# git diff-tree expects a treeish, but I have only a repository and branch name.-# I don't know how to turn that into a treeish without creating a remote.-# Please change this if you know a better way! -tmp_remote=__diff-tmp-gitremoterm$tmp_remote>/dev/null2>&1-gitremoteadd-t$refspec$tmp_remote$repository>/dev/null-# we fetch as a separate step so we can pass -q (quiet), which isn't an option for "git remote"-# could this instead be "git fetch -q $repository $refspec" and leave aside creating the remote?-# Still need a treeish for the diff-tree command...-gitfetch-q$tmp_remote-gitdiff-tree-prefs/remotes/$tmp_remote/$refspec-gitremoterm$tmp_remote>/dev/null2>&1-else-die"Cannot resolve directory '$dir'. Please point to an existing subtree directory to diff. Try 'git subtree add' to add a subtree."-fi+cmd_diff()+{+if[-e"$dir"];then+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+fi+# this is ugly, but I don't know of a better way to do it. My git-fu is weak.+# git diff-tree expects a treeish, but I have only a repository and branch name.+# I don't know how to turn that into a treeish without creating a remote.+# Please change this if you know a better way!+tmp_remote=__diff-tmp+gitremoterm$tmp_remote>/dev/null2>&1+gitremoteadd-t$refspec$tmp_remote$repository>/dev/null+# we fetch as a separate step so we can pass -q (quiet), which isn't an option for "git remote"+# could this instead be "git fetch -q $repository $refspec" and leave aside creating the remote?+# Still need a treeish for the diff-tree command...+gitfetch-q$tmp_remote+gitdiff-tree-prefs/remotes/$tmp_remote/$refspec+gitremoterm$tmp_remote>/dev/null2>&1+else+die"Cannot resolve directory '$dir'. Please point to an existing subtree directory to diff. Try 'git subtree add' to add a subtree."+fi} cmd_push(){if[$#-gt2];then-die"You shold provide either <refspec> or <repository> <refspec>"+die"You shold provide either <refspec> or <repository> <refspec>"fiif[-e"$dir"];then-if[$#-eq1];then-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$1-elif[$#-eq2];then-repository=$1-refspec=$2-else-repository=$(gitconfig-f.gittreessubtree.$prefix.url)-refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)-fi-push_opts=-if["$force"=="1"];then-push_opts="$push_opts --force"-fi-echo"git push using: "$repository$refspec-rev=$(gitsubtreesplit--prefix=$prefix)-if[-n"$rev"];then-gitpush$push_opts$repository$rev:refs/heads/$refspec-else-die"Couldn't push, 'git subtree split' failed."-fi+if[$#-eq1];then+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$1+elif[$#-eq2];then+repository=$1+refspec=$2+else+repository=$(gitconfig-f.gittreessubtree.$prefix.url)+refspec=$(gitconfig-f.gittreessubtree.$prefix.branch)+fi++push_opts=+if["$force"=="1"];then+push_opts="$push_opts --force"+fi++echo"git push using: "$repository$refspec+rev=$(gitsubtreesplit--prefix=$prefix)+if[-n"$rev"];then+gitpush$push_opts$repository$rev:refs/heads/$refspec+else+die"Couldn't push, 'git subtree split' failed."+fielsedie"'$dir' must already exist. Try 'git subtree add'."fi
@@ -831,6 +835,7 @@ cmd_from-submodule()gitcommit-m"Remove '$prefix/' submodule"# subtree add from submodule repo.+# TODO: Could be determin HEAD to be a specific branchcmd_add_repository$tmp_repoHEAD# Update .gittrees with the original repo url