* [PATCH v2 01/23] contrib/subtree: Fix typo (s/incldued/included/)
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 02/23] contrib/subtree: Add command from-submodule Paul Campbell
` (21 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Paul Cartwright, Paul Campbell, Dan Sabath
From: Paul Cartwright <paul.cartwright@ziilabs.com>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..e0957ee 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -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
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 02/23] contrib/subtree: Add command from-submodule
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
2013-03-10 23:41 ` [PATCH v2 01/23] contrib/subtree: Fix typo (s/incldued/included/) Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-11 3:19 ` Junio C Hamano
2013-03-10 23:41 ` [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees Paul Campbell
` (20 subsequent siblings)
22 siblings, 1 reply; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Peter Jaros, Paul Campbell, Avery Pennarun, Wayne Walter
From: Peter Jaros <pjaros@pivotallabs.com>
Converts a git-submodule into a git-subtree.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
.gitignore
contrib/subtree/git-subtree.sh
test.sh
---
contrib/subtree/git-subtree.sh | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..caf4988 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -14,6 +14,7 @@ git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
+git subtree from-submodule --prefix=<prefix>
--
h,help show the help
q quiet
@@ -101,7 +102,7 @@ done
command="$1"
shift
case "$command" in
- add|merge|pull) default= ;;
+ add|merge|pull|from-submodule) default= ;;
split|push) default="--default HEAD" ;;
*) die "Unknown command '$command'" ;;
esac
@@ -721,4 +722,31 @@ cmd_push()
fi
}
+cmd_from-submodule()
+{
+ ensure_clean
+
+ local submodule_sha=$(git submodule status $prefix | cut -d ' ' -f 2)
+
+ # Remove references to submodule.
+ git config --remove-section submodule.$prefix
+ git config --file .gitmodules --remove-section submodule.$prefix
+ git add .gitmodules
+
+ # Move submodule aside.
+ local tmp_repo="$(mktemp -d /tmp/git-subtree.XXXXX)"
+ rm -r $tmp_repo
+ mv $prefix $tmp_repo
+ git rm $prefix
+
+ # Commit changes.
+ git commit -m "Remove '$prefix/' submodule"
+
+ # subtree add from submodule repo.
+ cmd_add_repository $tmp_repo HEAD
+
+ # Remove submodule repo.
+ rm -rf $tmp_repo
+}
+
"cmd_$command" "$@"
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v2 02/23] contrib/subtree: Add command from-submodule
2013-03-10 23:41 ` [PATCH v2 02/23] contrib/subtree: Add command from-submodule Paul Campbell
@ 2013-03-11 3:19 ` Junio C Hamano
2013-03-24 20:59 ` [PATCH] " Paul Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Junio C Hamano @ 2013-03-11 3:19 UTC (permalink / raw)
To: Paul Campbell
Cc: git, David Greene, Peter Jaros, Avery Pennarun, Wayne Walter
Paul Campbell <pcampbell@kemitix.net> writes:
> @@ -721,4 +722,31 @@ cmd_push()
> fi
> }
>
> +cmd_from-submodule()
> +{
I know contrib/subtree does not work with anything other than bash,
and bash may accept this as a valid function name, but if you can
avoid it easily I would prefer not to see a non-POSIX construct like
this in my tree, even in contrib/ part:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_230
because people often reference random parts of the tree and mimick
what existing code does.
> + ensure_clean
> +
> + local submodule_sha=$(git submodule status $prefix | cut -d ' ' -f 2)
Is $prefix guaranteed not to have any $IFS whitespaces?
> + # Remove references to submodule.
> + git config --remove-section submodule.$prefix
> + git config --file .gitmodules --remove-section submodule.$prefix
> + git add .gitmodules
> +
> + # Move submodule aside.
> + local tmp_repo="$(mktemp -d /tmp/git-subtree.XXXXX)"
Doesn't "git subtree" honor TMPDIR? Not complaining, but being
curious.
> + rm -r $tmp_repo
> + mv $prefix $tmp_repo
> + git rm $prefix
Is $prefix guaranteed not to have any $IFS whitespaces?
> +
> + # Commit changes.
> + git commit -m "Remove '$prefix/' submodule"
> +
> + # subtree add from submodule repo.
> + cmd_add_repository $tmp_repo HEAD
> +
> + # Remove submodule repo.
> + rm -rf $tmp_repo
> +}
> +
> "cmd_$command" "$@"
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH] contrib/subtree: Add command from-submodule
2013-03-11 3:19 ` Junio C Hamano
@ 2013-03-24 20:59 ` Paul Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-24 20:59 UTC (permalink / raw)
To: git; +Cc: greened, Paul Campbell, Avery Pennarun, Wayne Walter
Converts a git-submodule into a git-subtree.
Based-on-patch-by: Peter Jaros <pjaros@pivotallabs.com>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index a81dfef..5e3c0b8 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -14,6 +14,7 @@ git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
+git subtree from-submodule --prefix=<prefix>
--
h,help show the help
q quiet
@@ -114,7 +115,7 @@ prefix="${prefix%/}";
command="$1"
shift
case "$command" in
- add|merge|pull) default= ;;
+ add|merge|pull|from-submodule) default= ;;
split|push) default="--default HEAD" ;;
*) die "Unknown command '$command'" ;;
esac
@@ -140,7 +141,14 @@ if ( test "$command" != "pull" ) && ( test "$command" != "add" ) && ( test "$com
fi
fi
+# map command to a function
+case $command in
+ from-submodule) cmd=cmd_from_submodule;;
+ *) cmd="cmd_$command";;
+esac
+
debug "command: {$command}"
+debug "function: {$function}"
debug "quiet: {$quiet}"
debug "revs: {$revs}"
debug "dir: {$dir}"
@@ -766,4 +774,29 @@ cmd_push()
fi
}
-"cmd_$command" "$@"
+cmd_from_submodule()
+{
+ ensure_clean
+
+ # Remove references to submodule.
+ git config --remove-section "submodule.$prefix"
+ git config --file .gitmodules --remove-section "submodule.$prefix"
+ git add .gitmodules
+
+ # Move submodule aside.
+ tmp_repo="$(mktemp -d git-subtree.XXXXX)"
+ rm -r $tmp_repo
+ mv "$prefix" $tmp_repo
+ git rm "$prefix"
+
+ # Commit changes.
+ git commit -m "Remove '$prefix/' submodule"
+
+ # subtree add from submodule repo.
+ cmd_add_repository $tmp_repo HEAD
+
+ # Remove submodule repo.
+ rm -rf $tmp_repo
+}
+
+"$cmd" "$@"
--
1.8.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
2013-03-10 23:41 ` [PATCH v2 01/23] contrib/subtree: Fix typo (s/incldued/included/) Paul Campbell
2013-03-10 23:41 ` [PATCH v2 02/23] contrib/subtree: Add command from-submodule Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-11 3:24 ` Junio C Hamano
2013-03-10 23:41 ` [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults Paul Campbell
` (19 subsequent siblings)
22 siblings, 1 reply; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Matt Hoffman, Paul Campbell, Wayne Walter
From: Matt Hoffman <matt.hoffman@quantumretail.com>
The repository and branch of a subtree added with the add command is
stored in the .gittrees file.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index caf4988..7b70251 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -528,6 +528,14 @@ cmd_add_repository()
revs=FETCH_HEAD
set -- $revs
cmd_add_commit "$@"
+
+ # now add it to our list of repos
+ git config -f .gittrees --unset subtree.$dir.url
+ git config -f .gittrees --add subtree.$dir.url $repository
+ git config -f .gittrees --unset subtree.$dir.path
+ git config -f .gittrees --add subtree.$dir.path $dir
+ git config -f .gittrees --unset subtree.$dir.branch
+ git config -f .gittrees --add subtree.$dir.branch $refspec
}
cmd_add_commit()
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees
2013-03-10 23:41 ` [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees Paul Campbell
@ 2013-03-11 3:24 ` Junio C Hamano
2013-03-24 20:17 ` Paul Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Junio C Hamano @ 2013-03-11 3:24 UTC (permalink / raw)
To: Paul Campbell; +Cc: git, David Greene, Matt Hoffman, Wayne Walter
Paul Campbell <pcampbell@kemitix.net> writes:
> From: Matt Hoffman <matt.hoffman@quantumretail.com>
>
> The repository and branch of a subtree added with the add command is
> stored in the .gittrees file.
>
> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
> ---
> contrib/subtree/git-subtree.sh | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index caf4988..7b70251 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -528,6 +528,14 @@ cmd_add_repository()
> revs=FETCH_HEAD
> set -- $revs
> cmd_add_commit "$@"
> +
> + # now add it to our list of repos
> + git config -f .gittrees --unset subtree.$dir.url
> + git config -f .gittrees --add subtree.$dir.url $repository
> + git config -f .gittrees --unset subtree.$dir.path
> + git config -f .gittrees --add subtree.$dir.path $dir
> + git config -f .gittrees --unset subtree.$dir.branch
> + git config -f .gittrees --add subtree.$dir.branch $refspec
Existing code in the function this touches seem to be written
carefully to allow $IFS whitespace in $dir, but this change butchers
it, it seems.
Also, where does $refspec come from? When this is called from
cmd_add_repository(), there is an assignment to the variable, but it
is not all clear. As git-subtree declares it won't work with
anything but bash, I think things like this should take advantage of
being written for bash by using "local" and passing arguments
explicitly instead of relying on global variables, which POSIX shell
scripts cannot afford to do but bash scripts can.
> }
>
> cmd_add_commit()
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees
2013-03-11 3:24 ` Junio C Hamano
@ 2013-03-24 20:17 ` Paul Campbell
2013-03-24 20:22 ` [PATCH] " Paul Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Paul Campbell @ 2013-03-24 20:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, David Greene, Matt Hoffman, Wayne Walter
On Mon, Mar 11, 2013 at 3:24 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Paul Campbell <pcampbell@kemitix.net> writes:
>
>> From: Matt Hoffman <matt.hoffman@quantumretail.com>
>>
>> The repository and branch of a subtree added with the add command is
>> stored in the .gittrees file.
>>
>> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
>> ---
>> contrib/subtree/git-subtree.sh | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index caf4988..7b70251 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -528,6 +528,14 @@ cmd_add_repository()
>> revs=FETCH_HEAD
>> set -- $revs
>> cmd_add_commit "$@"
>> +
>> + # now add it to our list of repos
>> + git config -f .gittrees --unset subtree.$dir.url
>> + git config -f .gittrees --add subtree.$dir.url $repository
>> + git config -f .gittrees --unset subtree.$dir.path
>> + git config -f .gittrees --add subtree.$dir.path $dir
>> + git config -f .gittrees --unset subtree.$dir.branch
>> + git config -f .gittrees --add subtree.$dir.branch $refspec
>
> Existing code in the function this touches seem to be written
> carefully to allow $IFS whitespace in $dir, but this change butchers
> it, it seems.
>
> Also, where does $refspec come from? When this is called from
> cmd_add_repository(), there is an assignment to the variable, but it
> is not all clear. As git-subtree declares it won't work with
> anything but bash, I think things like this should take advantage of
> being written for bash by using "local" and passing arguments
> explicitly instead of relying on global variables, which POSIX shell
> scripts cannot afford to do but bash scripts can.
>
>> }
>>
>> cmd_add_commit()
$refspec gets assigned in the third line of the function. The function
has only one caller in cmd_add() inside an if clause that requires
there be two parameters.
Personally I'd rather move git-subtree to be more portable and less
dependant on bash. I've sent some patches earlier to remove that
dependancy. As far as I could see there wasn't really anything that
was bash-only.
Reroll of this patch coming shortly allowing for $IFS whitespace.
--
Paul [W] Campbell
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH] contrib/subtree: Teach add to store repository & branch in .gittrees
2013-03-24 20:17 ` Paul Campbell
@ 2013-03-24 20:22 ` Paul Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-24 20:22 UTC (permalink / raw)
To: git; +Cc: greened, Matt Hoffman, Paul Campbell, Wayne Walter
From: Matt Hoffman <matt.hoffman@quantumretail.com>
The repository and branch of a subtree added with the add command is
stored in the .gittrees file.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
Rerolled allowing for $IFS whitespace.
contrib/subtree/git-subtree.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..b6e821e 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -527,6 +527,14 @@ cmd_add_repository()
revs=FETCH_HEAD
set -- $revs
cmd_add_commit "$@"
+
+ # now add it to our list of repos
+ git config -f .gittrees --unset subtree."$dir".url
+ git config -f .gittrees --add subtree."$dir".url "$repository"
+ git config -f .gittrees --unset subtree."$dir".path
+ git config -f .gittrees --add subtree."$dir".path "$dir"
+ git config -f .gittrees --unset subtree."$dir".branch
+ git config -f .gittrees --add subtree."$dir".branch "$refspec"
}
cmd_add_commit()
--
1.8.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (2 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-11 3:35 ` Junio C Hamano
2013-03-10 23:41 ` [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all Paul Campbell
` (18 subsequent siblings)
22 siblings, 1 reply; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, bibendi, Paul Campbell, Avery Pennarun, Wayne Walter
From: bibendi <bibendi@bk.ru>
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 <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7b70251..1aff956 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -708,21 +708,31 @@ cmd_merge()
cmd_pull()
{
- ensure_clean
- git fetch "$@" || exit $?
- revs=FETCH_HEAD
- set -- $revs
- cmd_merge "$@"
+ if [ $# -ne 1 ]; then
+ die "You must provide <branch>"
+ fi
+ if [ -e "$dir" ]; then
+ ensure_clean
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ git fetch $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 [ $# -ne 2 ]; then
- die "You must provide <repository> <refspec>"
+ if [ $# -ne 1 ]; then
+ die "You must provide <branch>"
fi
if [ -e "$dir" ]; then
- repository=$1
- refspec=$2
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
echo "git push using: " $repository $refspec
git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
else
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults
2013-03-10 23:41 ` [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults Paul Campbell
@ 2013-03-11 3:35 ` Junio C Hamano
2013-03-24 21:22 ` Paul Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Junio C Hamano @ 2013-03-11 3:35 UTC (permalink / raw)
To: Paul Campbell; +Cc: git, David Greene, bibendi, Avery Pennarun, Wayne Walter
> From: bibendi <bibendi@bk.ru>
>
> 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.
What the patch does can be read from the code, but what benefit
would users get by the extra file?
> cmd_pull()
> {
> - ensure_clean
> - git fetch "$@" || exit $?
> - revs=FETCH_HEAD
> - set -- $revs
> - cmd_merge "$@"
> + if [ $# -ne 1 ]; then
Broken indentation?
> + die "You must provide <branch>"
> + fi
It used to allow "git fetch $there" and let the configured
remote.$there.fetch refspec to decide what gets fetched, and also it
used to allow "git fetch $there $that_branch" to explicitly fetch
the named branch. But this change insists that the user has to give
what gets fetched from the command line and forbids the user from
giving where to fetch from, it seems. Isn't it a regression? Why
is it a good idea to forbid such uses that the script used to
accept?
The proposed log message does not explain why it is not a
regression, or why accepting some use patterns that the script used
to allow was a bug that needs to be diagnosed with this new
conditional.
> + if [ -e "$dir" ]; then
> + ensure_clean
> + repository=$(git config -f .gittrees subtree.$prefix.url)
> + refspec=$1
> + git fetch $repository $refspec || exit $?
> + echo "git fetch using: " $repository $refspec
Why are these variable references outside the dq pair?
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults
2013-03-11 3:35 ` Junio C Hamano
@ 2013-03-24 21:22 ` Paul Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-24 21:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, David Greene, bibendi, Avery Pennarun, Wayne Walter
On Mon, Mar 11, 2013 at 3:35 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> From: bibendi <bibendi@bk.ru>
>>
>> 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.
>
> What the patch does can be read from the code, but what benefit
> would users get by the extra file?
How about:
"Usually push and pull are to the same repository/branch that they were
originally added from. Add stores the repository/branch in .gittrees
which push and pull can now default to if not provided on the command
line."
>> cmd_pull()
>> {
>> - ensure_clean
>> - git fetch "$@" || exit $?
>> - revs=FETCH_HEAD
>> - set -- $revs
>> - cmd_merge "$@"
>> + if [ $# -ne 1 ]; then
>
> Broken indentation?
>
>> + die "You must provide <branch>"
>> + fi
>
> It used to allow "git fetch $there" and let the configured
> remote.$there.fetch refspec to decide what gets fetched, and also it
> used to allow "git fetch $there $that_branch" to explicitly fetch
> the named branch. But this change insists that the user has to give
> what gets fetched from the command line and forbids the user from
> giving where to fetch from, it seems. Isn't it a regression? Why
> is it a good idea to forbid such uses that the script used to
> accept?
>
> The proposed log message does not explain why it is not a
> regression, or why accepting some use patterns that the script used
> to allow was a bug that needs to be diagnosed with this new
> conditional.
I think the patch was based on an older version of git-subtree before
"git fetch $there" support was added. Will need to update it.
>> + if [ -e "$dir" ]; then
>> + ensure_clean
>> + repository=$(git config -f .gittrees subtree.$prefix.url)
>> + refspec=$1
>> + git fetch $repository $refspec || exit $?
>> + echo "git fetch using: " $repository $refspec
>
> Why are these variable references outside the dq pair?
>
They're inside now.
Rerolling once I figure out the update for "git fetch $there" support.
--
Paul [W] Campbell
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (3 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-11 5:03 ` Junio C Hamano
2013-03-10 23:41 ` [PATCH v2 06/23] contrib/subtree: Rename commands push_all/pull_all to push-all/pull-all Paul Campbell
` (17 subsequent siblings)
22 siblings, 1 reply; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, bibendi, Paul Campbell, Peter Jaros,
Avery Pennarun, Win Treese, Wayne Walter
From: bibendi <bibendi@bk.ru>
For each subtree listed in .gittrees perform a push or a pull.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
contrib/subtree/git-subtree.sh
---
contrib/subtree/git-subtree.sh | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 1aff956..ddae56e 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -12,6 +12,7 @@ git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <commit>
git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
+git subtree pull_all
git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
git subtree from-submodule --prefix=<prefix>
@@ -102,16 +103,18 @@ done
command="$1"
shift
case "$command" in
- add|merge|pull|from-submodule) default= ;;
+ add|merge|pull|from-submodule|pull_all|push_all) default= ;;
split|push) default="--default HEAD" ;;
*) die "Unknown command '$command'" ;;
esac
-if [ -z "$prefix" ]; then
+if [ -z "$prefix" -a "$command" != "pull_all" -a "$command" != "push_all" ]; then
die "You must provide the --prefix option."
fi
case "$command" in
+ pull_all);;
+ push_all);;
add) [ -e "$prefix" ] &&
die "prefix '$prefix' already exists." ;;
*) [ -e "$prefix" ] ||
@@ -120,7 +123,7 @@ esac
dir="$(dirname "$prefix/.")"
-if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" ]; then
+if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" -a "$command" != "pull_all" ]; then
revs=$(git rev-parse $default --revs-only "$@") || exit $?
dirs="$(git rev-parse --no-revs --no-flags "$@")" || exit $?
if [ -n "$dirs" ]; then
@@ -767,4 +770,20 @@ cmd_from-submodule()
rm -rf $tmp_repo
}
+cmd_pull_all()
+{
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ git subtree pull -P $path master || exit $?
+ done
+}
+
+cmd_push_all()
+{
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ git subtree push -P $path master || exit $?
+ done
+}
+
"cmd_$command" "$@"
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all
2013-03-10 23:41 ` [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all Paul Campbell
@ 2013-03-11 5:03 ` Junio C Hamano
2013-03-11 11:49 ` Paul Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Junio C Hamano @ 2013-03-11 5:03 UTC (permalink / raw)
To: Paul Campbell
Cc: git, David Greene, bibendi, Peter Jaros, Avery Pennarun,
Win Treese, Wayne Walter
Paul Campbell <pcampbell@kemitix.net> writes:
> From: bibendi <bibendi@bk.ru>
>
> For each subtree listed in .gittrees perform a push or a pull.
>
> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
>
> Conflicts:
> contrib/subtree/git-subtree.sh
The "Conflicts:" part is totally irrelevant. Please remove.
> ---
> contrib/subtree/git-subtree.sh | 25 ++++++++++++++++++++++---
> 1 file changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 1aff956..ddae56e 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -12,6 +12,7 @@ git subtree add --prefix=<prefix> <commit>
> git subtree add --prefix=<prefix> <repository> <commit>
> git subtree merge --prefix=<prefix> <commit>
> git subtree pull --prefix=<prefix> <repository> <refspec...>
> +git subtree pull_all
Why isn't it "pull --all"?
> git subtree push --prefix=<prefix> <repository> <refspec...>
Where did "push_all" go?
> +cmd_pull_all()
> +{
> + git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
"grep -o" is not even in POSIX. Besides, what is this trying to
parse? Is it expected to match lines like
path.subtree=trash
with this, or is it more like you only want something like this:
subtree.over/there.path=foo
in which case you would want to read with something like
sed -n -e 's/^subtree\...*\.path=\(.*\)/\1/p'
instead (modulo the usual caveat on $IFS whitespaces in path)?
> + while read path; do
> + git subtree pull -P $path master || exit $?
> + done
> +}
I'd stop looking at this series myself at this step for now.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all
2013-03-11 5:03 ` Junio C Hamano
@ 2013-03-11 11:49 ` Paul Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-11 11:49 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, David Greene
On Mon, Mar 11, 2013 at 5:03 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Paul Campbell <pcampbell@kemitix.net> writes:
>
>> From: bibendi <bibendi@bk.ru>
>>
>> For each subtree listed in .gittrees perform a push or a pull.
>>
>> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
>>
>> Conflicts:
>> contrib/subtree/git-subtree.sh
>
> The "Conflicts:" part is totally irrelevant. Please remove.
>
>> ---
>> contrib/subtree/git-subtree.sh | 25 ++++++++++++++++++++++---
>> 1 file changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index 1aff956..ddae56e 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -12,6 +12,7 @@ git subtree add --prefix=<prefix> <commit>
>> git subtree add --prefix=<prefix> <repository> <commit>
>> git subtree merge --prefix=<prefix> <commit>
>> git subtree pull --prefix=<prefix> <repository> <refspec...>
>> +git subtree pull_all
>
> Why isn't it "pull --all"?
>
>> git subtree push --prefix=<prefix> <repository> <refspec...>
>
> Where did "push_all" go?
>
>> +cmd_pull_all()
>> +{
>> + git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
>
> "grep -o" is not even in POSIX. Besides, what is this trying to
> parse? Is it expected to match lines like
>
> path.subtree=trash
>
> with this, or is it more like you only want something like this:
>
> subtree.over/there.path=foo
>
> in which case you would want to read with something like
>
> sed -n -e 's/^subtree\...*\.path=\(.*\)/\1/p'
>
> instead (modulo the usual caveat on $IFS whitespaces in path)?
>
>> + while read path; do
>> + git subtree pull -P $path master || exit $?
>> + done
>> +}
>
> I'd stop looking at this series myself at this step for now.
Thanks for your feedback. Plenty there for me already to get cracking on.
--
Paul [W] Campbell
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 06/23] contrib/subtree: Rename commands push_all/pull_all to push-all/pull-all
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (4 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed Paul Campbell
` (16 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Matt Hoffman, Paul Campbell, Peter Jaros,
Avery Pennarun, bibendi, Win Treese, Wayne Walter
From: Matt Hoffman <matt.hoffman@quantumretail.com>
Changing underscores to dashes (push_all -> push-all)
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
.gitignore
contrib/subtree/git-subtree.sh
---
contrib/subtree/git-subtree.sh | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index ddae56e..39d764b 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -12,7 +12,8 @@ git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <commit>
git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
-git subtree pull_all
+git subtree pull-all
+git subtree push-all
git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
git subtree from-submodule --prefix=<prefix>
@@ -103,18 +104,18 @@ done
command="$1"
shift
case "$command" in
- add|merge|pull|from-submodule|pull_all|push_all) default= ;;
+ add|merge|pull|from-submodule|pull-all|push-all) default= ;;
split|push) default="--default HEAD" ;;
*) die "Unknown command '$command'" ;;
esac
-if [ -z "$prefix" -a "$command" != "pull_all" -a "$command" != "push_all" ]; then
+if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" != "push-all" ]; then
die "You must provide the --prefix option."
fi
case "$command" in
- pull_all);;
- push_all);;
+ pull-all);;
+ push-all);;
add) [ -e "$prefix" ] &&
die "prefix '$prefix' already exists." ;;
*) [ -e "$prefix" ] ||
@@ -123,7 +124,7 @@ esac
dir="$(dirname "$prefix/.")"
-if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" -a "$command" != "pull_all" ]; then
+if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" -a "$command" != "pull-all" ]; then
revs=$(git rev-parse $default --revs-only "$@") || exit $?
dirs="$(git rev-parse --no-revs --no-flags "$@")" || exit $?
if [ -n "$dirs" ]; then
@@ -770,7 +771,7 @@ cmd_from-submodule()
rm -rf $tmp_repo
}
-cmd_pull_all()
+cmd_pull-all()
{
git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
while read path; do
@@ -778,7 +779,7 @@ cmd_pull_all()
done
}
-cmd_push_all()
+cmd_push-all()
{
git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
while read path; do
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (5 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 06/23] contrib/subtree: Rename commands push_all/pull_all to push-all/pull-all Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 08/23] contrib/subtree: Replace invisible carriage return with a visible \r Paul Campbell
` (15 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Matt Hoffman, Paul Campbell, Avery Pennarun,
bibendi, Wayne Walter
From: Matt Hoffman <matt.hoffman@quantumretail.com>
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 <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 39d764b..98c508b 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -712,13 +712,21 @@ cmd_merge()
cmd_pull()
{
- if [ $# -ne 1 ]; then
- die "You must provide <branch>"
+ if [ $# -gt 2 ]; then
+ die "You should provide either <refspec> or <repository> <refspec>"
fi
if [ -e "$dir" ]; then
ensure_clean
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
+ if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$prefix.branch)
+ fi
git fetch $repository $refspec || exit $?
echo "git fetch using: " $repository $refspec
revs=FETCH_HEAD
@@ -731,12 +739,20 @@ cmd_pull()
cmd_push()
{
- if [ $# -ne 1 ]; then
- die "You must provide <branch>"
+ if [ $# -gt 2 ]; then
+ die "You shold provide either <refspec> or <repository> <refspec>"
fi
if [ -e "$dir" ]; then
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
+ if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$prefix.branch)
+ fi
echo "git push using: " $repository $refspec
git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
else
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 08/23] contrib/subtree: Replace invisible carriage return with a visible \r
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (6 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 09/23] contrib/subtree: Teach push to abort if split fails Paul Campbell
` (14 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Matt Hoffman, Paul Campbell, Avery Pennarun
From: Matt Hoffman <matt.hoffman@quantumretail.com>
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 <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 98c508b..8056851 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -605,7 +605,7 @@ cmd_split()
eval "$grl" |
while read rev parents; do
revcount=$(($revcount + 1))
- say -n "$revcount/$revmax ($createcount)
"
+ say -ne "$revcount/$revmax ($createcount)\r"
debug "Processing commit: $rev"
exists=$(cache_get $rev)
if [ -n "$exists" ]; then
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 09/23] contrib/subtree: Teach push to abort if split fails
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (7 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 08/23] contrib/subtree: Replace invisible carriage return with a visible \r Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 10/23] contrib/subtree: Add command diff Paul Campbell
` (13 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Michael Hart, Paul Campbell, Matt Hoffman, Wayne Walter
From: Michael Hart <michael@adslot.com>
Added a check to ensure that split succeeds before trying to push.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8056851..ae9f87f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -754,7 +754,12 @@ cmd_push()
refspec=$(git config -f .gittrees subtree.$prefix.branch)
fi
echo "git push using: " $repository $refspec
- git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
+ rev=$(git subtree split --prefix=$prefix)
+ if [ -n "$rev" ]; then
+ git push $repository $rev:refs/heads/$refspec
+ else
+ die "Couldn't push, 'git subtree split' failed."
+ fi
else
die "'$dir' must already exist. Try 'git subtree add'."
fi
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 10/23] contrib/subtree: Add command diff
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (8 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 09/23] contrib/subtree: Teach push to abort if split fails Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 11/23] contrib/subtree: Add command list Paul Campbell
` (12 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Matt Hoffman, Paul Campbell, Peter Jaros,
Avery Pennarun, bibendi, Wayne Walter
From: Matt Hoffman <matt.hoffman@quantumretail.com>
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 <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index ae9f87f..4c3f3c0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -16,6 +16,7 @@ git subtree pull-all
git subtree push-all
git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
+git subtree diff --prefix=<prefix> [<repository> [<refspec>...]]
git subtree from-submodule --prefix=<prefix>
--
h,help show the help
@@ -105,8 +106,8 @@ command="$1"
shift
case "$command" in
add|merge|pull|from-submodule|pull-all|push-all) default= ;;
- split|push) default="--default HEAD" ;;
*) die "Unknown command '$command'" ;;
+ split|push|diff) default="--default HEAD" ;;
esac
if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" != "push-all" ]; then
@@ -737,6 +738,37 @@ cmd_pull()
fi
}
+cmd_diff()
+{
+ if [ -e "$dir" ]; then
+ if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$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
+ git remote rm $tmp_remote > /dev/null 2>&1
+ git remote add -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...
+ git fetch -q $tmp_remote
+ git diff-tree -p refs/remotes/$tmp_remote/$refspec
+ git remote rm $tmp_remote > /dev/null 2>&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 [ $# -gt 2 ]; then
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 11/23] contrib/subtree: Add command list
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (9 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 10/23] contrib/subtree: Add command diff Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 12/23] contrib/subtree: Add command prune Paul Campbell
` (11 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Matt Hoffman, Paul Campbell, Peter Jaros,
Avery Pennarun, bibendi, Win Treese
From: Matt Hoffman <matt.hoffman@quantumretail.com>
Lists subtrees from the .gittrees file.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4c3f3c0..7d08064 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -107,10 +107,10 @@ shift
case "$command" in
add|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" ]; then
die "You must provide the --prefix option."
fi
@@ -824,6 +824,21 @@ cmd_from-submodule()
rm -rf $tmp_repo
}
+subtree_list()
+{
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ repository=$(git config -f .gittrees subtree.$path.url)
+ refspec=$(git config -f .gittrees subtree.$path.branch)
+ echo " $path (merged from $repository branch $refspec) "
+ done
+}
+
+cmd_list()
+{
+ subtree_list
+}
+
cmd_pull-all()
{
git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 12/23] contrib/subtree: Add command prune
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (10 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 11/23] contrib/subtree: Add command list Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 13/23] contrib/subtree: Add prune command to OPTS_SPEC Paul Campbell
` (10 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Nate Jones, Paul Campbell, Matt Hoffman,
Avery Pennarun, bibendi, Win Treese
From: Nate Jones <nate@endot.org>
Removes entries in .gittrees where the subtree files are
no longer present on disk.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7d08064..0c41383 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -105,12 +105,12 @@ done
command="$1"
shift
case "$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" ]; then
die "You must provide the --prefix option."
fi
@@ -839,6 +839,17 @@ cmd_list()
subtree_list
}
+cmd_prune()
+{
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ if [ ! -e "$path" ]; then
+ echo "pruning $path"
+ git config -f .gittrees --remove-section subtree.$path
+ fi
+ done
+}
+
cmd_pull-all()
{
git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 13/23] contrib/subtree: Add prune command to OPTS_SPEC
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (11 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 12/23] contrib/subtree: Add command prune Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 14/23] contrib/subtree: Remove trailing slash from prefix parameter Paul Campbell
` (9 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Herman van Rink, Paul Campbell, Peter Jaros,
Matt Hoffman, Avery Pennarun
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 0c41383..d67fe5a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -18,6 +18,7 @@ git subtree push --prefix=<prefix> <repository> <refspec...>
git subtree split --prefix=<prefix> <commit...>
git subtree diff --prefix=<prefix> [<repository> [<refspec>...]]
git subtree from-submodule --prefix=<prefix>
+git subtree prune
--
h,help show the help
q quiet
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 14/23] contrib/subtree: Remove trailing slash from prefix parameter
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (12 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 13/23] contrib/subtree: Add prune command to OPTS_SPEC Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 15/23] contrib/subtree: Teach from-submodule to add new subtree to .gittrees Paul Campbell
` (8 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Herman van Rink, Paul Campbell, Avery Pennarun
From: Herman van Rink <rink@initfour.nl>
Conflicts:
git-subtree.sh
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index d67fe5a..ae7d1fe 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -103,6 +103,9 @@ while [ $# -gt 0 ]; do
esac
done
+# Remove trailing slash
+prefix="${prefix%/}";
+
command="$1"
shift
case "$command" in
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 15/23] contrib/subtree: Teach from-submodule to add new subtree to .gittrees
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (13 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 14/23] contrib/subtree: Remove trailing slash from prefix parameter Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 16/23] contrib/subtree: Document pull-all and push-all Paul Campbell
` (7 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Herman van Rink, Paul Campbell, Peter Jaros
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index ae7d1fe..84c90c7 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -806,6 +806,7 @@ cmd_from-submodule()
ensure_clean
local submodule_sha=$(git submodule status $prefix | cut -d ' ' -f 2)
+ local submodule_orig_repo=$(git config --file .gitmodules submodule.$prefix.url)
# Remove references to submodule.
git config --remove-section submodule.$prefix
@@ -824,6 +825,10 @@ cmd_from-submodule()
# subtree add from submodule repo.
cmd_add_repository $tmp_repo HEAD
+ # Update .gittrees with the original repo url
+ git config --file .gittrees --unset subtree.$prefix.url
+ git config --file .gittrees subtree.$prefix.url $submodule_orig_repo
+
# Remove submodule repo.
rm -rf $tmp_repo
}
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 16/23] contrib/subtree: Document pull-all and push-all
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (14 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 15/23] contrib/subtree: Teach from-submodule to add new subtree to .gittrees Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 17/23] contrib/subtree: Document from-submodule and prune commands Paul Campbell
` (6 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Herman van Rink, Paul Campbell, Avery Pennarun,
Michael Schubert, Wayne Walter
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.txt | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index e0957ee..c8fc103 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -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
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 17/23] contrib/subtree: Document from-submodule and prune commands
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (15 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 16/23] contrib/subtree: Document pull-all and push-all Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 18/23] contrib/subtree: Add missing commands to SYNOPSIS Paul Campbell
` (5 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Herman van Rink, Paul Campbell, Avery Pennarun
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.txt | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index c8fc103..48ba158 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -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
-------
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 18/23] contrib/subtree: Add missing commands to SYNOPSIS
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (16 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 17/23] contrib/subtree: Document from-submodule and prune commands Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 19/23] contrib/subtree: Document list command Paul Campbell
` (4 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Herman van Rink, Paul Campbell, Avery Pennarun, John Yani
From: Herman van Rink <rink@initfour.nl>
Add pull-all, push-all, from-submodule, prune and diff commands
to SYNOPSIS.
Add alternate parameter option for add command.
Use long-form option for specifying prefix.
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
contrib/subtree/git-subtree.txt
---
contrib/subtree/git-subtree.txt | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 48ba158..b485ab5 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -9,13 +9,16 @@ git-subtree - Merge subtrees together and split repository into subtrees
SYNOPSIS
--------
[verse]
-'git subtree' add -P <prefix> <refspec>
-'git subtree' add -P <prefix> <repository> <refspec>
-'git subtree' pull -P <prefix> <repository> <refspec...>
-'git subtree' push -P <prefix> <repository> <refspec...>
-'git subtree' merge -P <prefix> <commit>
-'git subtree' split -P <prefix> [OPTIONS] [<commit>]
-
+'git subtree' add --prefix=<prefix> <repository> <refspec>
+'git subtree' merge --prefix=<prefix> <commit>
+'git subtree' pull --prefix=<prefix> [<repository> [<refspec>...]]
+'git subtree' pull-all
+'git subtree' push-all
+'git subtree' push --prefix=<prefix> [<repository> [<refspec>...]]
+'git subtree' split --prefix=<prefix> <commit...>
+'git subtree' from-submodule --prefix=<prefix>
+'git subtree' prune
+'git subtree' diff --prefix=<prefix> [<repository> [<refspec>...]]
DESCRIPTION
-----------
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 19/23] contrib/subtree: Document list command
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (17 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 18/23] contrib/subtree: Add missing commands to SYNOPSIS Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 20/23] contrib/subtree: Teach push to use --force option Paul Campbell
` (3 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Herman van Rink, Paul Campbell, Peter Jaros,
Matt Hoffman, Avery Pennarun, Wayne Walter
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
git-subtree.sh
---
contrib/subtree/git-subtree.sh | 1 +
contrib/subtree/git-subtree.txt | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 84c90c7..4605203 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -15,6 +15,7 @@ git subtree pull --prefix=<prefix> <repository> <refspec...>
git subtree pull-all
git subtree push-all
git subtree push --prefix=<prefix> <repository> <refspec...>
+git subtree list
git subtree split --prefix=<prefix> <commit...>
git subtree diff --prefix=<prefix> [<repository> [<refspec>...]]
git subtree from-submodule --prefix=<prefix>
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index b485ab5..385bde8 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -15,6 +15,7 @@ SYNOPSIS
'git subtree' pull-all
'git subtree' push-all
'git subtree' push --prefix=<prefix> [<repository> [<refspec>...]]
+'git subtree' list
'git subtree' split --prefix=<prefix> <commit...>
'git subtree' from-submodule --prefix=<prefix>
'git subtree' prune
@@ -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
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 20/23] contrib/subtree: Teach push to use --force option
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (18 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 19/23] contrib/subtree: Document list command Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 21/23] contrib/subtree: Convert spaces to tabs and remove some trailing whitespace Paul Campbell
` (2 subsequent siblings)
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, James Roper, Paul Campbell, Matt Hoffman,
Michael Hart, Avery Pennarun, Jakub Suder, John Yani,
Wayne Walter
From: James Roper <jroper@vz.net>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
contrib/subtree/git-subtree.sh
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 9 ++++++++-
contrib/subtree/git-subtree.txt | 5 +++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4605203..3582a55 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -32,6 +32,8 @@ 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
rejoin merge the new branch back into HEAD
+ options for 'push'
+f,force use force push
options for 'add', 'merge', 'pull' and 'push'
squash merge subtree changes as a single commit
"
@@ -90,6 +92,7 @@ while [ $# -gt 0 ]; do
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-m) message="$1"; shift ;;
+ -f|--force) force=1 ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
--no-onto) onto= ;;
@@ -790,10 +793,14 @@ cmd_push()
repository=$(git config -f .gittrees subtree.$prefix.url)
refspec=$(git config -f .gittrees subtree.$prefix.branch)
fi
+ push_opts=
+ if [ "$force" == "1" ]; then
+ push_opts="$push_opts --force"
+ fi
echo "git push using: " $repository $refspec
rev=$(git subtree split --prefix=$prefix)
if [ -n "$rev" ]; then
- git push $repository $rev:refs/heads/$refspec
+ git push $push_opts $repository $rev:refs/heads/$refspec
else
die "Couldn't push, 'git subtree split' failed."
fi
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 385bde8..9e9eb9e 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -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
----------------------
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 21/23] contrib/subtree: Convert spaces to tabs and remove some trailing whitespace
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (19 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 20/23] contrib/subtree: Teach push to use --force option Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 22/23] contrib/subtree: Parameters repository/branch for push/pull are optional Paul Campbell
2013-03-10 23:41 ` [PATCH v2 23/23] contrib/subtree: Fix order of case switches so default case is last Paul Campbell
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Herman van Rink, Paul Campbell, Peter Jaros,
James Roper, Michael Hart, Matt Hoffman, Avery Pennarun,
Jakub Suder, Nate Jones, bibendi, Win Treese, Wayne Walter
From: Herman van Rink <rink@initfour.nl>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
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(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 3582a55..263ea9f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -92,7 +92,7 @@ while [ $# -gt 0 ]; do
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-m) message="$1"; shift ;;
- -f|--force) force=1 ;;
+ -f|--force) force=1 ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
--no-onto) onto= ;;
@@ -123,8 +123,10 @@ if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" != "push-all" -a "$c
fi
case "$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_HEAD
set -- $revs
cmd_add_commit "$@"
-
- # now add it to our list of repos
- git config -f .gittrees --unset subtree.$dir.url
- git config -f .gittrees --add subtree.$dir.url $repository
- git config -f .gittrees --unset subtree.$dir.path
- git config -f .gittrees --add subtree.$dir.path $dir
- git config -f .gittrees --unset subtree.$dir.branch
- git config -f .gittrees --add subtree.$dir.branch $refspec
+
+ # now add it to our list of repos
+ git config -f .gittrees --unset subtree.$dir.url
+ git config -f .gittrees --add subtree.$dir.url $repository
+ git config -f .gittrees --unset subtree.$dir.path
+ git config -f .gittrees --add subtree.$dir.path $dir
+ git config -f .gittrees --unset subtree.$dir.branch
+ git config -f .gittrees --add subtree.$dir.branch $refspec
}
cmd_add_commit()
@@ -721,89 +723,91 @@ cmd_merge()
cmd_pull()
{
- if [ $# -gt 2 ]; then
- die "You should provide either <refspec> or <repository> <refspec>"
+ if [ $# -gt 2 ]; then
+ die "You should provide either <refspec> or <repository> <refspec>"
fi
if [ -e "$dir" ]; then
- ensure_clean
- if [ $# -eq 1 ]; then
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
- elif [ $# -eq 2 ]; then
- repository=$1
- refspec=$2
- else
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$(git config -f .gittrees subtree.$prefix.branch)
- fi
- git fetch $repository $refspec || exit $?
- echo "git fetch using: " $repository $refspec
- revs=FETCH_HEAD
- set -- $revs
- cmd_merge "$@"
+ ensure_clean
+ if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$prefix.branch)
+ fi
+ git fetch $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 [ $# -eq 1 ]; then
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
- elif [ $# -eq 2 ]; then
- repository=$1
- refspec=$2
- else
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$(git config -f .gittrees subtree.$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
- git remote rm $tmp_remote > /dev/null 2>&1
- git remote add -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...
- git fetch -q $tmp_remote
- git diff-tree -p refs/remotes/$tmp_remote/$refspec
- git remote rm $tmp_remote > /dev/null 2>&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 [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$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
+ git remote rm $tmp_remote > /dev/null 2>&1
+ git remote add -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...
+ git fetch -q $tmp_remote
+ git diff-tree -p refs/remotes/$tmp_remote/$refspec
+ git remote rm $tmp_remote > /dev/null 2>&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 [ $# -gt 2 ]; then
- die "You shold provide either <refspec> or <repository> <refspec>"
+ die "You shold provide either <refspec> or <repository> <refspec>"
fi
if [ -e "$dir" ]; then
- if [ $# -eq 1 ]; then
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
- elif [ $# -eq 2 ]; then
- repository=$1
- refspec=$2
- else
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$(git config -f .gittrees subtree.$prefix.branch)
- fi
- push_opts=
- if [ "$force" == "1" ]; then
- push_opts="$push_opts --force"
- fi
- echo "git push using: " $repository $refspec
- rev=$(git subtree split --prefix=$prefix)
- if [ -n "$rev" ]; then
- git push $push_opts $repository $rev:refs/heads/$refspec
- else
- die "Couldn't push, 'git subtree split' failed."
- fi
+ if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+ elif [ $# -eq 2 ]; then
+ repository=$1
+ refspec=$2
+ else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$(git config -f .gittrees subtree.$prefix.branch)
+ fi
+
+ push_opts=
+ if [ "$force" == "1" ]; then
+ push_opts="$push_opts --force"
+ fi
+
+ echo "git push using: " $repository $refspec
+ rev=$(git subtree split --prefix=$prefix)
+ if [ -n "$rev" ]; then
+ git push $push_opts $repository $rev:refs/heads/$refspec
+ else
+ die "Couldn't push, 'git subtree split' failed."
+ fi
else
die "'$dir' must already exist. Try 'git subtree add'."
fi
@@ -831,6 +835,7 @@ cmd_from-submodule()
git commit -m "Remove '$prefix/' submodule"
# subtree add from submodule repo.
+ # TODO: Could be determin HEAD to be a specific branch
cmd_add_repository $tmp_repo HEAD
# Update .gittrees with the original repo url
@@ -841,46 +846,46 @@ cmd_from-submodule()
rm -rf $tmp_repo
}
-subtree_list()
+subtree_list()
{
- git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
- while read path; do
- repository=$(git config -f .gittrees subtree.$path.url)
- refspec=$(git config -f .gittrees subtree.$path.branch)
- echo " $path (merged from $repository branch $refspec) "
- done
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ repository=$(git config -f .gittrees subtree.$path.url)
+ refspec=$(git config -f .gittrees subtree.$path.branch)
+ echo " $path (merged from $repository branch $refspec) "
+ done
}
cmd_list()
{
- subtree_list
+ subtree_list
}
cmd_prune()
{
- git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
- while read path; do
- if [ ! -e "$path" ]; then
- echo "pruning $path"
- git config -f .gittrees --remove-section subtree.$path
- fi
- done
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ if [ ! -e "$path" ]; then
+ echo "pruning $path"
+ git config -f .gittrees --remove-section subtree.$path
+ fi
+ done
}
cmd_pull-all()
{
- git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
- while read path; do
- git subtree pull -P $path master || exit $?
- done
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ git subtree pull -P $path $(git config -f .gittrees subtree.$path.url) $(git config -f .gittrees subtree.$path.branch) || exit $?
+ done
}
cmd_push-all()
{
- git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
- while read path; do
- git subtree push -P $path master || exit $?
- done
+ git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+ while read path; do
+ git subtree push -P $path $(git config -f .gittrees subtree.$path.url) $(git config -f .gittrees subtree.$path.branch) || exit $?
+ done
}
"cmd_$command" "$@"
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 22/23] contrib/subtree: Parameters repository/branch for push/pull are optional
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (20 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 21/23] contrib/subtree: Convert spaces to tabs and remove some trailing whitespace Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 23/23] contrib/subtree: Fix order of case switches so default case is last Paul Campbell
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git
Cc: David Greene, Paul Campbell, Matt Hoffman, Avery Pennarun,
Herman van Rink, Wayne Walter
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 263ea9f..aaee6ae 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -11,10 +11,10 @@ OPTS_SPEC="\
git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <commit>
git subtree merge --prefix=<prefix> <commit>
-git subtree pull --prefix=<prefix> <repository> <refspec...>
+git subtree pull --prefix=<prefix> [<repository> [<refspec>...]]
git subtree pull-all
git subtree push-all
-git subtree push --prefix=<prefix> <repository> <refspec...>
+git subtree push --prefix=<prefix> [<repository> [<refspec>...]]
git subtree list
git subtree split --prefix=<prefix> <commit...>
git subtree diff --prefix=<prefix> [<repository> [<refspec>...]]
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v2 23/23] contrib/subtree: Fix order of case switches so default case is last
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
` (21 preceding siblings ...)
2013-03-10 23:41 ` [PATCH v2 22/23] contrib/subtree: Parameters repository/branch for push/pull are optional Paul Campbell
@ 2013-03-10 23:41 ` Paul Campbell
22 siblings, 0 replies; 33+ messages in thread
From: Paul Campbell @ 2013-03-10 23:41 UTC (permalink / raw)
To: git; +Cc: David Greene, Paul Campbell, Matt Hoffman, Avery Pennarun, Nate Jones
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
contrib/subtree/git-subtree.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index aaee6ae..fb6f044 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -113,9 +113,9 @@ prefix="${prefix%/}";
command="$1"
shift
case "$command" in
- add|merge|pull|from-submodule|pull-all|push-all|prune) default= ;;
+ add|merge|pull|pull-all|push-all|from-submodule|prune) default= ;;
+ split|push|diff|list) default="--default HEAD" ;;
*) 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" -a "$command" != "prune" ]; then
--
1.8.2.rc1
^ permalink raw reply related [flat|nested] 33+ messages in thread