Re: git subtree push-all and pull-all

2013-07-25 Thread Paul Campbell
I agree with the idea of maintaining git-subtree outside of contrib.
However, you would need the commitment of apenwarr, or whoever hosts
the master repo, to merge in any pull requests or we are no further
forward. (apenwarr appears not to have been active on github since
early May).

On Thu, Jul 25, 2013 at 11:00 AM, Herman van Rink r...@initfour.nl wrote:
 On 22-07-13 21:35, Paul Campbell wrote:

 Hi,

 Sorry for the delay. Not been monitoring the list lately.

 I'm afraid work stopped for two reasons. Lack of interest from the
 list was the main one. I understand subtree isn't used much and
 subsequently there wasn't much interest in reviewing the patches I was
 putting out. As a result I lost interest.


 It seems to be hard to get anything done on such a busy list. :( Especially
 when the maintainers lack time/attention for such a contrib.

 I think including it in the contrib folder has not done us any good.

 Maybe we should just focus on maintaining a separate repo, which could be
 based of https://github.com/apenwarr/git-subtree (which has already 92
 forks, including one of mine). And obviously integrate all the recent work
 from Paul.


 --

 Met vriendelijke groet / Regards,

 Herman van Rink
 Initfour websolutions




-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree push-all and pull-all

2013-07-22 Thread Paul Campbell
Hi,

Sorry for the delay. Not been monitoring the list lately.

I'm afraid work stopped for two reasons. Lack of interest from the
list was the main one. I understand subtree isn't used much and
subsequently there wasn't much interest in reviewing the patches I was
putting out. As a result I lost interest.



On Tue, Jul 9, 2013 at 10:21 AM, Herman van Rink r...@initfour.nl wrote:
 On 08-07-13 17:20, Gareth Collins wrote:

 Hello Fredrik,

 Thanks for the suggestion! Adding in Paul Campbell and Herman Van Rink
 who worked on this before.


 Paul Campbell has been working hard on multiple branches in
 https://github.com/kemitix/git
 But work appears to have stopped. :(

 There is also a recent blogpost:
 http://ruleant.blogspot.nl/2013/06/git-subtree-module-with-gittrees-config.html

 Thanks for your interest, I'd love to see this get integrated



 thanks again,
 Gareth

 On Sun, Jul 7, 2013 at 8:54 AM, Fredrik Gustafsson iv...@iveqy.com
 wrote:

 On Wed, Jul 03, 2013 at 03:56:36PM -0400, Gareth Collins wrote:

 Hello,

 I see over the last year (on the web and in this mailing list) there
 was some activity to extend subtree with a .gittrees file and
 push-all/pull-all commands.

 Perhaps I missed it, but looking through the latest git code on the
 github mirror I can't find any reference to the .gittrees file or
 these commands.

 Does anyone know the status of this feature? Was it decided that this
 was a bad idea and the feature has been rejected? Or is this a feature
 still cooking...which will likely make it into git mainline at some
 point?

 I ask because I would like to use something like this to be able to
 keep a combined repository and separate project repositories in sync.
 Of course, if it was decided that this feature is fundamentally a bad
 idea then I will do something different.

 Any pointers would be a big help.

 thanks in advance,
 Gareth Collins

 Still no answer to this? I suggest that you CC the persons discussing
 this the last time.

 --
 Med vänliga hälsningar
 Fredrik Gustafsson

 tel: 0733-608274
 e-post: iv...@iveqy.com



 --

 Met vriendelijke groet / Regards,

 Herman van Rink
 Initfour websolutions




-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] contrib/subtree: stop explicitly using a bash shell

2013-03-24 Thread Paul Campbell
Don't explicitly use the Bash shell but allow the system to provide a
hopefully POSIX compatible shell at /bin/sh.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---

Only the system's I was able to test this on (Debian squeeze) /bin/sh is
the dash shell.

 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 8a23f58..5701376 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # git-subtree.sh: split/join git repositories in subdirectories of this one
 #
-- 
1.8.2

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] contrib/subtree: remove use of -a/-o in [ commands

2013-03-24 Thread Paul Campbell
Use of -a and -o in the [ command can have confusing semantics.

Use a separate test invocation for each single test, combining them with
 and ||, and use ordinary parentheses for grouping.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 5701376..884cbfb 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -119,7 +119,7 @@ esac
 
 dir=$(dirname $prefix/.)
 
-if [ $command != pull -a $command != add -a $command != push ]; 
then
+if ( test $command != pull )  ( test $command != add )  ( test 
$command != push ); then
revs=$(git rev-parse $default --revs-only $@) || exit $?
dirs=$(git rev-parse --no-revs --no-flags $@) || exit $?
if [ -n $dirs ]; then
@@ -181,9 +181,9 @@ cache_set()
 {
oldrev=$1
newrev=$2
-   if [ $oldrev != latest_old \
--a $oldrev != latest_new \
--a -e $cachedir/$oldrev ]; then
+   if ( test $oldrev != latest_old ) \
+ ( test $oldrev != latest_new ) \
+ ( test -e $cachedir/$oldrev ); then
die cache for $oldrev already exists!
fi
echo $newrev $cachedir/$oldrev
@@ -273,12 +273,12 @@ find_existing_splits()
git-subtree-split:) sub=$b ;;
END)
debug   Main is: '$main'
-   if [ -z $main -a -n $sub ]; then
+   if ( test -z $main )  ( test -n $sub ); 
then
# squash commits refer to a subtree
debug   Squash: $sq from $sub
cache_set $sq $sub
fi
-   if [ -n $main -a -n $sub ]; then
+   if ( test -n $main )  (test -n $sub ); 
then
debug   Prior: $main - $sub
cache_set $main $sub
cache_set $sub $sub
@@ -541,7 +541,7 @@ cmd_add_commit()
tree=$(git write-tree) || exit $?

headrev=$(git rev-parse HEAD) || exit $?
-   if [ -n $headrev -a $headrev != $rev ]; then
+   if ( test -n $headrev )  ( test $headrev != $rev ); then
headp=-p $headrev
else
headp=
-- 
1.8.2

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 03/23] contrib/subtree: Teach add to store repository branch in .gittrees

2013-03-24 Thread Paul Campbell
On Mon, Mar 11, 2013 at 3:24 AM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 From: Matt Hoffman matt.hoff...@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 pcampb...@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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] contrib/subtree: Teach add to store repository branch in .gittrees

2013-03-24 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] contrib/subtree: Add command from-submodule

2013-03-24 Thread Paul Campbell
Converts a git-submodule into a git-subtree.

Based-on-patch-by: Peter Jaros pja...@pivotallabs.com
Signed-off-by: Paul Campbell pcampb...@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,helpshow 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.X)
+   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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults

2013-03-24 Thread Paul Campbell
On Mon, Mar 11, 2013 at 3:35 AM, Junio C Hamano gits...@pobox.com wrote:
 From: bibendi bibe...@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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4] contrib/subtree: general updates

2013-03-23 Thread Paul Campbell
On Thu, Mar 14, 2013 at 3:30 AM, Junio C Hamano gits...@pobox.com wrote:
 Miles Bader mi...@gnu.org writes:

 Paul Campbell pcampb...@kemitix.net writes:
 James and Michael's patches add if clauses that use the
 bashism 'if []' rather than 'if test'.

 Bashism...?  I dunno how portable is, but [ is an old unix alias
 for test ... it certainly predates bash...

 Correct. [[ ... ]] is new and spelling out test indeed is more
 traditionalist than [ ... ], but for contrib/subtree/ that does not
 work with anything but bash, I do not think such a rewrite has much
 merit in the first place.  Being consistently bash script (as
 opposed to being old-style) is more appropriate for it.



Does no-one have any other comments about these patches?

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/12] pretty: support truncating in %, % and %

2013-03-16 Thread Paul Campbell
On Sat, Mar 16, 2013 at 2:24 AM, Nguyễn Thái Ngọc Duy pclo...@gmail.com wrote:
 %(N,trunc) truncates the righ part after N columns and replace the
 last two letters with ... ltrunc does the same on the left. mtrunc
 cuts the middle out.

 Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
 ---

s/righ/right/

  Documentation/pretty-formats.txt |  6 +++--
  pretty.c | 51 
 +---
  utf8.c   | 46 
  utf8.h   |  2 ++
  4 files changed, 100 insertions(+), 5 deletions(-)

 diff --git a/Documentation/pretty-formats.txt 
 b/Documentation/pretty-formats.txt
 index 87ca2c4..17f82f4 100644
 --- a/Documentation/pretty-formats.txt
 +++ b/Documentation/pretty-formats.txt
 @@ -162,8 +162,10 @@ The placeholders are:
  - '%x00': print a byte from a hex code
  - '%w([w[,i1[,i2]]])': switch line wrapping, like the -w option of
linkgit:git-shortlog[1].
 -- '%(N)': make the next placeholder take at least N columns,
 -  padding spaces on the right if necessary
 +- '%(N[,trunc|ltrunc|mtrunc])': make the next placeholder take at
 +  least N columns, padding spaces on the right if necessary.
 +  Optionally truncate at the beginning (ltrunc), the middle (mtrunc)
 +  or the end (trunc) if the output is longer than N columns.
  - '%|(N)': make the next placeholder take at least until Nth
columns, padding spaces on the right if necessary
  - '%(N)', '%|(N)': similar to '%(N)', '%|(N)'
 diff --git a/pretty.c b/pretty.c
 index 233d69c..29384b5 100644
 --- a/pretty.c
 +++ b/pretty.c
 @@ -767,6 +767,13 @@ enum flush_type {
 flush_both
  };

 +enum trunc_type {
 +   trunc_none,
 +   trunc_left,
 +   trunc_middle,
 +   trunc_right
 +};
 +
  struct format_commit_context {
 const struct commit *commit;
 const struct pretty_print_context *pretty_ctx;
 @@ -774,6 +781,7 @@ struct format_commit_context {
 unsigned commit_message_parsed:1;
 unsigned commit_signature_parsed:1;
 enum flush_type flush_type;
 +   enum trunc_type truncate;
 struct {
 char *gpg_output;
 char good_bad;
 @@ -1044,7 +1052,7 @@ static size_t parse_padding_placeholder(struct strbuf 
 *sb,

 if (*ch == '(') {
 const char *start = ch + 1;
 -   const char *end = strchr(start, ')');
 +   const char *end = start + strcspn(start, ,));
 char *next;
 int width;
 if (!end || end == start)
 @@ -1054,6 +1062,23 @@ static size_t parse_padding_placeholder(struct strbuf 
 *sb,
 return 0;
 c-padding = to_column ? -width : width;
 c-flush_type = flush_type;
 +
 +   if (*end == ',') {
 +   start = end + 1;
 +   end = strchr(start, ')');
 +   if (!end || end == start)
 +   return 0;
 +   if (!prefixcmp(start, trunc)))
 +   c-truncate = trunc_right;
 +   else if (!prefixcmp(start, ltrunc)))
 +   c-truncate = trunc_left;
 +   else if (!prefixcmp(start, mtrunc)))
 +   c-truncate = trunc_middle;
 +   else
 +   return 0;
 +   } else
 +   c-truncate = trunc_none;
 +
 return end - placeholder + 1;
 }
 return 0;
 @@ -1335,9 +1360,29 @@ static size_t format_and_pad_commit(struct strbuf *sb, 
 /* in UTF-8 */
 total_consumed++;
 }
 len = utf8_strnwidth(local_sb.buf, -1, 1);
 -   if (len  padding)
 +   if (len  padding) {
 +   switch (c-truncate) {
 +   case trunc_left:
 +   strbuf_utf8_replace(local_sb,
 +   0, len - (padding - 2),
 +   ..);
 +   break;
 +   case trunc_middle:
 +   strbuf_utf8_replace(local_sb,
 +   padding / 2 - 1,
 +   len - (padding - 2),
 +   ..);
 +   break;
 +   case trunc_right:
 +   strbuf_utf8_replace(local_sb,
 +   padding - 2, len - (padding - 2),
 +   ..);
 +   break;
 +   case trunc_none:
 +   break;
 +   }
 strbuf_addstr(sb, local_sb.buf);
 -   else {
 +   } else {
 int sb_len = sb-len, offset = 0;
 if (c-flush_type == flush_left)
  

Re: building git ; need suggestion

2013-03-15 Thread Paul Campbell
On Fri, Mar 15, 2013 at 12:52 PM, Joydeep Bakshi
joydeep.bak...@infoservices.in wrote:

 On 15-Mar-2013, at 6:14 PM, Fredrik Gustafsson iv...@iveqy.com wrote:

 On Fri, Mar 15, 2013 at 05:54:05PM +0530, Joydeep Bakshi wrote:
 [1] the server will have different git repo with branches
 [2] there will be a web-based GUI which must be flexible to show just a 
 specific branch of a repo based on user authentication
 [3] the web-based GUI should also have the flexibility to show a single 
 repo based on the authentication
 [4] the web-based GUI should have an admin account to supervise and 
 configure all repos along with their branches
 [3] there must be a control mechanism in the repo/web based GUI which have 
 ACL on branches i.e.
 some specific users should see some specific/ or just a branch and able to 
 commit there only.

 based on the above scenario could anyone suggest the best available 
 solution ?
 There are many like gitolike/github etc…. but don't know whig one has much 
 finer granular
 control/ACL/web-based GUI…

 gitolite have a more fine ACL. Check it out. However it doesn't really
 meet your needs with web-interface (and I'm not even sure about the ACL
 thing is fine enough for you). You can read more about ACL in the git
 book: http://git-scm.com/book/ch7-4.html

 The webgui that's most populair is cgit and git-web. They don't do ACL
 afaik.

 Why would you need ACL? Why not don't share the branches that are going
 to be secret? Or are you looking for some branches to be read only?

 Actually the branches have to be dedicated to a group of users.
  developer branch --- developers
 bug fixed branch ---  bug fixer

 and specific group don't need to RW permission on other branch.
 Obviously the admin must have the full permission on all these branches
 and merge as per requirement.

 The web-interface is required for checking the history by the users themselves
 and for code review. I don't know any web interface which can show repo/branch
 based on authentication. I have tried gitweb but it can handle a single repo 
 or multiple
 repo with single authentication. NO ACL

I think you would need to have a separate repo for each group. Then
only push the appropriate branches to each repo.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] contrib/subtree: general updates

2013-03-13 Thread Paul Campbell
Less ambitious patch series this time.

James and Michael's patches add if clauses that use the
bashism 'if []' rather than 'if test'. I've left them as
they are to match the other if clauses within the
git-subtree.sh file. I remember reading a comment on the
list about matching the local style being more important
than the overall project's style. I'm happy to change them
otherwise.

James Roper (1):
  contrib/subtree: Teach push to use --force option

Matt Hoffman (1):
  contrib/subtree: Replace invisible carriage return with a visible \r

Michael Hart (1):
  contrib/subtree: Teach push to abort if split fails

Paul Cartwright (1):
  contrib/subtree: Fix typo (s/incldued/included/)

 contrib/subtree/git-subtree.sh  | 16 ++--
 contrib/subtree/git-subtree.txt |  7 ++-
 2 files changed, 20 insertions(+), 3 deletions(-)

-- 
1.8.2

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] contrib/subtree: Teach push to abort if split fails

2013-03-13 Thread Paul Campbell
From: Michael Hart mich...@adslot.com

If the subtree split fails it doesn't return the SHA that should be
pushed to the other repository.

Added a check to ensure that split succeeds before trying to push
and display an error message.

Signed-off-by: Paul Campbell pcampb...@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 8a23f58..c68cc6f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -715,7 +715,12 @@ cmd_push()
repository=$1
refspec=$2
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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] contrib/subtree: Teach push to use --force option

2013-03-13 Thread Paul Campbell
From: James Roper jro...@vz.net

Allow the --force option to be passed to the child push command.

Signed-off-by: Paul Campbell pcampb...@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 c68cc6f..2d9b071 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -26,6 +26,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
 rejoinmerge the new branch back into HEAD
+ options for 'push'
+f,force   use force push
  options for 'add', 'merge', 'pull' and 'push'
 squashmerge subtree changes as a single commit
 
@@ -84,6 +86,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= ;;
@@ -712,12 +715,16 @@ cmd_push()
die You must provide repository refspec
fi
if [ -e $dir ]; then
+   push_opts=
+   if [ $force == 1 ]; then
+   push_opts=$push_opts --force
+   fi
repository=$1
refspec=$2
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 7ba853e..97dd3c9 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -255,6 +255,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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] contrib/subtree: Fix typo (s/incldued/included/)

2013-03-13 Thread Paul Campbell
From: Paul Cartwright paul.cartwri...@ziilabs.com

Signed-off-by: Paul Campbell pcampb...@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 97dd3c9..e1bfa61 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -275,7 +275,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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] contrib/subtree: Replace invisible carriage return with a visible \r

2013-03-13 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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 2d9b071..5314bd0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -595,7 +595,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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] contrib/subtree: Replace invisible carriage return with a visible \r

2013-03-13 Thread Paul Campbell
On Wed, Mar 13, 2013 at 10:32 PM, Paul Campbell pcampb...@kemitix.net wrote:
 From: Matt Hoffman matt.hoff...@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 pcampb...@kemitix.net

 Conflicts:
 git-subtree.sh

Oops. Meant to replace this Conflict line.

 ---
  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 2d9b071..5314bd0 100755
 --- a/contrib/subtree/git-subtree.sh
 +++ b/contrib/subtree/git-subtree.sh
 @@ -595,7 +595,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




-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] contrib/subtree: Replace invisible carriage return with a visible \r

2013-03-13 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@kemitix.net
---

Rerolled with the Conflicts lines removed.

 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 2d9b071..5314bd0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -595,7 +595,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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Questions/investigations on git-subtree and tags

2013-03-12 Thread Paul Campbell
On Tue, Mar 12, 2013 at 10:02 AM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:
 Paul, I'm not quite sure where I should go from here...

 should I send you a patch so you make it a V3 of your patch ? should I
 send a patch superseeding yours ?

 I have also found a similar problem in git-subtree pull, which needs
 the same fix.

 in the mean time, attached is the current version of my changes

 Cordialement

 Jérémy Rosen

 fight key loggers : write some perl using vim


Thanks Jérémy.

Nothing in your patches are dependant on anything I'm working on. I'll
gladly take them for my own tree but feel free to submit them (inline,
rather than as attachments) to the list and cc: David Greene
gree...@obbligato.org the subtree area maintainer.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/19] Document pull-all and push-all

2013-03-12 Thread Paul Campbell
On Tue, Mar 12, 2013 at 3:12 PM, Holger Hellmuth (IKS)
hellm...@ira.uka.de wrote:
 Am 09.03.2013 20:28, schrieb Paul Campbell:

  From 7dcd40ab8687a588b7b0c6ff914a7cfb601b6774 Mon Sep 17 00:00:00 2001
 From: Herman van Rink r...@initfour.nl
 Date: Tue, 27 Mar 2012 13:59:16 +0200
 Subject: [PATCH 14/19] Document pull-all and push-all

 ---
   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.

  -
 pull-push


Thanks.

 +
   split::
 Extract a new, synthetic project history from the
 history of the prefix subtree.  The new history





-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all

2013-03-11 Thread Paul Campbell
On Mon, Mar 11, 2013 at 5:03 AM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 From: bibendi bibe...@bk.ru

 For each subtree listed in .gittrees perform a push or a pull.

 Signed-off-by: Paul Campbell pcampb...@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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/23] contrib/subtree: Collected updates

2013-03-10 Thread Paul Campbell
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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/23] contrib/subtree: Fix typo (s/incldued/included/)

2013-03-10 Thread Paul Campbell
From: Paul Cartwright paul.cartwri...@ziilabs.com

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/23] contrib/subtree: Add command from-submodule

2013-03-10 Thread Paul Campbell
From: Peter Jaros pja...@pivotallabs.com

Converts a git-submodule into a git-subtree.

Signed-off-by: Paul Campbell pcampb...@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,helpshow 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.X)
+   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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/23] contrib/subtree: Teach add to store repository branch in .gittrees

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults

2013-03-10 Thread Paul Campbell
From: bibendi bibe...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all

2013-03-10 Thread Paul Campbell
From: bibendi bibe...@bk.ru

For each subtree listed in .gittrees perform a push or a pull.

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 06/23] contrib/subtree: Rename commands push_all/pull_all to push-all/pull-all

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@quantumretail.com

Changing underscores to dashes (push_all - push-all)

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 08/23] contrib/subtree: Replace invisible carriage return with a visible \r

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/23] contrib/subtree: Teach push to abort if split fails

2013-03-10 Thread Paul Campbell
From: Michael Hart mich...@adslot.com

Added a check to ensure that split succeeds before trying to push.

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/23] contrib/subtree: Add command diff

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@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 pcampb...@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,helpshow 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 21
+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 21
+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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 11/23] contrib/subtree: Add command list

2013-03-10 Thread Paul Campbell
From: Matt Hoffman matt.hoff...@quantumretail.com

Lists subtrees from the .gittrees file.

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/23] contrib/subtree: Add command prune

2013-03-10 Thread Paul Campbell
From: Nate Jones n...@endot.org

Removes entries in .gittrees where the subtree files are
no longer present on disk.

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 13/23] contrib/subtree: Add prune command to OPTS_SPEC

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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,helpshow the help
 q quiet
-- 
1.8.2.rc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 14/23] contrib/subtree: Remove trailing slash from prefix parameter

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Conflicts:
git-subtree.sh

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 15/23] contrib/subtree: Teach from-submodule to add new subtree to .gittrees

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 16/23] contrib/subtree: Document pull-all and push-all

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 17/23] contrib/subtree: Document from-submodule and prune commands

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 18/23] contrib/subtree: Add missing commands to SYNOPSIS

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@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 pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 19/23] contrib/subtree: Document list command

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 20/23] contrib/subtree: Teach push to use --force option

2013-03-10 Thread Paul Campbell
From: James Roper jro...@vz.net

Signed-off-by: Paul Campbell pcampb...@kemitix.net

Conflicts:
contrib/subtree/git-subtree.sh

Signed-off-by: Paul Campbell pcampb...@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
 rejoinmerge the new branch back into HEAD
+ options for 'push'
+f,force   use force push
  options for 'add', 'merge', 'pull' and 'push'
 squashmerge 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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 21/23] contrib/subtree: Convert spaces to tabs and remove some trailing whitespace

2013-03-10 Thread Paul Campbell
From: Herman van Rink r...@initfour.nl

Signed-off-by: Paul Campbell pcampb...@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 21
-git remote add -t $refspec $tmp_remote

[PATCH v2 22/23] contrib/subtree: Parameters repository/branch for push/pull are optional

2013-03-10 Thread Paul Campbell
Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 23/23] contrib/subtree: Fix order of case switches so default case is last

2013-03-10 Thread Paul Campbell
Signed-off-by: Paul Campbell pcampb...@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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/19] git-subtree updates

2013-03-09 Thread Paul Campbell
The following set of commits are taken from the collection collated by
Herman van Rink and offered to the list in May of last year
($gmane/196667).

Where updating a commit to resolve a conflict has cleared the original
author of the commit I've noted the original author in the commit
message. Thus I've left the From lines in the format-patch output as
none of the work here is mine and I don't want to assume another's
credit.

I have tried to leave the commit's in a state as close to their
original, with only enough modification to allow them to be applied to
the current HEAD 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.

They provide the following:

In git-subtree.sh:

* OPTS_SPEC
  * pull/push: options for repository and refspec are both optional,
[repository [refspec]]
  * new sub-command: pull-all
  * new sub-command: push-all
  * new sub-command: list
  * new sub-command: from-submodule
  * new sub-command: prune
  * new sub-command: diff
  * new option for push: --force
* Trailing slash on prefix is removed
* Stores subtree metadata in .gittrees as:
  [subtree $dir]
url = $repository
path = $dir
branch = $refspec
* Replaces a non-visible carriage return character with a properly escaped one
* pull and push: reads options from .gitrees if not provided on the command line
* Implementation of diff
  Fetches remote repo as a temporary git-remote then uses
git-diff-tree to compare before removing the temporary git-remote
* Implementation of list as plain wrapper to new functions subtree_list
  Iterates over subtrees listed in .gittrees and prints out their details
* Implementation of from-submodule
  Converts a git-submodule into a git-subtree
* Implementation of prune
  Removes entries from .gittrees where the $dir is missing
* Implementation of pull-all
  Performs a git-subtree pull for each subtree
* Implementation of push-all
  Performs a git-subtree push for each subtree

In git-subtree.txt:

* Adds brief descriptions for commands:
  * pull-all
  * push-all
  * list
  * from-submodule
  * prune
  * diff (TO BE DOCUMENTED)
* Notes optional -f|--force for push sub-command
* fixes a typo in text for Example 1 (s/incldued/included/)

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/19] spell checking

2013-03-09 Thread Paul Campbell
From 72fc84b6e5085b328cc90e664c9f85a1f5cde36c Mon Sep 17 00:00:00 2001
From: Paul Cartwright paul.cartwri...@ziilabs.com
Date: Thu, 27 Jan 2011 22:33:06 +0800
Subject: [PATCH 01/19] spell checking

---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/19] Add from-submodule. Conflicts: .gitignore contrib/subtree/git-subtree.sh test.sh

2013-03-09 Thread Paul Campbell
From 718c99d167255b28830b6f684d6e6e184fba0f7c Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:30:20 +
Subject: [PATCH 02/19] Add from-submodule. Conflicts:   .gitignore
 contrib/subtree/git-subtree.sh test.sh

Original-Author: Peter Jaros pja...@pivotallabs.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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,helpshow 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.X)
+   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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/19] Use .gittrees config file like a .gitmodules when pull or push

2013-03-09 Thread Paul Campbell
From 92787322c6e0e8c9166f02f98a71b6e0af9dc405 Mon Sep 17 00:00:00 2001
From: bibendi bibe...@bk.ru
Date: Fri, 20 May 2011 00:15:53 +0600
Subject: [PATCH 03/19] Use .gittrees config file like a .gitmodules when pull
 or push

---
 contrib/subtree/git-subtree.sh | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index caf4988..cb9e288 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -593,7 +593,8 @@ cmd_split()
eval $grl |
while read rev parents; do
revcount=$(($revcount + 1))
-   say -n $revcount/$revmax ($createcount)

+   say -n $revcount/$revmax ($createcount)
+
debug Processing commit: $rev
exists=$(cache_get $rev)
if [ -n $exists ]; then
@@ -700,21 +701,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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/19] new commands: pull_all and push_all

2013-03-09 Thread Paul Campbell
From 7e20edee694cbcbac79be4fbe37d9cedebe3e4ee Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:31:37 +
Subject: [PATCH 04/19] new commands: pull_all and push_all

Conflicts:
contrib/subtree/git-subtree.sh

Original-Author: bibendi bibe...@bk.ru
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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 cb9e288..c3b1208 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
@@ -760,4 +763,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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/19] A number of changes to push_all and pull_all:

2013-03-09 Thread Paul Campbell
From 10f2260165d6be3a6ab477ed38fd8ab0308c11e6 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:31:59 +
Subject: [PATCH 05/19] A number of changes to push_all and pull_all:

* adding commands in add to populate the .gittrees file
* changing underscores to dashes (push_all - push-all)
* changing commands to not be hardcoded to branch master from remote
* letting the user specify 0, 1, or 2 arguments to push and pull, like
normal git push and git pull.  We'll try to look up missing
information from .gittrees, like git normally does from .git/config

Conflicts:
.gitignore
contrib/subtree/git-subtree.sh

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 57 ++
 1 file changed, 41 insertions(+), 16 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index c3b1208..74e4c74 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
@@ -531,6 +532,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()
@@ -704,13 +713,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
@@ -723,12 +740,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
@@ -763,7 +788,7 @@ cmd_from-submodule()
rm -rf $tmp_repo
 }

-cmd_pull_all()
+cmd_pull-all()
 {
 git

[PATCH 06/19] merging change from nresni

2013-03-09 Thread Paul Campbell
From b6c810480547966c73bcaaea4c069fe73dacbc05 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:32:24 +
Subject: [PATCH 06/19] merging change from nresni

manual merge at the moment...i'll try a proper merge next now that
formatting is cleaner

Conflicts:
git-subtree.sh

Fixes hidden carriage return

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 74e4c74..8056851 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -605,8 +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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/19] Added check to ensure that split succeeds before trying to push

2013-03-09 Thread Paul Campbell
From ef4d4081474bd9925b60c2ab856260d9174220b9 Mon Sep 17 00:00:00 2001
From: mhart mich...@adslot.com
Date: Sun, 16 Oct 2011 00:16:53 +1100
Subject: [PATCH 07/19] Added check to ensure that split succeeds before trying
 to push

---
 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

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/19] fixing typo

2013-03-09 Thread Paul Campbell
From 8f6eb2ddfcaef888dc3d3ea4d089aa2e9cad5d0f Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:32:53 +
Subject: [PATCH 08/19] fixing typo

Conflicts:
git-subtree.sh

Add diff command

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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,helpshow 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 21
+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 21
+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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/19] Adding a list command

2013-03-09 Thread Paul Campbell
From ca1c855c032d88159ed878f68ef2e18640bbd49c Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:12 +
Subject: [PATCH 09/19] Adding a list command

Conflicts:
git-subtree.sh

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/19] 'prune' command to clear out stale .gittrees info

2013-03-09 Thread Paul Campbell
From 1aaa55ff64b3b4d9325568b3bb863748f20c80f3 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:33 +
Subject: [PATCH 10/19] 'prune' command to clear out stale .gittrees info

Conflicts:
git-subtree.sh

Original-Author: Nate Jones n...@endot.org
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/19] Add prune command to OPTS_SPEC

2013-03-09 Thread Paul Campbell
From 48e77d62e05582e2aec4c634a913f28f3f804a37 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:50 +
Subject: [PATCH 11/19] Add prune command to OPTS_SPEC

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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,helpshow the help
 q quiet
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/19] Remove trailing slash from prefix parameter

2013-03-09 Thread Paul Campbell
From d4aa87f53b61481d2f916415f0baec527a8b6417 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:34:10 +
Subject: [PATCH 12/19] Remove trailing slash from prefix parameter

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/19] Document pull-all and push-all

2013-03-09 Thread Paul Campbell
From 7dcd40ab8687a588b7b0c6ff914a7cfb601b6774 Mon Sep 17 00:00:00 2001
From: Herman van Rink r...@initfour.nl
Date: Tue, 27 Mar 2012 13:59:16 +0200
Subject: [PATCH 14/19] Document pull-all and push-all

---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/19] Document from-submodule and prune commands

2013-03-09 Thread Paul Campbell
From 6dc8119a7d99f7107e32f2c5d7ec18b9fd93a6b8 Mon Sep 17 00:00:00 2001
From: Herman van Rink r...@initfour.nl
Date: Tue, 27 Mar 2012 14:14:54 +0200
Subject: [PATCH 15/19] Document from-submodule and prune commands

---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/19] Update SYNOPSIS

2013-03-09 Thread Paul Campbell
From 6024d877e6c3beebe4c11bd060553d06af422680 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:34:54 +
Subject: [PATCH 16/19] Update SYNOPSIS

Conflicts:
contrib/subtree/git-subtree.txt

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/19] Document list command

2013-03-09 Thread Paul Campbell
From fed80cb47dffcb805a7808e8574dda44992363b0 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:35:18 +
Subject: [PATCH 17/19] Document list command

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/19] Added --force option to push

2013-03-09 Thread Paul Campbell
From ae7c05bdc6d02fa89deabb59cec6150308f227f7 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:35:42 +
Subject: [PATCH 18/19] Added --force option to push

Conflicts:
contrib/subtree/git-subtree.sh

Original-Author: James Roper jro...@vz.net
Conflicts-resolved-by: Paul Campbell pcampb...@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
 rejoinmerge the new branch back into HEAD
+ options for 'push'
+f,force   use force push
  options for 'add', 'merge', 'pull' and 'push'
 squashmerge 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


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/19] Fix some trailing whitespace

2013-03-09 Thread Paul Campbell
From 54d376c3d731ce9e528fe9095ea6c16d382b5ce3 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:36:22 +
Subject: [PATCH 19/19] Fix some trailing whitespace

Conflicts:
contrib/subtree/.gitignore
contrib/subtree/git-subtree.sh
contrib/subtree/test.sh

Original-Author: Herman van Rink r...@initfour.nl

OPTS_SPEC for push and pull updated (should have been picked up in an
earlier commit)

Fixed order of cases in setting the --default parameter

Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 223 +
 1 file changed, 114 insertions(+), 109 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 3582a55..df1413d 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...]]
@@ -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= ;;
@@ -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
@@ -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 ] ||
@@ -133,7 +135,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 -a $command != diff ]; then
revs=$(git rev-parse $default --revs-only $@) || exit $?
dirs=$(git rev-parse --no-revs --no-flags $@) || exit $?
if [ -n $dirs ]; then
@@ -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

Re: [PATCH 01/19] spell checking

2013-03-09 Thread Paul Campbell
On Sat, Mar 9, 2013 at 7:45 PM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 From 72fc84b6e5085b328cc90e664c9f85a1f5cde36c Mon Sep 17 00:00:00 2001
 From: Paul Cartwright paul.cartwri...@ziilabs.com
 Date: Thu, 27 Jan 2011 22:33:06 +0800
 Subject: [PATCH 01/19] spell checking

 ---
  contrib/subtree/git-subtree.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 I won't repeat these for other 18 patches, but please:

Thanks and apologies. All noted, although I have a question below.

  - drop the first From object name magic timestamp line which
is not part of the patch (it is only meant to help people who
maintain the file(1) and magic(5));

  - keep From: author name ... and Date:  lines for other
peoples' patches you are forwarding (they can be dropped for your
own patches); and

  - drop Subject:  as that is the same as the subject of the e-mail
message.

  - fix the subject to make it clear that the change is for
contrib/subtree.

spell checking [*1*] in the output of git shortlog v1.8.1..,
together with other 600+ patches' titles, will not help the
reader to see how much activity each area had and who worked in
what area.

I'd wanted to avoid changing the original author's work as much as
possible. Wrong choice on my part.

  - have the authors sign-off their patches, and then add yours as
the person who is forwarding other peoples' patches (see
Documentation/SubmittingPatches).

Four of the eight original authors now have dead email addresses. As I
found out when I started getting the mail bounces when I started
sending these patches out. Would it be acceptable for those patches to
leave the From line, add a Based-on-patch-by and then sign of myself?
I've really only done enough on top of the cherry-picking to get round
any conflicts.

  - Cc the area maintainer (I thought it was David Greene?)

 if these patches are meant to become part of git.git eventually.

I knew that and forgot. Can I blame this on my head-cold? No?

 Thanks.


 [Footnote]

 *1* Besides, a patch can never be spell *checking*.  It would be
  typofix after the author did a 'spell checking' ;-)

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Questions/investigations on git-subtree and tags

2013-03-07 Thread Paul Campbell
On Thu, Mar 7, 2013 at 10:25 AM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:
 Hello everybody


 I am trying to use git-subtree to follow a subproject but I have a couple of 
 problems and I am not sure if I am doing something wrong

 Basically I am trying to use a tag on the subproject as my base for the 
 subproject but subtree doesn't seem to handle that properly


 my first attempt was to simply do

 git subtree add --squash git://git.buildroot.net/buildroot 2013.02

 but subtree refused, telling me that the SHA of the tag is not a valid commit.
 Ok it makes sense, though I think this is a very valid use-case...

 so I tried

 git subtree add git://git.buildroot.net/buildroot 2013.02^{commit}

 which was refused because git fetch can't parse the ^{commit} marker.
 Again it makes sense, but I really want to start from that tag.


 so I tried

 git fetch git://git.buildroot.net/buildroot 2013.02
 git subtree add --squash FETCH_HEAD

 which worked. Ok at that point I am slightly abusing git subtree, but it 
 seems a valid usage

 except that this last attempt causes serious problems when trying to split 
 out the tree again

 the call to git commit-tree within git subtree split complains that the 
 SHA of the parent
 is not a valid commit SHA. Which is true, it's the SHA of the tag.


 At this point I am not sure if I am abusing subtree, if I have a legitimate 
 but unimplemented use-case and how to
 fix/implement it.

 the squash-commit message only contains the SHA of the tag, should it contain 
 the SHA of the commit ?

 subtree split can only handle commit SHA, should it somehow follow tag SHA 
 too ? how ?

 this is probably a trivial fix for someone with good knowledge of git-subtree 
 but i'm not there yet, so any hint would be welcomed

 Regards

 Jérémy Rosen


Hi Jérémy,

Git subtree ignores tags from the remote repo.

To follow a project in a subdirectory I would use git-subtree add
selecting a branch, not a tag, from the other repo. Then use
git-subtree pull to keep yourself updated.

e.g.

To add:

git subtree add --prefix=$subdir $repo $branch

Then to update:

git subtree pull --prefix=$subdir $repo $branch

If you make any changes on the branch and wanted to push them back you
could do that with:

git subtree pull --prefix=$subdir $repo2 $branch2

$repo2 and $branch2 would be different from $repo and $branch if you
wanted to push to your own fork before submitting a pull request.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Questions/investigations on git-subtree and tags

2013-03-07 Thread Paul Campbell
On Thu, Mar 7, 2013 at 11:05 AM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:

 Hi Jérémy,

 Git subtree ignores tags from the remote repo.


 is that a design decision or a case of not implemented yet

I'm not sure. If you imported all the tags from all your subtrees
repos, you could easily end up with duplicate tags from different
repos. They could be namespaced, but there is no concept of namespace
in git-subtree. That even assumes that you can tag a subtree (I've not
tried).

 To follow a project in a subdirectory I would use git-subtree add
 selecting a branch, not a tag, from the other repo. Then use
 git-subtree pull to keep yourself updated.



 well... yes, but releases are marked by tags, not branches so what I really 
 want is a tag.

 I still use git so I have the possibility to update and can traceback what 
 happened later

 e.g.

 To add:

 git subtree add --prefix=$subdir $repo $branch

 Then to update:

 git subtree pull --prefix=$subdir $repo $branch



 ok, that probably works with branches (didn't test)

 If you make any changes on the branch and wanted to push them back
 you
 could do that with:

 git subtree pull --prefix=$subdir $repo2 $branch2

 $repo2 and $branch2 would be different from $repo and $branch if you
 wanted to push to your own fork before submitting a pull request.


 shouldn't there be a subtree split somewhere ? IIUC pull is only merge from 
 the remote to my local repo,
 not the other way round

Oops, that should have been git subtree push, which uses git subtree
split internally.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Questions/investigations on git-subtree and tags

2013-03-07 Thread Paul Campbell
On Thu, Mar 7, 2013 at 12:50 PM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:
 
  Git subtree ignores tags from the remote repo.
 
 
  is that a design decision or a case of not implemented yet

 I'm not sure. If you imported all the tags from all your subtrees
 repos, you could easily end up with duplicate tags from different
 repos. They could be namespaced, but there is no concept of namespace
 in git-subtree. That even assumes that you can tag a subtree (I've
 not
 tried).


 Ok, I can understand that you don't want to import tags for namespace reason, 
 but in that case shouldn't
 git subtree add refuse to create a subtree when the tag isn't a commit

It shouldn't and tries not to, but is limited in it's ability to
identify if a refspec points to a commit or not in the remote repo.

 or if it allows it, what would be the gracefull way to handle that ?

I've posted a patch (which is pending a lot of other changes to
git-subtree that I'm corralling) that tries to prevent some obvious
errors in the refspec. But letting the git fetch used by git-subtree
add and git-subtree pull catch the error and report it may be the best
option.

 i'm quite new to git's internals, so I don't really know if/what the right 
 approch would be.

 note that all those problems seems to disapear when squash is not used

I've never really tried using --squash, I don't see that it adds any
value for me.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Questions/investigations on git-subtree and tags

2013-03-07 Thread Paul Campbell
On Thu, Mar 7, 2013 at 3:15 PM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:
 
  Ok, I can understand that you don't want to import tags for
  namespace reason, but in that case shouldn't
  git subtree add refuse to create a subtree when the tag isn't a
  commit

 It shouldn't and tries not to, but is limited in it's ability to
 identify if a refspec points to a commit or not in the remote repo.


 ok, i've studied a little more

 * the target for git subtree add url refspec can only be a remote branch 
 or tag, since we git fetch
 can only target remote refs.
 * in case of a branch, git subtree forgets the branch and only use the commit 
 linked to the branch. for
 tags, the fetch part is ok, it's the merge part that fail. adding ^{} at the 
 right place would probably fix that

I think I tried adding the ^{} syntax, but I don't think it works on
remote repos. Or I couldn't get the right syntax.


 I've posted a patch (which is pending a lot of other changes to
 git-subtree that I'm corralling) that tries to prevent some obvious
 errors in the refspec. But letting the git fetch used by git-subtree
 add and git-subtree pull catch the error and report it may be the
 best
 option.


 that's interesting... do you have a link ?

Latest patch:

  http://thread.gmane.org/gmane.comp.version-control.git/217257

Prior patch with comments from Junio on what was probably going on
with the old tests:

  http://thread.gmane.org/gmane.comp.version-control.git/217227


 I've never really tried using --squash, I don't see that it adds any
 value for me.


 my project has a git subtree for a linux kernel and another subtree for 
 buildroot,

 a default .git is about 1.5G, squashing it reduces it to 200M so it's worth 
 it for me :)

If disk space is the issue, or bandwidth for initial cloning, then
sure, but I thought Git was efficient enough that a large repo
wouldn't give much of a performance hit.  Unless you use git-subtree
split or push, they are slow.

If git-subtree split could be optimised then --squash wouldn't be
needed as much. It does take an age compared to other Git operations.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Subtree in Git

2013-03-04 Thread Paul Campbell
On Sat, Mar 2, 2013 at 5:43 PM, Paul Campbell pcampb...@kemitix.net wrote:
 On Sat, Mar 2, 2013 at 11:21 AM, David Michael Barr b...@rr-dav.id.au wrote:
 On Sat, Mar 2, 2013 at 9:05 AM, Paul Campbell pcampb...@kemitix.net wrote:
 On Fri, Mar 1, 2013 at 2:28 AM, Kindjal kind...@gmail.com wrote:
 David Michael Barr b at rr-dav.id.au writes:

 From a quick survey, it appears there are no more than 55 patches
 squashed into the submitted patch.
 As I have an interest in git-subtree for maintaining the out-of-tree
 version of vcs-svn/ and a desire to improve my rebase-fu, I am tempted
 to make some sense of the organic growth that happened on GitHub.
 It doesn't appear that anyone else is willing to do this, so I doubt
 there will be any duplication of effort.


 What is the status of the work on git-subtree described in this thread?
 It looks like it's stalled.


 I hadn't been aware of that patch. Reading the thread David Michael
 Barr was going to try picking the patch apart into sensible chunks.


 Sorry for not updating the thread. I did end up moving onto other things.
 I quickly realised the reason for globbing all the patches together was
 that the individual patches were not well contained.
 That is single patches with multiple unrelated changes and multiple
 patches changing the same things in different directions.
 To me this means that the first step is to curate the history.

 If this work is still needing done I'd like to volunteer.

 You're most welcome. Sorry again for abandoning the thread.

 --
 David Michael Barr

 Okay, I'll start picking the patch apart this week then feedback when
 I have a plan to tackle it all.

 --
 Paul [W] Campbell

From a comparison of the tip for helmo's subtree-updates branch and
the current master these are the changes and features that the patch
is providing.  I've listed the changes briefly per file, with a note
of the general action I plan to take. This is based on a simple diff,
so some changes are actually reversions to recent commits, which I
have tried to note.

Makefile

* Regresses two recent commits (8165be064e and d86848228f)
* ACTION: Ignore file

README.md

* Adds a markdown readme file (that github likes to have in root)
* Includes some install instructions in a pseudo man page format
* The INSTALL file covers all the information contained and is more 
up-to-date
* ACTION: Ignore file

git-subtree.sh

* OPTS_SPEC
* pull/push: options for repository and refspec are both 
optional,
[repository [refspec]]
* new sub-command: pull-all
* new sub-command: push-all
* new sub-command: list
* new sub-command: from-submodule
* new sub-command: prune
* new sub-command: diff
* new option for push: --force
* Trailing slash on prefix is removed
* Different pretty log format in cmd_commit getting piped to set some
environment variables
* Would revert: a5b8e28e4e
* Ignoring this change
* Removes all tests in cmd_add to check that refspec is valid
* I've posted a patch with new tests to the list recently that 
would
go in here
* Change reference to 'commit' into 'refspec' in error message in 
cmd_add
* Stores subtree metadata in .gittrees as:
[subtree $dir]
url = $repository
path = $dir
branch = $refspec
* Inadvertently commited a change to the linefeed character in
cmd_split for the activity indicator
* cmd_pull/cmd_push: reads options from .gitrees if not provided on
the command line
* Implementation of cmd_diff
* fetches remote repo as a temporary git-remote then uses
git-diff-tree to compare before removing the temporary git-remote
* Implementation of cmd_list as plain wrapper to new functions 
subtree_list
* Iterates over subtrees listed in .gittrees and prints out 
their details
* Dubious about greps used to get list from .gittrees
* Implementation of cmd_from-submodule
* Converts a git-submodule into a git-subtree
* Implementation of cmd_prune
* Removes entries from .gittrees where the $dir is missing
* Dubious about greps used to get list from .gittrees
* Implementation of cmd_pull-all
* Performs a git-subtree pull for each subtree
* Dubious about greps used to get list from .gittrees
* Implementation of cmd_push-all
* Perfroms a git-subtree push for each subtree
* Dubious about greps used to get list from .gittrees

git-subtree.txt

* Adds brief descriptions for commands:
* pull-all
* push-all
* list
* from

Re: Subtree in Git

2013-03-02 Thread Paul Campbell
On Sat, Mar 2, 2013 at 11:21 AM, David Michael Barr b...@rr-dav.id.au wrote:
 On Sat, Mar 2, 2013 at 9:05 AM, Paul Campbell pcampb...@kemitix.net wrote:
 On Fri, Mar 1, 2013 at 2:28 AM, Kindjal kind...@gmail.com wrote:
 David Michael Barr b at rr-dav.id.au writes:

 From a quick survey, it appears there are no more than 55 patches
 squashed into the submitted patch.
 As I have an interest in git-subtree for maintaining the out-of-tree
 version of vcs-svn/ and a desire to improve my rebase-fu, I am tempted
 to make some sense of the organic growth that happened on GitHub.
 It doesn't appear that anyone else is willing to do this, so I doubt
 there will be any duplication of effort.


 What is the status of the work on git-subtree described in this thread?
 It looks like it's stalled.


 I hadn't been aware of that patch. Reading the thread David Michael
 Barr was going to try picking the patch apart into sensible chunks.


 Sorry for not updating the thread. I did end up moving onto other things.
 I quickly realised the reason for globbing all the patches together was
 that the individual patches were not well contained.
 That is single patches with multiple unrelated changes and multiple
 patches changing the same things in different directions.
 To me this means that the first step is to curate the history.

 If this work is still needing done I'd like to volunteer.

 You're most welcome. Sorry again for abandoning the thread.

 --
 David Michael Barr

Okay, I'll start picking the patch apart this week then feedback when
I have a plan to tackle it all.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Subtree in Git

2013-03-01 Thread Paul Campbell
On Fri, Mar 1, 2013 at 2:28 AM, Kindjal kind...@gmail.com wrote:
 David Michael Barr b at rr-dav.id.au writes:

 From a quick survey, it appears there are no more than 55 patches
 squashed into the submitted patch.
 As I have an interest in git-subtree for maintaining the out-of-tree
 version of vcs-svn/ and a desire to improve my rebase-fu, I am tempted
 to make some sense of the organic growth that happened on GitHub.
 It doesn't appear that anyone else is willing to do this, so I doubt
 there will be any duplication of effort.


 What is the status of the work on git-subtree described in this thread?
 It looks like it's stalled.


I hadn't been aware of that patch. Reading the thread David Michael
Barr was going to try picking the patch apart into sensible chunks.

My own patches, some of which I've submitted to the list, appear to be
tackling a couple of the same things (e.g. storing subtree metadata in
an ini file). Mine can be found here
(https://github.com/kemitix/git/commits/subtree-usability), including
some I've not submitted yet.

If this work is still needing done I'd like to volunteer.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG/PATCH] contrib/subtree: allow addition of remote branch with name not locally present

2013-02-28 Thread Paul Campbell
On Thu, Feb 28, 2013 at 12:20 AM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 cmd_add() attempts to check for the validity of refspec for the repository
 it is about to add as a subtree. It tries to do so before contacting the
 repository. If the refspec happens to exist locally (say 'master') then
 the test passes and the repo is fetched. If the refspec doesn't exist
 locally then the test fails and the remote repo is never contacted.

 Removing the tests still works as the git fetch command fails with the
 perfectly accurate error:

   fatal: Couldn't find remote ref refspec

 Signed-off-by: Paul Campbell pcampb...@carnegiecollege.ac.uk
 ---

 I must confess to not understanding the comment preceding the
 rev-parse test. Given that it is against the rev-parse and not the
 cmd_add_repository call I'm assuming it can be removed.

 This is contrib/ material and I do not use the command, so anything
 I say should be taken with a moderate amount of salt, but I think
 the comment is talking about _not_ accepting a full storing refspec,
 or worse yet wildcard, e.g.

 refs/heads/topic:refs/remotes/origin/topic
 refs/heads/*:refs/remotes/origin/*

 which will not make sense given that you are only adding a single
 commit via cmd_add.  Also, if you have already fetched from the
 remote, rev-parse $2^{commit} at this point will protect against
 a typo by the end user.

 As you noticed, checking if $2 is a commit using rev-parse _before_
 fetching $2 from the remote repository is not a valid way to check
 against such errors.  So I tend to agree that removing the die
 will be a good idea.

 Typing tipoc when the user meant topic will error out at the
 git fetch done in cmd_add_repository, but that fetch will happily
 fetch and store whatever a refspec specifies, so you might want to
 replace the bogus rev-parse before fetching check to reject
 refspec with something else.

Thanks for the feedback.

Checking for a ':' or a '*' in the refspec should stop the storage
name and wildcards getting through.

Rerolling the patch with new test.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] contrib/subtree: allow addition of remote branch with name not locally present

2013-02-28 Thread Paul Campbell
cmd_add() attempts to check for the validity of refspec for the repository
it is about to add as a subtree. It tries to do so before contacting the
repository. If the refspec happens to exist locally (say 'master') then
the test passes and the repo is fetched. If the refspec doesn't exist
locally then the test fails and the remote repo is never contacted.

Removing the tests still works as the git fetch command fails with the
perfectly accurate error:

  fatal: Couldn't find remote ref refspec

New tests check to prevent pulling in multiple branches or creating a local
branch for the subtree.

Signed-off-by: Paul Campbell pcampb...@carnegiecollege.ac.uk
---

I've rerolled this with alternate tests.

Is there anything else that should be tested for?

 contrib/subtree/git-subtree.sh | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..d04bd25 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -503,13 +503,14 @@ cmd_add()

cmd_add_commit $@
elif [ $# -eq 2 ]; then
-   # Technically we could accept a refspec here but we're
-   # just going to turn around and add FETCH_HEAD under the
-   # specified directory.  Allowing a refspec might be
-   # misleading because we won't do anything with any other
-   # branches fetched via the refspec.
-   git rev-parse -q --verify $2^{commit} /dev/null ||
-   die '$2' does not refer to a commit
+   case $2 in
+   *\**) # Avoid pulling in multiple branches
+   die '$2' contains a wildcard
+   ;;
+   *\:*) # Don't create a local branch for the subtree
+   die '$2' contains a local branch name
+   ;;
+   esac

cmd_add_repository $@
else
-- 
1.8.2.rc1
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree workflow

2013-02-27 Thread Paul Campbell
On Tue, Feb 26, 2013 at 9:04 AM, Ben McCann b...@benmccann.com wrote:
 I'm fairly new to git and am trying to determine if git subtree would
 be helpful for managing our company's codebase, which has several
 repos some of which depend on each other. All the examples I've seen
 make sense to me as a one-time operation to merge separate repos into
 one monolithic one or to split one monolithic repo into separate
 repos. I'm having a harder time understanding how this fits into a
 larger picture and what the workflow for working with subtree would
 be.

The git subtree command does support pushing and pulling changes
to/from a subtree to a remote repo. This operation can be repeated
over time as the underlying git subtree split command produces an
accurate extract from the subtree.

For example:

$ git clone $superrepo super
$ cd super
$ git subtree add --prefix=child $childrepo master
$ split_head=$(git subtree split --prefix=child)

git subtree split creates a synthetic copy of the child subtree and
returns the SHA1 for the head of that subtree.

$ cd ..
$ git clone $childrepo child
$ cd child
$ child_head=$(git rev-parse master)

$split_head and $child_head match.

You could pass either $*_head to gitk and be able to browse identical
trees and histories.

$ gitk $child_head 
$ cd ../super
$ gitk $split_head 

The only difference you should see is that the tree in the super
project doesn't have any branches or tags from the child repo.

 If I have a bunch of repos on GitHub and some depend on each other,
 how would I set them up to work with subtree? Would GitHub continue to
 host them as is, host a merged monolithic repo, or host both a
 monolithic repo and the splitted out repos? The exact answer probably
 varies, but I imagine there's basic workflow that would satisfy 80% of
 users.  If I have GitHub host both monolithic and splitted out repos,
 it seems unclear as to how I keep those repos in sync and make sure
 all the developers in our company push their changes to both repos.

This is what I'm using git-subtree for. I have a super project which
holds child repos, some of which hold other child repos.  You can
develop on all of your projects within the super project and still
periodically pull and push updates with the remote child repos.

Someone who doesn't know about your child repos can take the
monolithic repo and commit to it as normal. You can then pull their
commits and push any changes to the child repos. Probably to a
non-master branch so you they can be integrated like other pull
requests.

Caveats:

1) I would probably avoid the --squash option as I suspect that might
mess with $split_head == $child_head. Whether or not it would have any
impact of your ability to push or pull I don't know. I've not tried
it.

2) When you commit you should ideally not commit a set of files that
are in more than one subtree. You're commit history when you push back
to the source repo for a subtree might look a bit odd if it's
referring to other parts of the super project or it's subtrees.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BUG/PATCH] contrib/subtree: allow addition of remote branch with name not locally present

2013-02-27 Thread Paul Campbell
cmd_add() attempts to check for the validity of refspec for the repository
it is about to add as a subtree. It tries to do so before contacting the
repository. If the refspec happens to exist locally (say 'master') then
the test passes and the repo is fetched. If the refspec doesn't exist
locally then the test fails and the remote repo is never contacted.

Removing the tests still works as the git fetch command fails with the
perfectly accurate error:

  fatal: Couldn't find remote ref refspec

Signed-off-by: Paul Campbell pcampb...@carnegiecollege.ac.uk
---

I must confess to not understanding the comment preceding the
rev-parse test. Given that it is against the rev-parse and not the
cmd_add_repository call I'm assuming it can be removed.

 contrib/subtree/git-subtree.sh | 8 
 1 file changed, 8 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..9a38b18 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -503,14 +503,6 @@ cmd_add()

cmd_add_commit $@
elif [ $# -eq 2 ]; then
-   # Technically we could accept a refspec here but we're
-   # just going to turn around and add FETCH_HEAD under the
-   # specified directory.  Allowing a refspec might be
-   # misleading because we won't do anything with any other
-   # branches fetched via the refspec.
-   git rev-parse -q --verify $2^{commit} /dev/null ||
-   die '$2' does not refer to a commit
-
cmd_add_repository $@
else
say error: parameters were '$@'
--
1.8.2.rc1


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFD] subtree status - comparing subtree with a remote

2013-02-22 Thread Paul Campbell
Hi,

I'm looking at adding a git subtree status command that will tell if
a subtree is up-to-date, ahead of, behind, divergant with or unrelated
to a remote repo.

I just wanted to check that I'm working this out correctly before
writing the code.

1) perform a synthetic subtree split

  mine=$(git subtree split --prefix=subtree/path)

This outputs the SHA1 for this subtree in isolation to the superproject.

2) fetch latest branch HEAD from remote repository we're comparing with

  git fetch $repo $branch
  theirs=$(git rev-parse FETCH_HEAD)

3) Find common ancestor

  base=$(git merge-base $mine $theirs)

Where:

* $base == $mine  $base == $theirs : up-to-date

* $base == $mine  $base != $theirs : behind remote - can pull

* $base != $mine  $base == $theirs : ahead of remote - can push

* $base != $mine  $base != $theirs : divergent

* $base == null : no common ancestor - wrong repo?

Comments?

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] contrib/subtree: Store subtree sources in .gitsubtree

2013-02-19 Thread Paul Campbell
Thanks to Jonathan for the constructive criticism of the tests.  Here
is the latest version.

I suspect I'll need to leave it until after David's changes to the
tests are merged into master, unless anyone thinks I should rebase
elsewhere. I think my tests only need a minor update to accommodate
those changes.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] contrib/subtree: Store subtree sources in .gitsubtree

2013-02-19 Thread Paul Campbell
Add the prefix, repository and refspec in the file .gitsubtree when
git subtree add is used. Then when a git subtree push or pull is needed
the repository and refspec from .gitsubtree are used as the default
values.

Having to remember what subtree came from what source is a waste of
developer memory and doesn't transfer easily to other developers.

git subtree push/pull operations would typically be to/from the same
source that the original subtree was cloned from with git subtree add.

The repository and refspec, or commit, used in the git subtree add
operation are stored in .gitsubtree. One line each, delimited by a space:
prefix repository refspec or prefix . commit.

Subsequent git subtree push/pull operations now default to the values
stored in .gitsubtree, unless overridden from the command line.

The .gitsubtree file should be tracked as part of the repo as it
describes where parts of the tree came from and can be used to update
to and from that source.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 75 +++---
 1 file changed, 64 insertions(+), 11 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..1d0bf35 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -11,8 +11,8 @@ 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 push  --prefix=prefix repository refspec...
+git subtree pull  --prefix=prefix [repository refspec...]
+git subtree push  --prefix=prefix [repository refspec...]
 git subtree split --prefix=prefix commit...
 --
 h,helpshow the help
@@ -489,6 +489,28 @@ ensure_clean()
fi
 }

+add_subtree () {
+   if ( grep ^$dir  .gitsubtree 2/dev/null )
+   then
+   # remove $dir from .gitsubtree - there's probably a clever way 
to
do this with sed
+   grep -v ^$dir  .gitsubtree .gitsubtree.temp
+   rm .gitsubtree
+   mv .gitsubtree.temp .gitsubtree
+   fi
+   if test $# -eq 1
+   then
+   # Only a commit provided, thus use the current repository
+   echo $dir . $@ .gitsubtree
+   elif test $# -eq 2
+   then
+   echo $dir $@ .gitsubtree
+   fi
+}
+
+get_subtree () {
+   grep ^$dir  .gitsubtree || die Subtree not found in .gitsubtree:  
$dir
+}
+
 cmd_add()
 {
if [ -e $dir ]; then
@@ -497,6 +519,8 @@ cmd_add()

ensure_clean

+   add_subtree $@
+
if [ $# -eq 1 ]; then
git rev-parse -q --verify $1^{commit} /dev/null ||
die '$1' does not refer to a commit
@@ -700,7 +724,23 @@ cmd_merge()
 cmd_pull()
 {
ensure_clean
-   git fetch $@ || exit $?
+   if test $# -eq 0
+   then
+   subtree=($(get_subtree))
+   repository=${subtree[1]}
+   refspec=${subtree[2]}
+   if test $repository == .
+   then
+   echo Pulling into $dir from branch $refspec
+   else
+   echo Pulling into $dir from $repository $refspec
+   fi
+   echo git fetch using:  $repository $refspec
+   git fetch $repository $refspec || exit $?
+   else
+   echo git fetch using: $@
+   git fetch $@ || exit $?
+   fi
revs=FETCH_HEAD
set -- $revs
cmd_merge $@
@@ -708,16 +748,29 @@ cmd_pull()

 cmd_push()
 {
-   if [ $# -ne 2 ]; then
-   die You must provide repository refspec
+   repository=$1
+   refspec=$2
+   if test $# -eq 0
+   then
+   subtree=($(get_subtree))
+   repository=${subtree[1]}
+   refspec=${subtree[2]}
+   if test $repository == .
+   then
+   echo Pushing from $dir into branch $refspec
+   else
+   echo Pushing from $dir into $repository $refspec
+   fi
+   elif test $# -ne 2
+   then
+   die You must provide repository refspec, or a prefix 
listed
in .gitsubtree
fi
-   if [ -e $dir ]; then
-   repository=$1
-   refspec=$2
-   echo git push using:  $repository $refspec
-   git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
+   if test -e $dir
+   then
+   echo git push using:  $repository $refspec
+   git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
else
-   die '$dir' must already exist. Try 'git subtree add'.
+   die '$dir' must already exist. Try 'git subtree add'.
fi
 }

-- 
1.8.2.rc0.16.g20a599e
--
To unsubscribe from this list: send the line

[PATCH v2 2/3] contrib/subtree/t: Added tests for .gitsubtree support

2013-02-19 Thread Paul Campbell
add: ensure details are added to .gitsubtree
push: check for a SHA1 update line
pull: add a file on one subtree, push it to a branch, then pull into
another subtree containing the same branch and confirm the files match
add: ensure stale .gitsubtree entry is replaced

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/t/t7900-subtree.sh | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/contrib/subtree/t/t7900-subtree.sh
b/contrib/subtree/t/t7900-subtree.sh
index 80d3399..f1a24cf 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -465,4 +465,46 @@ test_expect_success 'verify one file change per commit' '
 ))
 '

+# return to mainline
+cd ../..
+
+# .gitsubtree
+test_expect_success 'added repository appears in .gitsubtree' '
+   git subtree add --prefix=copy0 sub1 
+   grep ^copy0 \. sub1$ .gitsubtree
+'
+
+test_expect_success 'change in subtree is pushed okay' '
+   (
+   cd copy0 
+   create new_file 
+   git commit -mAdded new_file
+   ) 
+   git ls-tree refs/heads/sub1 output 
+   ! grep new_file$ output 
+   git subtree push --prefix=copy0 
+   git ls-tree refs/heads/sub1 output 
+   grep new_file$ output
+'
+
+test_expect_success 'pull into subtree okay' '
+   git subtree add --prefix=copy1 sub1 
+   git subtree add --prefix=copy2 sub1 
+   (
+   cd copy1 
+   create new_file_in_copy1 
+   git commit -mAdded new_file_in_copy1
+   ) 
+   git subtree push --prefix=copy1 
+   git subtree pull --prefix=copy2 output 
+   grep ^ create mode 100644 copy2/new_file_in_copy1$ output
+'
+
+test_expect_success 'replace outdated entry in .gitsubtree' '
+   echo copy3 . sub2 .gitsubtree 
+   git subtree add --prefix=copy3 sub1 
+   ! grep ^copy3 . sub2$ .gitsubtree 
+   grep ^copy3 . sub1$ .gitsubtree
+'
+
 test_done
-- 
1.8.2.rc0.16.g20a599e
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] contrib/subtree: update documentation

2013-02-19 Thread Paul Campbell
Indicate that repository and refspec are now optional on push and pull.

Add notes to add, push and pull about storing values in .gitsubtree
and their use as default values.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.txt | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..2ad9278 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -11,8 +11,8 @@ 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' 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]

@@ -72,7 +72,9 @@ add::
A new commit is created automatically, joining the imported
project's history with your own.  With '--squash', imports
only a single commit from the subproject, rather than its
-   entire history.
+   entire history. Details of the prefix are added to the
+   .gitsubtree file, where they will be used as defaults for
+   'push' and 'pull'.

 merge::
Merge recent changes up to commit into the prefix
@@ -91,13 +93,16 @@ merge::
 pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
-   repository.
+   repository. Default values for repository and refspec
+   are taken from the .gitsubtree file.

 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.
+   Default values for repository and refspec are taken
+   from the .gitsubtree file.

 split::
Extract a new, synthetic project history from the
-- 
1.8.2.rc0.16.g20a599e
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] contrib/subtree: Store subtree sources in .gitsubtree and use for push/pull

2013-02-18 Thread Paul Campbell
On Mon, Feb 18, 2013 at 8:20 PM,  gree...@obbligato.org wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 Subsequent git subtree push/pull operations now default to the values
 stored in .gitsubtree, unless overridden from the command line.

 The .gitsubtree file should be tracked as part of the repo as it
 describes where parts of the tree came from and can be used to update
 to/from that source.

 I agree with the basic idea but have some questions about the
 implementation.

 Is there precedent of git commands storing information in hidden files
 and requiring those files to be added to the repository and tracked?  It
 seems like a bit of a kludge.

 Could we use notes or something for this?

 I'm not necessarily against the patches, I just want to make sure we
 don't go down a road that won't be acceptable later on.

-David

I'm not familiar with git notes. Adding that the my to-read list.

I took my inspiration from git submodules which uses the .gitmodules
file for a similar purpose.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] contrib/subtree: remove contradicting use options on echo wrapper

2013-02-15 Thread Paul Campbell
Remove redundant -n option and raw ^M in call to echo.

Call to 'say' function, a wrapper of 'echo', passed the parameter -n, then
included a raw ^M newline in the end of the last parameter. Yet the -n option
is meant to suppress the addition of new line by echo.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 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 8a23f58..51146bd 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -592,7 +592,7 @@ cmd_split()
eval $grl |
while read rev parents; do
revcount=$(($revcount + 1))
-   say -n $revcount/$revmax ($createcount)

+   say $revcount/$revmax ($createcount)
debug Processing commit: $rev
exists=$(cache_get $rev)
if [ -n $exists ]; then
-- 
1.8.1.3.605.g02339dd
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] contrib/subtree: Store subtree sources in .gitsubtree and use for push/pull

2013-02-15 Thread Paul Campbell
Add the prefix, repository and refspec in the file .gitsubtree when
git subtree add is used. Then when a git subtree push or pull is needed
the repository and refspec from .gitsubtree are used as the default
values.

Having to remember what subtree came from what source is a waste of
developer memory and doesn't transfer easily to other developers.

git subtree push/pull operations would typically be to/from the same
source that the original subtree was cloned from with git subtree add.

The repository and refspec, or commit, used in the git subtree add
operation are stored in .gitsubtree. One line each, delimited by a space:
prefix repository refspec or prefix . commit.

Subsequent git subtree push/pull operations now default to the values
stored in .gitsubtree, unless overridden from the command line.

The .gitsubtree file should be tracked as part of the repo as it
describes where parts of the tree came from and can be used to update
to and from that source.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---

Reworked my previous patch paying closer attention to the coding style
documentation and renamed my new functions to make more sense.

 contrib/subtree/git-subtree.sh | 75 +++---
 1 file changed, 64 insertions(+), 11 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 51146bd..6dc8999 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -11,8 +11,8 @@ 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 push  --prefix=prefix repository refspec...
+git subtree pull  --prefix=prefix [repository refspec...]
+git subtree push  --prefix=prefix [repository refspec...]
 git subtree split --prefix=prefix commit...
 --
 h,helpshow the help
@@ -489,6 +489,28 @@ ensure_clean()
fi
 }

+add_subtree () {
+   if ( grep ^$dir  .gitsubtree )
+   then
+   # remove $dir from .gitsubtree - there's probably a clever way 
to
do this with sed
+   grep -v ^$dir  .gitsubtree  .gitsubtree.temp
+   rm .gitsubtree
+   mv .gitsubtree.temp .gitsubtree
+   fi
+   if test $# -eq 1
+   then
+   # Only a commit provided, thus use the current repository
+   echo $dir . $@  .gitsubtree
+   elif test $# -eq 2
+   then
+   echo $dir $@  .gitsubtree
+   fi
+}
+
+get_subtree () {
+   grep ^$dir  .gitsubtree || die Subtree not found in .gitsubtree:  
$dir
+}
+
 cmd_add()
 {
if [ -e $dir ]; then
@@ -497,6 +519,8 @@ cmd_add()

ensure_clean

+   add_subtree $@
+
if [ $# -eq 1 ]; then
git rev-parse -q --verify $1^{commit} /dev/null ||
die '$1' does not refer to a commit
@@ -700,7 +724,23 @@ cmd_merge()
 cmd_pull()
 {
ensure_clean
-   git fetch $@ || exit $?
+   if test $# -eq 0
+   then
+   subtree=($(get_subtree))
+   repository=${subtree[1]}
+   refspec=${subtree[2]}
+   if test $repository == .
+   then
+   echo Pulling into $dir from branch $refspec
+   else
+   echo Pulling into '$dir' from '$repository' '$refspec'
+   fi
+   echo git fetch using:  $repository $refspec
+   git fetch $repository $refspec || exit $?
+   else
+   echo git fetch using: $@
+   git fetch $@ || exit $?
+   fi
revs=FETCH_HEAD
set -- $revs
cmd_merge $@
@@ -708,16 +748,29 @@ cmd_pull()

 cmd_push()
 {
-   if [ $# -ne 2 ]; then
-   die You must provide repository refspec
+   repository=$1
+   refspec=$2
+   if test $# -eq 0
+   then
+   subtree=($(get_subtree))
+   repository=${subtree[1]}
+   refspec=${subtree[2]}
+   if test $repository == .
+   then
+   echo Pushing from $dir into branch $refspec
+   else
+   echo Pushing from $dir into $repository $refspec
+   fi
+   elif test $# -ne 2
+   then
+   die You must provide repository refspec, or a prefix 
listed
in .gitsubtree
fi
-   if [ -e $dir ]; then
-   repository=$1
-   refspec=$2
-   echo git push using:  $repository $refspec
-   git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
+   if test -e $dir
+   then
+   echo git push using:  $repository $refspec
+   git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
else
-   die '$dir' must already exist. Try 'git subtree add'.
+   die '$dir' must

[PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support

2013-02-15 Thread Paul Campbell
add: ensure details are added to .gitsubtree
push: check for a SHA1 update line
pull: add a file on one subtree, push it to a branch, then pull into
another subtree containing the same branch and confirm the files match
add: ensure stale .gitsubtree entry is replaced

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/t/t7900-subtree.sh | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/contrib/subtree/t/t7900-subtree.sh
b/contrib/subtree/t/t7900-subtree.sh
index 80d3399..4437dc6 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -465,4 +465,34 @@ test_expect_success 'verify one file change per commit' '
 ))
 '

+# return to mainline
+cd ../..
+
+# .gitsubtree
+test_expect_success 'added repository appears in .gitsubtree' '
+git subtree add --prefix=copy0 sub1 
+grep ^copy0 \. sub1$ .gitsubtree
+'
+
+test_expect_success 'change in subtree is pushed okay' '
+cd copy0  create new_file  git commit -mAdded new_file 
+cd ..  git subtree push --prefix=copy0 21 | \
+grep
^\s\{3\}[0-9a-f]\{7\}\.\.[0-9a-f]\{7\}\s\s[0-9a-f]\{40\}\s-\ssub1$
+'
+
+test_expect_success 'pull into subtree okay' '
+git subtree add --prefix=copy1 sub1 
+git subtree add --prefix=copy2 sub1 
+cd copy1  create new_file_in_copy1  git commit -mAdded
new_file_in_copy1 
+cd ..  git subtree push --prefix=copy1 
+git subtree pull --prefix=copy2 | grep ^ create mode 100644
copy2/new_file_in_copy1$
+'
+
+test_expect_success 'replace outdated entry in .gitsubtree' '
+echo copy3 . sub2  .gitsubtree 
+git subtree add --prefix=copy3 sub1 
+(grep ^copy3 . sub2$ .gitsubtree  die || true) 
+grep ^copy3 . sub1$ .gitsubtree
+'
+
 test_done
-- 
1.8.1.3.605.g02339dd
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] contrib/subtree: update documentation

2013-02-15 Thread Paul Campbell
Indicate that repository and refspec are now optional on push and pull.

Add notes to add, push and pull about storing values in .gitsubtree
and their use as default values.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.txt | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..2ad9278 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -11,8 +11,8 @@ 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' 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]

@@ -72,7 +72,9 @@ add::
A new commit is created automatically, joining the imported
project's history with your own.  With '--squash', imports
only a single commit from the subproject, rather than its
-   entire history.
+   entire history. Details of the prefix are added to the
+   .gitsubtree file, where they will be used as defaults for
+   'push' and 'pull'.

 merge::
Merge recent changes up to commit into the prefix
@@ -91,13 +93,16 @@ merge::
 pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
-   repository.
+   repository. Default values for repository and refspec
+   are taken from the .gitsubtree file.

 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.
+   Default values for repository and refspec are taken
+   from the .gitsubtree file.

 split::
Extract a new, synthetic project history from the
-- 
1.8.1.3.605.g02339dd
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support

2013-02-15 Thread Paul Campbell
Hi Jonathan,

On Fri, Feb 15, 2013 at 10:56 PM, Jonathan Nieder jrnie...@gmail.com wrote:
 Hi Paul,

 Paul Campbell wrote:

 --- a/contrib/subtree/t/t7900-subtree.sh
 +++ b/contrib/subtree/t/t7900-subtree.sh
 @@ -465,4 +465,34 @@ test_expect_success 'verify one file change per commit' 
 '
 [...]
 +test_expect_success 'change in subtree is pushed okay' '
 +cd copy0  create new_file  git commit -mAdded new_file 
 +cd ..  git subtree push --prefix=copy0 21 | \

 If it possible to restrict the chdirs to subshells, that can make the
 test more resiliant to early failures without breaking later tests.

 That is:

 (
 cd copy0 
 create new_file 
 test_tick 
 git commit -m add new_file
 ) 
 git subtree push --prefix=copy0 output 21 
 grep ... output


Adding them in.

 +grep 
 ^\s\{3\}[0-9a-f]\{7\}\.\.[0-9a-f]\{7\}\s\s[0-9a-f]\{40\}\s-\ssub1$

 This might not be portable if I understand
 Documentation/CodingGuidelines correctly.


And it's ugly. But I believe it fits the don't use grep -E
condition. Unless I missed something else.

Is there was a better way to verify that the push operation succeeds
then grepping for a SHA1?

 [...]
 +(grep ^copy3 . sub2$ .gitsubtree  die || true) 

 ! grep ^copy3 . sub2\$ .gitsubtree 

 Hope that helps,
 Jonathan

Thanks. That's a much neater way to do it.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] contrib/subtree: remove contradicting use options on echo wrapper

2013-02-15 Thread Paul Campbell
On Fri, Feb 15, 2013 at 10:39 PM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 Remove redundant -n option and raw ^M in call to echo.

 Call to 'say' function, a wrapper of 'echo', passed the parameter -n, then
 included a raw ^M newline in the end of the last parameter. Yet the -n option
 is meant to suppress the addition of new line by echo.

 Signed-off-by: Paul Campbell pcampb...@kemitix.net

 I generally do not comment on comment on contrib/ material, and I am
 not familiar with subtree myself, but

 for count in $(seq 0 $total)
 do
 echo -n $count/$total^M
 ... do heavy lifting ...
 done
 echo Done  

 is an idiomatic way to implement a progress meter without scrolling
 more important message you gave earlier to the user before entering
 the loop away.  The message appears, carrige-return moves the cursor
 to the beginning of the line without going to the next line, and the
 next iteration overwrites the previous count.  Finally, the progress
 meter is overwritten with the Done message.  Alternatively you can
 wrap it up with

 echo
 echo Done

 if you want to leave the final progress 100/100 before saying Done.

 Isn't that what this piece of code trying to do?

 ---
  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 8a23f58..51146bd 100755
 --- a/contrib/subtree/git-subtree.sh
 +++ b/contrib/subtree/git-subtree.sh
 @@ -592,7 +592,7 @@ cmd_split()
   eval $grl |
   while read rev parents; do
   revcount=$(($revcount + 1))
 - say -n $revcount/$revmax ($createcount)
 
 + say $revcount/$revmax ($createcount)
   debug Processing commit: $rev
   exists=$(cache_get $rev)
   if [ -n $exists ]; then

[Apologies for resending this Junio. Forgot to hit reply all.]

Ah. I've not seen that done in shell before. In other languages I've
seen and used '\r'  for this purpose, rather than a raw ^M.

I was getting frustrated with it as my apparently braindead text
editor was converting it to a normal unix newline, which would then
keep getting picked up by git diff.

Please ignore my patch.

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: A good Git technique for referring back to original files

2013-02-12 Thread Paul Campbell
Hi Mike,

I think git-cvsimport and git-subtree could help you here.

Roughly:

# Create a git version of each SDK_subproj
git cvsimport -r upstream -d $CVSREPO1 $CVSMODULE1 -C SDK_subproj1
git cvsimport -r upstream -d $CVSREPO2 $CVSMODULE2 -C SDK_subproj2

# Create your Working_SDK
git init Working_SDK
cd Working_SDK

# Import the SDK_subprojN repos
git subtree add --prefix=subproj1 ../SDK_subproj1 upstream/master
git subtree add --prefix=subproj2 ../SDK_subproj2 upstream/master

# Edit and commit your files
# N.B. when committing don't commit to more than one subproj in a single commit

# Update from the upstream CVS as needed
git cvsimport -r upstream -d $CVSREPO1 $CVSMODULE1 -C ../SDK_subproj1
git subtree pull --prefix=subproj1 ../SDK_subproj1 upstream/master
git cvsimport -r upstream -d $CVSREPO2 $CVSMODULE2 -C ../SDK_subproj2
git subtree pull --prefix=subproj2 ../SDK_subproj2 upstream/master

# Push your changes back to SDK_subproj repos into a branch other than master
git subtree push --prefix=subproj1 ../SDK_subproj1 new-branch
git subtree push --prefix=subproj1 ../SDK_subproj2 new-branch

# Prepare patches to apply to a real CVS copy or submit upstream
(cd ../SDK_subproj1  git format-patch upstream/master..new-branch)
(cd ../SDK_subproj2  git format-patch upstream/master..new-branch)

Hope that helps.

--
Paul

On Tue, Feb 12, 2013 at 10:19 AM, MikeW mw_p...@yahoo.co.uk wrote:
 Matthieu Moy Matthieu.Moy at grenoble-inp.fr writes:


 MikeW mw_phil at yahoo.co.uk writes:

  Since git is so good at tracking file content, I wondered whether
 there was any
  technique using git that would simplify the back-referencing task.

 I'm not sure I understand the question, but if you want to add meta-data
 to Git commits (e.g. this Git commit is revision 42 in CVS repository
 foo), then have a look at git-notes. It won't give you directly
 reference to other VCS, but at least can be used as a storage
 mechanism to store these references.

 Thanks for the reply.

 In my work environment both the SDK and the original files are available
 (in an enclosing directory).

 --SDK_content
   |
   SDK_subproj1-- ...
   ||
   |content
   |
   SDK_subproj2- ...
   ||
   |content
   |
   SDK_subprojN- ...
   ||
   |content
   |
   Working_SDK ... (under git, baseline generated from subproj1..N)
|
content derived from subproj1..N


 What I had in mind was something I could run over, say, SDK_content
 (alternatively, from within Working_SDK, referring back to SDK_content)
 which would note the changed files in Working_SDK and locate the
 original files in SDK_subproj1..N letting me merge the changes back.


 --
 To unsubscribe from this list: send the line unsubscribe git in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] contrib/subtree: Store subtree sources in .gitsubtree and use for push/pull

2013-02-12 Thread Paul Campbell
Having to remember what subtree came from what source is a waste of
developer memory and doesn't transfer easily to other developers.

git subtree push/pull operations would typically be to/from the same
source that the original subtree was cloned from with git subtree add.


The repository and refspec, or commit, used in the git subtree add
operation are stored in .gitsubtree. One line each delimited by a space:
prefix repository refspec or prefix . commit.

Subsequent git subtree push/pull operations now default to the values
stored in .gitsubtree, unless overridden from the command line.

The .gitsubtree file should be tracked as part of the repo as it
describes where parts of the tree came from and can be used to update
to/from that source.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 42 +-
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 920c664..02aae30 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -488,6 +488,23 @@ ensure_clean()
  fi
 }

+subtree_memorize()
+{
+ if [ $# -eq 1 ] ; then
+ echo $dir . $@  .gitsubtree
+ elif [ $# -eq 2 ]; then
+ echo $dir $@  .gitsubtree
+ else
+ # don't know how to handle this
+ echo Not memorizing subtree: $dir $@
+ fi
+}
+
+subtree_remember()
+{
+ grep ^$dir  .gitsubtree || die Subtree $dir isn't in .gitsubtree
+}
+
 cmd_add()
 {
  if [ -e $dir ]; then
@@ -496,6 +513,7 @@ cmd_add()

  ensure_clean

+ subtree_memorize $@
  if [ $# -eq 1 ]; then
  cmd_add_commit $@
  elif [ $# -eq 2 ]; then
@@ -688,7 +706,17 @@ cmd_merge()
 cmd_pull()
 {
  ensure_clean
- git fetch $@ || exit $?
+ if [ $# -eq 0 ]; then
+ memory=($(subtree_remember))
+ echo Pulling into '$dir' from '${memory[1]}' '${memory[2]}'
+ repository=${memory[1]}
+ refspec=${memory[2]}
+ echo git fetch using:  $repository $refspec
+ git fetch $repository $refspec || exit $?
+ else
+ echo git fetch using: $@
+ git fetch $@ || exit $?
+ fi
  revs=FETCH_HEAD
  set -- $revs
  cmd_merge $@
@@ -696,12 +724,16 @@ cmd_pull()

 cmd_push()
 {
- if [ $# -ne 2 ]; then
-die You must provide repository refspec
+ repository=$1
+ refspec=$2
+ if [ $# -eq 0 ]; then
+ memo=($(subtree_remember))
+ repository=${memo[1]}
+ refspec=${memo[2]}
+ elif [ $# -ne 2 ]; then
+ die You must provide repository refspec or a prefix listed in
.gitsubtree
  fi
  if [ -e $dir ]; then
-repository=$1
-refspec=$2
 echo git push using:  $repository $refspec
 git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
  else
--
1.8.1.3.566.gaa39828


--
Paul [W] Campbell
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] contrib/subtree: Allow stale .gitsubtree entries to be replaced

2013-02-12 Thread Paul Campbell
Should .gitsubtree have a prefix listed that doesn't exist on disk, allow
it to be replaced/updated by a git subtree add.

Ideally I would have aborted the operation if there was an existing entry
and required the user to edit the .gitsubtree file by hand, but that
behaviour broke a lot of the tests.

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 02aae30..4f21902 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -490,7 +490,13 @@ ensure_clean()

 subtree_memorize()
 {
-   if [ $# -eq 1 ] ; then
+   if ( grep ^$dir  .gitsubtree ); then
+   # remove $dir from .gitsubtree - there's probably a clever way 
to
do this with sed
+   grep -v ^$dir  .gitsubtree  .gitsubtree.temp
+   rm .gitsubtree
+   mv .gitsubtree.temp .gitsubtree
+   fi
+   if [ $# -eq 1 ]; then
echo $dir . $@  .gitsubtree
elif [ $# -eq 2 ]; then
echo $dir $@  .gitsubtree
-- 
1.8.1.3.566.gaa39828
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] contrib/subtree/t: Added tests for .gitsubtree support

2013-02-12 Thread Paul Campbell
 55 add: ensure details are added to .gitsubtree
 56 push: check for a SHA1 update line
 57 pull: add a file on one subtree, push it to a branch, then pull into
another subtree containing the same branch and confirm the files match
 58 add: ensure stale .gitsubtree entry is replaced

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/t/t7900-subtree.sh | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/contrib/subtree/t/t7900-subtree.sh
b/contrib/subtree/t/t7900-subtree.sh
index bc2eeb0..5ae4584 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -505,4 +505,38 @@ test_expect_success 'verify one file change per commit' '
 ))
 '

+# return to mainline
+cd ../..
+
+# .gitsubtree
+# 55
+test_expect_success 'added repository appears in .gitsubtree' '
+git subtree add --prefix=copy0 sub1 
+grep ^copy0 \. sub1$ .gitsubtree
+'
+
+# 56
+test_expect_success 'change in subtree is pushed okay' '
+cd copy0  create new_file  git commit -mAdded new_file 
+cd ..  git subtree push --prefix=copy0 21 | \
+grep -E ^   [0-9a-f]{7}\.\.[0-9a-f]{7}  [0-9a-f]{40} - sub1$
+'
+
+# 57
+test_expect_success 'pull into subtree okay' '
+git subtree add --prefix=copy1 sub1 
+git subtree add --prefix=copy2 sub1 
+cd copy1  create new_file_in_copy1  git commit -mAdded
new_file_in_copy1 
+cd ..  git subtree push --prefix=copy1 
+git subtree pull --prefix=copy2 | grep ^ create mode 100644
copy2/new_file_in_copy1$
+'
+
+# 58
+test_expect_success 'replace outdated entry in .gitsubtree' '
+echo copy3 . sub2  .gitsubtree 
+git subtree add --prefix=copy3 sub1 
+(grep ^copy3 . sub2$ .gitsubtree  die || true) 
+grep ^copy3 . sub1$ .gitsubtree
+'
+
 test_done
-- 
1.8.1.3.566.gaa39828
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] contrib/subtree: update documentation

2013-02-12 Thread Paul Campbell
From 483a644fb40d14f2209116c45c1cb6beab11a181 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Tue, 12 Feb 2013 00:07:26 +
Subject: [PATCH 4/4] contrib/subtree: update documentation

Signed-off-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.txt | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index c5bce41..67dea3f 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -10,8 +10,8 @@ SYNOPSIS
 
 [verse]
 'git subtree' add   -P prefix commit
-'git subtree' pull  -P prefix repository refspec...
-'git subtree' push  -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]

@@ -71,7 +71,9 @@ add::
A new commit is created automatically, joining the imported
project's history with your own.  With '--squash', imports
only a single commit from the subproject, rather than its
-   entire history.
+   entire history. Details of the prefix are added to the
+   .gitsubtree file, where they will be used as defaults for
+   'push' and 'pull'.

 merge::
Merge recent changes up to commit into the prefix
@@ -90,13 +92,16 @@ merge::
 pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
-   repository.
+   repository. Default values for repository and refspec
+   are taken from the .gitsubtree file.

 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.
+   Default values for repository and refspec are taken
+   from the .gitsubtree file.

 split::
Extract a new, synthetic project history from the
-- 
1.8.1.3.566.gaa39828
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html