* Re: [PATCH 13/13] contrib/subtree: Remove --annotate
From: James Nylen @ 2013-02-18 19:46 UTC (permalink / raw)
To: greened; +Cc: Junio C Hamano, git
In-Reply-To: <87sj4t4gar.fsf@waller.obbligato.org>
On Mon, Feb 18, 2013 at 1:39 PM, <greened@obbligato.org> wrote:
> James Nylen <jnylen@gmail.com> writes:
>> - add "fancylib" as a subtree of "myprog"
>> - commit to "myprog" repo: "fancylib: don't crash as much"
>> - split these commits back out to "fancylib" main repo, and remove
>> the "fancylib: " prefix
> Should this really be a function of git-subtree? It seems like it would
> fit better in a history-rewriting command. Wouldn't rebase -i or even
> filter-branch be a better way to do this?
I'm not a git guru by any stretch, so I'm sure there are other ways to
accommodate the example use case above. I really just want to be able
to split and merge repositories while keeping meaningful commit
messages with an appropriate level of detail. Can you suggest an
alternative workflow?
> If there's no --annotate I don't see why git-subtree should have the
> --unannotate functionality.
Because they are not inverse operations - they both apply to `git
subtree split`. I think that `--annotate` would only be useful as an
option to `git subtree merge`. In that case it would be the inverse
operation of `git subtree split --unannotate`, and then I would agree
that if you remove one, you can/should remove the other.
> Again, I agree that your example is relevant, maybe even common, but I
> don't necessarily think git-subtree should be in the business of
> rewriting commit messages at all.
I'm willing to accept that. Junio seemed to be leaning that way too
in earlier emails.
> I'd appreciate more thoughts from you on this. I want to make sure we
> can support your use case.
I currently need to enable `git subtree` manually anyway, since it's
not part of the main distribution. So it's not a burden for me to
support this feature with a customized script, or learn a new way to
do it.
Thanks for your consideration of this small and nit-picky issue.
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Thomas Rast @ 2013-02-18 19:48 UTC (permalink / raw)
To: Ronan Keryell
Cc: git, Jeff King, Shawn Pearce, Jakub Narebski, Christian Couder,
Pat Thoyts, Paul Mackerras, Carlos Martín Nieto,
Thomas Gummerer, David Michael Barr, Ramkumar Ramachandra,
Jens Lehmann, Nguyen Thai Ngoc Duy
In-Reply-To: <87fw0ta4ai.fsf@an-dro.info.enstb.org>
Ronan Keryell <Ronan.Keryell@silkan.com> writes:
>>>>>> On Mon, 18 Feb 2013 18:46:05 +0100, Thomas Rast <trast@student.ethz.ch> said:
>
> Thomas> The actual programming must be done in C using pthreads
> Thomas> for obvious reasons.
>
> Are there obvious reasons OpenMP would not be enough to do the job?
>
> It looks like a trade-off between the code readability & portability
> versus the real expressiveness of what parallelism control details are
> needed.
Except for the added dependency you mean?
I'm not sure exactly what the capabilities of OpenMP are that would help
here, but most likely it would work. It wouldn't really change the
amount of work needed, though, since the main work is in shuffling
around the existing code paths to be amenable to parallel access in the
first place. A "dumb" parallelization (i.e., just locking around all
shared structures) POC yielded very little speedup because of lock
contention.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Thomas Rast @ 2013-02-18 19:53 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: git, Jeff King, Shawn Pearce, Jakub Narebski, Christian Couder,
Pat Thoyts, Paul Mackerras, Carlos Martín Nieto,
Thomas Gummerer, David Michael Barr, Jens Lehmann,
Nguyen Thai Ngoc Duy
In-Reply-To: <CALkWK0ne3GX7wA1U0-TnMqU3mTFNe12TQ_s0=2MVJ=BMs8tirA@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> * Cannot look at the diff in word-diff mode (and apply it normally).
[...]
> Also: Having to figure out, heuristically, when to actually turn it on
> might be a worthwhile feature, especially for services like GitHub.
Actually that's a pretty cute idea of its own. You could call it
--smart-diff or some such, and define its output as "whatever diff
format git thinks would be appropriate".
And given the current state of diff pipeline refactorization, the effort
is probably on the order of magnitude of a GSoC...
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: feature request
From: James Nylen @ 2013-02-18 19:54 UTC (permalink / raw)
To: Jay Townsend; +Cc: git, peff
In-Reply-To: <BLU0-SMTP2753D5BFC50D7334EDDE278E1F40@phx.gbl>
On Mon, Feb 18, 2013 at 1:52 PM, Jay Townsend <townsend891@hotmail.com> wrote:
> Hi everyone,
>
> Just would like to request a security feature to help secure peoples github
> accounts more by supporting 2 factor authentication like the yubikey more
> information can be found from this link www.yubico.com/develop/ and googles
> 2 factor authentication. Hope it gets implemented as I think it would make a
> great feature
This would most likely be something that users would set up with their
SSH client, and GitHub would have to provide support for it on their
servers as well. It shouldn't require any changes to git. Here is an
example of how this could be done:
http://www.howtogeek.com/121650/how-to-secure-ssh-with-google-authenticators-two-factor-authentication/
I like the idea, and I would probably use it if it were available.
Jeff, what do you think?
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Jonathan Nieder @ 2013-02-18 19:57 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Jeff King, Thomas Rast, git, Shawn Pearce, Jakub Narebski,
Christian Couder, Pat Thoyts, Paul Mackerras,
Carlos Martín Nieto, Thomas Gummerer, David Barr,
Jens Lehmann, Nguyen Thai Ngoc Duy
In-Reply-To: <CALkWK0kFYP4k5=237PZ3XHhxkzF-RWwwe=3+Thb_xU2Jw5tg2g@mail.gmail.com>
Ramkumar Ramachandra wrote:
> Take what I'm about to say with a pinch of salt, because I've never mentored.
>
> Mentors often don't provide much technical assistance: students should
> just post to the list with queries, or ask on #git-devel. Mentors
> serve a different purpose; their primary responsibility, in my
> opinion, is to teach the student a sustainable productive workflow.
I basically agree. One of the most important jobs of mentors is to
make sure there are people available to provide prompt technical
assistance, hopefully before the project begins.
[...]
> - using gdb efficiently to quickly understand parts?
Oh, dear. I hope not. ;-)
Thanks,
Jonathan
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Jens Lehmann @ 2013-02-18 20:01 UTC (permalink / raw)
To: Thomas Rast
Cc: Ramkumar Ramachandra, Jeff King, git, Shawn Pearce,
Jakub Narebski, Christian Couder, Pat Thoyts, Paul Mackerras,
Carlos Martín Nieto, Thomas Gummerer, David Barr,
Nguyen Thai Ngoc Duy
In-Reply-To: <87fw0txv6r.fsf@pctrast.inf.ethz.ch>
Am 18.02.2013 20:45, schrieb Thomas Rast:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> What's the harm of including something estimated to take 80% of a
>> summer?
>
> Maybe even less than 80%.
I didn't regret at all having split the summer's topic I mentored
into smaller pieces. That made it easy to post patches to the list
rather early (and IIRC some of them hit master before the end of
the GSoC).
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Jens Lehmann @ 2013-02-18 20:02 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Jeff King, Thomas Rast, git, Shawn Pearce, Jakub Narebski,
Christian Couder, Pat Thoyts, Paul Mackerras,
Carlos Martín Nieto, Thomas Gummerer, David Michael Barr,
Ramkumar Ramachandra, Nguyen Thai Ngoc Duy
In-Reply-To: <20130218193424.GC3234@elie.Belkin>
Am 18.02.2013 20:34, schrieb Jonathan Nieder:
> That said, I won't have time to mentor a project on my own. It takes
> a lot of time (or luck, to get the student that doesn't need
> mentoring).
That's my experience too. Also I think it really makes sense to have a
co-mentor so you can balance the load a bit.
> I'd be happy to help on a project with 1 or 2 co-mentors.
Same here.
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Thomas Rast @ 2013-02-18 20:03 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Jeff King, git, Shawn Pearce, Jakub Narebski, Christian Couder,
Pat Thoyts, Paul Mackerras, Carlos Martín Nieto,
Thomas Gummerer, David Barr, Jens Lehmann, Nguyen Thai Ngoc Duy
In-Reply-To: <CALkWK0kFYP4k5=237PZ3XHhxkzF-RWwwe=3+Thb_xU2Jw5tg2g@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
[...]
>>> On a related note, I don't like our Wiki. It's down half the time,
>>> and it's very badly maintained. I want to write content for our Wiki
>>> from the comfort of my editor, with version control aiding me. And I
>>> can't stand archaic WikiText.
>>
>> Agreed on all of those points. Putting the Wiki on GitHub fixes that.
>> But it means contributors need to have a GitHub account. On the other
>> hand, I think kernel.org wiki contributors need an account these days?
>> And GitHub is putting some active effort into finding and killing spammy
>> accounts, which might keep wiki spam down (I do not pay too much
>> attention to those efforts, but on kernel.org, it is mostly up to the
>> Git community to do it ourselves).
>
> No, I'm against using the GitHub Wiki for neutrality reasons. There
> is one easy way to fight spam: don't expose a web-based editing
> interface at all. It's mainly going to be maintained by the
> community, and we're all much more comfortable in our editors and git.
> We can give the regulars direct commit access and ask the rest to
> submit pull requests. Make it cost pennies, so any of us can easily
> afford it: just a cheap domain, DNS, and static HTML hosting.
I suppose since github's wiki system (gollum) is open source [1] it
wouldn't be too hard to set up another instance somewhere. Bonus points
for importing all the old data in mediawiki format first, which is also
apparently supported.
But that just shifts the point of failure from the entire github team to
one or two people who end up administering the server.
Perhaps a better solution would be to ask Scott or Peff to create a
gollum instance under git-scm.com, which they're already hosting? (It
seems people got over *that* neutrality issue quickly enough.) Push
rights could be given to interested regulars. It would then at least be
independent in name.
Footnotes:
[1] https://github.com/github/gollum
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: Rebased git-subtree changes
From: greened @ 2013-02-18 20:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vy5f2nyd7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> This looks to be of mixed quality. The earlier ones look fairly
> finished, while the later ones not so much.
>
> I am tempted to take up to 06/13 and advance them to 'next', without
> the rest.
Can you let me know what you've taken up? I have a new set with some
fixes.
-David
^ permalink raw reply
* Re: [PATCH] l10n: de.po: translate 35 new messages
From: Thomas Rast @ 2013-02-18 20:15 UTC (permalink / raw)
To: Ralf Thielow; +Cc: jk, stimming, git
In-Reply-To: <1361211754-5641-1-git-send-email-ralf.thielow@gmail.com>
Ralf Thielow <ralf.thielow@gmail.com> writes:
> #: builtin/branch.c:888
> msgid "too many branches for a rename operation"
> -msgstr ""
> +msgstr "zu viele Zweige angegeben"
You lost the "rename" bit, was that on purpose?
Other than that, ACK.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH 1/4] contrib/subtree: Store subtree sources in .gitsubtree and use for push/pull
From: greened @ 2013-02-18 20:20 UTC (permalink / raw)
To: Paul Campbell; +Cc: git, Junio C Hamano
In-Reply-To: <CALeLG_kuXdF_F4ScRLPLm5h5cV_9p=EZYrWdjoWBrO99WFyi2Q@mail.gmail.com>
Paul Campbell <pcampbell@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
^ permalink raw reply
* Re: What's cooking in git.git (Feb 2013, #05; Tue, 12)
From: greened @ 2013-02-18 20:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v621xdql8.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> * dg/subtree-fixes (2013-02-05) 6 commits
> (merged to 'next' on 2013-02-09 at 8f19ebe)
> + contrib/subtree: make the manual directory if needed
> + contrib/subtree: honor DESTDIR
> + contrib/subtree: fix synopsis
> + contrib/subtree: better error handling for 'subtree add'
> + contrib/subtree: use %B for split subject/body
> + contrib/subtree: remove test number comments
>
> contrib/subtree updates, but here are only the ones that looked
> ready to be merged to 'next'. For the remainder, they will have
> another day.
Great, I've got updates for the rest.
-David
^ permalink raw reply
* Re: feature request
From: Jeff King @ 2013-02-18 20:45 UTC (permalink / raw)
To: James Nylen; +Cc: Shawn O. Pearce, Jay Townsend, git
In-Reply-To: <CABVa4NgsbeNGS2F2jQJ5d9bDcFb4=oEVrBg_-n2eYjwnfQzMqA@mail.gmail.com>
On Mon, Feb 18, 2013 at 02:54:30PM -0500, James Nylen wrote:
> > Just would like to request a security feature to help secure peoples github
> > accounts more by supporting 2 factor authentication like the yubikey more
> > information can be found from this link www.yubico.com/develop/ and googles
> > 2 factor authentication. Hope it gets implemented as I think it would make a
> > great feature
>
> This would most likely be something that users would set up with their
> SSH client, and GitHub would have to provide support for it on their
> servers as well. It shouldn't require any changes to git. Here is an
> example of how this could be done:
>
> http://www.howtogeek.com/121650/how-to-secure-ssh-with-google-authenticators-two-factor-authentication/
>
> I like the idea, and I would probably use it if it were available.
> Jeff, what do you think?
When you are talking about something like GitHub, there are a lot of
times and methods to authenticate: logging into the web service, using
an ssh key for git-over-ssh, using a password for git-over-http, tokens
for API access, and probably more that I can't think of right now.
Logging into the web page can add 2-factor auth pretty easily, since
it's a web form.
Git over ssh can also do so without changes to git, because we rely on
ssh to do all of the interactive authentication. However, I wonder how
many people would be that interested in it, as key auth already provides
some degree of two factor protection, assuming you protect your key with
a passphrase (the threat model is different, of course, because the two
factors are happening on the client, and do not involve the server at
all).
Git over http _would_ need git client support, since it asks the user
for the password directly. Or at the very least some clever encoding
scheme where your password becomes "<real_password>:<2FA_pass>" or
something. But I'm not sure that people want raw two-factor
authentication for pushes. It's a giant pain, and people were recently
happy to move to password-less pushes via credential helpers; this would
move in the opposite direction.
The thing that makes 2FA usable in the web browser setting is that you
authenticate only occasionally, and get a token (i.e., a cookie) from
the server that lets you have a longer session without re-authenticating.
I suspect a usable 2FA scheme for http pushes would involve a special
credential helper that did the 2FA auth to receive a cookie on the first
use, cached the cookie, and then provided it for subsequent auth
requests. That would not necessarily involve changing git, but it would
mean writing the appropriate helper (and the server side to match). I
seem to recall Shawn mentioning that Google does something like this
internally, but I don't know the details[1].
So yes. It's an interesting direction to go, but I think there's a fair
bit of work, and it needs to be broken down into how specific services
will interact with it. The first step would probably be securing the web
login with it, since that is the easiest one to do, and also the most
powerful interface (the other ones just let you push or fetch code; the
web interface lets you delete repos, change passwords, access billing,
etc).
But that first step is something that would happen entirely at GitHub,
with no client support necessary. We don't have schedules or plans, and
we don't promise features. So I can neither confirm nor deny that people
are working on it right now.
-Peff
[1] I don't know if Google's system is based on the Google Authenticator
system. But it would be great if there could be an open,
standards-based system for doing 2FA+cookie authentication like
this. I'd hate to have "the GitHub credential helper" and "the
Google credential helper". I'm not well-versed enough in the area to
know what's feasible and what the standards are.
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Ramkumar Ramachandra @ 2013-02-18 20:44 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Jeff King, Thomas Rast, git, Shawn Pearce, Jakub Narebski,
Christian Couder, Pat Thoyts, Paul Mackerras,
Carlos Martín Nieto, Thomas Gummerer, David Barr,
Jens Lehmann, Nguyen Thai Ngoc Duy
In-Reply-To: <20130218193424.GC3234@elie.Belkin>
Jonathan Nieder wrote:
> Hi,
>
> Jeff King wrote:
>
>> I will do it again, if people feel strongly about Git being a part of
>> it. However, I have gotten a little soured on the GSoC experience. Not
>> because of anything Google has done; it's a good idea, and I think they
>> do a fine of administering the program. But I have noticed that the work
>> that comes out of GSoC the last few years has quite often not been
>> merged, or not made a big impact in the codebase, and nor have the
>> participants necessarily stuck around.
>
> I think that if we can commit enough time to mentor well it's
> worthwhile. Even such a negative result is useful, since it can teach
> us how good or poor we are at bringing new contributors in and what
> parts of that process need more work.
The point is that we must be willing to spend time learning what went
wrong the previous summer, and how to improve upon it. There's no
point in doing a lather-rinse-repeat after many consecutive failures.
> Some potential projects (unfiltered --- please take them with a grain
> of salt):
>
> - cross-compilable git
Why, exactly? Git for embedded devices?
> - incorporation of the cgit web interface, or formalizing a subset of
> libgit.a to export as a stable library to it
I didn't understand this: you want cgit in-tree?
> - moving forward on a project that was the subject of a previous
> gsoc project: line-level logging, "rebase --interactive" on top of
> sequencer, usable svn remote helper
I can't see a roadmap for gradually phasing out `rebase -i` as more
and more of its functionality is built into the sequencer. Would you
start by using `cherry-pick --continue` in the special case of
consecutive `pick` or `revert` operations (yuck)? The sequencer
currently has a continuation logic that we can leverage, but how will
it call out to shell functions to do specific tasks (like `fixup`,
which is not yet implemented)? Really, the only way I see is to
duplicate the functionality of `rebase -i` in C, and throw away the
shell script when we're sure we're done.
For usable svn remote helper, the major TODO is a git -> svn bridge.
My previous effort (which was a long time) was stalled because we
needed a way to persist blobs of text referenced by marks, and
retrieve them on demand. Building this bridge is hard enough already,
and I think we should just focus on an independent git -> svn bridge
to put into contrib/svn-fi as a deliverable. It doesn't have to have
anything to do with remote helpers at all.
> - drag-and-drop cherry-pick in gitk
You expect someone to write Tcl/Tk today? Do a `git log gitk-git/`
and tell me how many people are writing it.
> - a sub-library of code shared with libgit2 (might be hard because
> our notions of strings are different :().
>
> - assimilating the distro builds: "make deb-pkg", "make rpm-pkg",
> etc along the same lines as the linux kernel's script/package/,
> to help people get recent git installed when they want it
Overkill. I just symlink to bin-wrapper/git from a place high up in
my $PATH. If anything, we should be making it easier for ourselves to
run different versions of git right from $HOME, much like rbenv.
System-wide installs are taken care of by the distribution package
managers, and I doubt they need any help from us.
> - collaborative notes editing: fix the default notes refspec,
> make sure the "notes pull" workflow works well and is documented
> well, offer an easy way to hide private notes after the fact
> without disrupting public history
I personally don't care for notes much, because I can't see practical
usecases. I'd much rather fix something that's much more widely used
and broken: submodules.
^ permalink raw reply
* Re: [PATCH 1/4] contrib/subtree: Store subtree sources in .gitsubtree and use for push/pull
From: Paul Campbell @ 2013-02-18 20:50 UTC (permalink / raw)
To: greened; +Cc: git, Junio C Hamano
In-Reply-To: <87bobh4bmz.fsf@waller.obbligato.org>
On Mon, Feb 18, 2013 at 8:20 PM, <greened@obbligato.org> wrote:
> Paul Campbell <pcampbell@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
^ permalink raw reply
* Re: Git Merge 2013 Conference, Berlin
From: Thomas Rast @ 2013-02-18 20:52 UTC (permalink / raw)
To: Scott Chacon; +Cc: git list
In-Reply-To: <CAP2yMaJyCi5tvFZ5hVpVULR=oKgfc-b0zb8baxFDhNqmu+W_Bg@mail.gmail.com>
Scott Chacon <schacon@gmail.com> writes:
> We're starting off in Berlin, May 9-11th. GitHub has secured
> conference space at the Radisson Blu Berlin for those days. I have a
> smaller room for the first day so we can get 30-40 Git implementors
> together to talk about the future of Git and whatnot.
[...]
> http://git-merge.com/
So this has been fairly quiet -- is anyone else coming? :-)
You should probably talk to Radisson Blu about their cancellation
conditions, so as to avoid some nasty arguments. Their "Features" say
Cancellations free of charge can be made until 4 weeks prior to
arrival date.
while their "Hotel Policy" says
Cancellation Policy:
- Cancel by 6:00 PM hotel time on May 09 2013 = no penalty.
which is clearly contradictory.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: Google Summer of Code 2013 (GSoC13)
From: Jeff King @ 2013-02-18 20:55 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Thomas Rast, git, Shawn Pearce, Jakub Narebski, Christian Couder,
Pat Thoyts, Paul Mackerras, Carlos Martín Nieto,
Thomas Gummerer, David Michael Barr, Ramkumar Ramachandra,
Jens Lehmann, Nguyen Thai Ngoc Duy
In-Reply-To: <20130218193424.GC3234@elie.Belkin>
On Mon, Feb 18, 2013 at 11:34:24AM -0800, Jonathan Nieder wrote:
> Some potential projects (unfiltered --- please take them with a grain
> of salt):
> [...]
> - collaborative notes editing: fix the default notes refspec,
> make sure the "notes pull" workflow works well and is documented
> well, offer an easy way to hide private notes after the fact
> without disrupting public history
I know you said a grain of salt, so please don't feel like I'm beating
up on your idea. I'm picking this one because I think it has some
characteristics of projects that have not gone well in the past, so it's
a good illustrative example.
IMHO, this is the type of project that is likely to fail, because most
of the work is not technical at all, but political. Changing the default
refspecs is a few lines of code. But the hard part is figuring out where
they should go, the implications of doing so, and how people are going
to react. And it's intimately tied to how we have considered refactoring
the default ref namespaces, which is a messy discussion with a lot of
different options (and implications, and backwards compatibility issues,
etc). Plans need to be laid for deprecating old things, and handling the
transition to the new thing. Lines need to be drawn about what is in the
project and what isn't.
Bringing a project like that to completion is going to involve a lot of
community involvement. And that's the thing students are historically
the worst at it. I think it's _also_ the most valuable thing they can
learn. But I think it doesn't make for a very gentle introduction to
open source.
Again, just my two cents. I don't want to dissuade anybody from this
project in particular, or this style of project. I'm more trying to
bring up discussion on how and why projects fail.
-Peff
^ permalink raw reply
* Subtree Fixes Updates
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen
Here are the subtree fixes I've got with changes in response to
feedback.
^ permalink raw reply
* [PATCH 1/8] contrib/subtree: Use %B for split subject/body
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Use %B to format the commit message and body to avoid an extra newline
if a commit only has a subject line.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/t/t7900-subtree.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 80d3399..8dd6a82 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -226,6 +226,17 @@ test_expect_success 'check hash of split' '
check_equal ''"$new_hash"'' "$subdir_hash"
'
+test_expect_success 'check hash of split' '
+ spl1=$(git subtree split --prefix subdir) &&
+ undo &&
+ git subtree split --prefix subdir --branch splitbr1test &&
+ check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
+ git checkout splitbr1test &&
+ new_hash=$(git rev-parse HEAD~2) &&
+ git checkout mainline &&
+ check_equal ''"$new_hash"'' "$subdir_hash"
+'
+
test_expect_success 'check split with --branch for an existing branch' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/8] contrib/subtree: Fix whitespaces
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Previous code does not fulfill Git's whitespace policy.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 68 ++++----
contrib/subtree/git-subtree.txt | 42 ++---
contrib/subtree/t/t7900-subtree.sh | 326 +++++++++++++++++-------------------
3 files changed, 206 insertions(+), 230 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..6c3929b 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -5,7 +5,7 @@
# Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>
#
if [ $# -eq 0 ]; then
- set -- -h
+ set -- -h
fi
OPTS_SPEC="\
git subtree add --prefix=<prefix> <commit>
@@ -111,9 +111,9 @@ if [ -z "$prefix" ]; then
fi
case "$command" in
- add) [ -e "$prefix" ] &&
+ add) [ -e "$prefix" ] &&
die "prefix '$prefix' already exists." ;;
- *) [ -e "$prefix" ] ||
+ *) [ -e "$prefix" ] ||
die "'$prefix' does not exist; use 'git subtree add'" ;;
esac
@@ -182,8 +182,8 @@ cache_set()
oldrev="$1"
newrev="$2"
if [ "$oldrev" != "latest_old" \
- -a "$oldrev" != "latest_new" \
- -a -e "$cachedir/$oldrev" ]; then
+ -a "$oldrev" != "latest_new" \
+ -a -e "$cachedir/$oldrev" ]; then
die "cache for $oldrev already exists!"
fi
echo "$newrev" >"$cachedir/$oldrev"
@@ -305,7 +305,7 @@ copy_commit()
read GIT_COMMITTER_NAME
read GIT_COMMITTER_EMAIL
read GIT_COMMITTER_DATE
- export GIT_AUTHOR_NAME \
+ export GIT_AUTHOR_NAME \
GIT_AUTHOR_EMAIL \
GIT_AUTHOR_DATE \
GIT_COMMITTER_NAME \
@@ -328,7 +328,7 @@ add_msg()
fi
cat <<-EOF
$commit_message
-
+
git-subtree-dir: $dir
git-subtree-mainline: $latest_old
git-subtree-split: $latest_new
@@ -356,7 +356,7 @@ rejoin_msg()
fi
cat <<-EOF
$commit_message
-
+
git-subtree-dir: $dir
git-subtree-mainline: $latest_old
git-subtree-split: $latest_new
@@ -369,7 +369,7 @@ squash_msg()
oldsub="$2"
newsub="$3"
newsub_short=$(git rev-parse --short "$newsub")
-
+
if [ -n "$oldsub" ]; then
oldsub_short=$(git rev-parse --short "$oldsub")
echo "Squashed '$dir/' changes from $oldsub_short..$newsub_short"
@@ -379,7 +379,7 @@ squash_msg()
else
echo "Squashed '$dir/' content from commit $newsub_short"
fi
-
+
echo
echo "git-subtree-dir: $dir"
echo "git-subtree-split: $newsub"
@@ -428,7 +428,7 @@ new_squash_commit()
newsub="$3"
tree=$(toptree_for_commit $newsub) || exit $?
if [ -n "$old" ]; then
- squash_msg "$dir" "$oldsub" "$newsub" |
+ squash_msg "$dir" "$oldsub" "$newsub" |
git commit-tree "$tree" -p "$old" || exit $?
else
squash_msg "$dir" "" "$newsub" |
@@ -456,7 +456,7 @@ copy_or_skip()
else
nonidentical="$parent"
fi
-
+
# sometimes both old parents map to the same newparent;
# eliminate duplicates
is_new=1
@@ -471,7 +471,7 @@ copy_or_skip()
p="$p -p $parent"
fi
done
-
+
if [ -n "$identical" ]; then
echo $identical
else
@@ -496,7 +496,7 @@ cmd_add()
fi
ensure_clean
-
+
if [ $# -eq 1 ]; then
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
die "'$1' does not refer to a commit"
@@ -513,8 +513,8 @@ cmd_add()
"cmd_add_repository" "$@"
else
- say "error: parameters were '$@'"
- die "Provide either a commit or a repository and commit."
+ say "error: parameters were '$@'"
+ die "Provide either a commit or a repository and commit."
fi
}
@@ -534,19 +534,19 @@ cmd_add_commit()
revs=$(git rev-parse $default --revs-only "$@") || exit $?
set -- $revs
rev="$1"
-
+
debug "Adding $dir as '$rev'..."
git read-tree --prefix="$dir" $rev || exit $?
git checkout -- "$dir" || exit $?
tree=$(git write-tree) || exit $?
-
+
headrev=$(git rev-parse HEAD) || exit $?
if [ -n "$headrev" -a "$headrev" != "$rev" ]; then
headp="-p $headrev"
else
headp=
fi
-
+
if [ -n "$squash" ]; then
rev=$(new_squash_commit "" "" "$rev") || exit $?
commit=$(add_squashed_msg "$rev" "$dir" |
@@ -556,7 +556,7 @@ cmd_add_commit()
git commit-tree $tree $headp -p "$rev") || exit $?
fi
git reset "$commit" || exit $?
-
+
say "Added dir '$dir'"
}
@@ -564,7 +564,7 @@ cmd_split()
{
debug "Splitting $dir..."
cache_setup || exit $?
-
+
if [ -n "$onto" ]; then
debug "Reading history for --onto=$onto..."
git rev-list $onto |
@@ -575,13 +575,13 @@ cmd_split()
cache_set $rev $rev
done
fi
-
+
if [ -n "$ignore_joins" ]; then
unrevs=
else
unrevs="$(find_existing_splits "$dir" "$revs")"
fi
-
+
# We can't restrict rev-list to only $dir here, because some of our
# parents have the $dir contents the root, and those won't match.
# (and rev-list --follow doesn't seem to solve this)
@@ -603,12 +603,12 @@ cmd_split()
debug " parents: $parents"
newparents=$(cache_get $parents)
debug " newparents: $newparents"
-
+
tree=$(subtree_for_commit $rev "$dir")
debug " tree is: $tree"
check_parents $parents
-
+
# ugly. is there no better way to tell if this is a subtree
# vs. a mainline commit? Does it matter?
if [ -z $tree ]; then
@@ -629,7 +629,7 @@ cmd_split()
if [ -z "$latest_new" ]; then
die "No new revisions were found"
fi
-
+
if [ -n "$rejoin" ]; then
debug "Merging split branch into HEAD..."
latest_old=$(cache_get latest_old)
@@ -657,13 +657,13 @@ cmd_merge()
{
revs=$(git rev-parse $default --revs-only "$@") || exit $?
ensure_clean
-
+
set -- $revs
if [ $# -ne 1 ]; then
die "You must provide exactly one revision. Got: '$revs'"
fi
rev="$1"
-
+
if [ -n "$squash" ]; then
first_split="$(find_latest_squash "$dir")"
if [ -z "$first_split" ]; then
@@ -709,15 +709,15 @@ cmd_pull()
cmd_push()
{
if [ $# -ne 2 ]; then
- die "You must provide <repository> <refspec>"
+ die "You must provide <repository> <refspec>"
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
+ repository=$1
+ refspec=$2
+ 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
}
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..aae9d19 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -87,15 +87,15 @@ merge::
go back in time from v2.5 to v2.4, for example. If your
merge introduces a conflict, you can resolve it in the
usual ways.
-
+
pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
repository.
-
+
push::
Does a 'split' (see below) using the <prefix> supplied
- and then does a 'git push' to push the result to the
+ 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.
@@ -107,19 +107,19 @@ split::
contents of <prefix> at the root of the project instead
of in a subdirectory. Thus, the newly created history
is suitable for export as a separate git repository.
-
+
After splitting successfully, a single commit id is
printed to stdout. This corresponds to the HEAD of the
newly created tree, which you can manipulate however you
want.
-
+
Repeated splits of exactly the same history are
guaranteed to be identical (ie. to produce the same
commit ids). Because of this, if you add new commits
and then re-split, the new commits will be attached as
commits on top of the history you generated last time,
so 'git merge' and friends will work as expected.
-
+
Note that if you use '--squash' when you merge, you
should usually not just '--rejoin' when you split.
@@ -156,26 +156,26 @@ OPTIONS FOR add, merge, push, pull
project, produce only a single commit that contains all
the differences you want to merge, and then merge that
new commit into your project.
-
+
Using this option helps to reduce log clutter. People
rarely want to see every change that happened between
v1.0 and v1.1 of the library they're using, since none of the
interim versions were ever included in their application.
-
+
Using '--squash' also helps avoid problems when the same
subproject is included multiple times in the same
project, or is removed and then re-added. In such a
case, it doesn't make sense to combine the histories
anyway, since it's unclear which part of the history
belongs to which subtree.
-
+
Furthermore, with '--squash', you can switch back and
forth between different versions of a subtree, rather
than strictly forward. 'git subtree merge --squash'
always adjusts the subtree to match the exactly
specified commit, even if getting to that commit would
require undoing some changes that were added earlier.
-
+
Whether or not you use '--squash', changes made in your
local repository remain intact and can be later split
and send upstream to the subproject.
@@ -191,11 +191,11 @@ OPTIONS FOR split
commits with the same commit message, but possibly
different content, from the original commits, this can help
to differentiate them and avoid confusion.
-
+
Whenever you split, you need to use the same
<annotation>, or else you don't have a guarantee that
the new re-created history will be identical to the old
- one. That will prevent merging from working correctly.
+ one. That will prevent merging from working correctly.
git subtree tries to make it work anyway, particularly
if you use --rejoin, but it may not always be effective.
@@ -204,8 +204,8 @@ OPTIONS FOR split
This option is only valid for the split command.
After generating the synthetic history, create a new
- branch called <branch> that contains the new history.
- This is suitable for immediate pushing upstream.
+ branch called <branch> that contains the new history.
+ This is suitable for immediate pushing upstream.
<branch> must not already exist.
--ignore-joins::
@@ -228,7 +228,7 @@ OPTIONS FOR split
revision of the subproject's history that was imported
into your project, and git subtree will attempt to build
its history from there.
-
+
If you used 'git subtree add', you should never need
this option.
@@ -239,18 +239,18 @@ OPTIONS FOR split
history back into your main project. That way, future
splits can search only the part of history that has
been added since the most recent --rejoin.
-
+
If your split commits end up merged into the upstream
subproject, and then you want to get the latest upstream
version, this will allow git's merge algorithm to more
intelligently avoid conflicts (since it knows these
synthetic commits are already part of the upstream
repository).
-
+
Unfortunately, using this option results in 'git log'
showing an extra copy of every new commit that was
created (the original, and the synthetic one).
-
+
If you do all your merges with '--squash', don't use
'--rejoin' when you split, because you don't want the
subproject's history to be part of your project anyway.
@@ -285,7 +285,7 @@ First, get your own copy of the git.git repository:
$ cd test-git
gitweb (commit 1130ef3) was merged into git as of commit
-0a8f4f0, after which it was no longer maintained separately.
+0a8f4f0, after which it was no longer maintained separately.
But imagine it had been maintained separately, and we wanted to
extract git's changes to gitweb since that time, to share with
the upstream. You could do this:
@@ -295,7 +295,7 @@ the upstream. You could do this:
--branch gitweb-latest
$ gitk gitweb-latest
$ git push git@github.com:whatever/gitweb.git gitweb-latest:master
-
+
(We use '0a8f4f0^..' because that means "all the changes from
0a8f4f0 to the current version, including 0a8f4f0 itself.")
@@ -329,7 +329,7 @@ And fast forward again:
$ git subtree merge --prefix=gitweb --squash gitweb-latest
And notice that your change is still intact:
-
+
$ ls -l gitweb/myfile
And you can split it out and look at your changes versus
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 8dd6a82..c7f9e1a 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -23,7 +23,7 @@ check_equal()
{
test_debug 'echo'
test_debug "echo \"check a:\" \"{$1}\""
- test_debug "echo \" b:\" \"{$2}\""
+ test_debug "echo \" b:\" \"{$2}\""
if [ "$1" = "$2" ]; then
return 0
else
@@ -61,17 +61,17 @@ last_commit_message()
}
test_expect_success 'init subproj' '
- test_create_repo subproj
+ test_create_repo subproj
'
# To the subproject!
cd subproj
test_expect_success 'add sub1' '
- create sub1 &&
- git commit -m "sub1" &&
- git branch sub1 &&
- git branch -m master subproj
+ create sub1 &&
+ git commit -m "sub1" &&
+ git branch sub1 &&
+ git branch -m master subproj
'
# Save this hash for testing later.
@@ -79,133 +79,133 @@ test_expect_success 'add sub1' '
subdir_hash=`git rev-parse HEAD`
test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2" &&
- git branch sub2
+ create sub2 &&
+ git commit -m "sub2" &&
+ git branch sub2
'
test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3" &&
- git branch sub3
+ create sub3 &&
+ git commit -m "sub3" &&
+ git branch sub3
'
# Back to mainline
cd ..
test_expect_success 'add main4' '
- create main4 &&
- git commit -m "main4" &&
- git branch -m master mainline &&
- git branch subdir
+ create main4 &&
+ git commit -m "main4" &&
+ git branch -m master mainline &&
+ git branch subdir
'
test_expect_success 'fetch subproj history' '
- git fetch ./subproj sub1 &&
- git branch sub1 FETCH_HEAD
+ git fetch ./subproj sub1 &&
+ git branch sub1 FETCH_HEAD
'
test_expect_success 'no subtree exists in main tree' '
- test_must_fail git subtree merge --prefix=subdir sub1
+ test_must_fail git subtree merge --prefix=subdir sub1
'
test_expect_success 'no pull from non-existant subtree' '
- test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+ test_must_fail git subtree pull --prefix=subdir ./subproj sub1
'
test_expect_success 'check if --message works for add' '
- git subtree add --prefix=subdir --message="Added subproject" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject" &&
- undo
+ git subtree add --prefix=subdir --message="Added subproject" sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject" &&
+ undo
'
test_expect_success 'check if --message works as -m and --prefix as -P' '
- git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
- undo
+ git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
+ undo
'
test_expect_success 'check if --message works with squash too' '
- git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
- undo
+ git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
+ undo
'
test_expect_success 'add subproj to mainline' '
- git subtree add --prefix=subdir/ FETCH_HEAD &&
- check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
+ git subtree add --prefix=subdir/ FETCH_HEAD &&
+ check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
'
# this shouldn't actually do anything, since FETCH_HEAD is already a parent
test_expect_success 'merge fetched subproj' '
- git merge -m "merge -s -ours" -s ours FETCH_HEAD
+ git merge -m "merge -s -ours" -s ours FETCH_HEAD
'
test_expect_success 'add main-sub5' '
- create subdir/main-sub5 &&
- git commit -m "main-sub5"
+ create subdir/main-sub5 &&
+ git commit -m "subproj: main-sub5"
'
test_expect_success 'add main6' '
- create main6 &&
- git commit -m "main6 boring"
+ create main6 &&
+ git commit -m "main6 boring"
'
test_expect_success 'add main-sub7' '
- create subdir/main-sub7 &&
- git commit -m "main-sub7"
+ create subdir/main-sub7 &&
+ git commit -m "subproj: main-sub7"
'
test_expect_success 'fetch new subproj history' '
- git fetch ./subproj sub2 &&
- git branch sub2 FETCH_HEAD
+ git fetch ./subproj sub2 &&
+ git branch sub2 FETCH_HEAD
'
test_expect_success 'check if --message works for merge' '
- git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
- undo
+ git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
+ check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
+ undo
'
test_expect_success 'check if --message for merge works with squash too' '
- git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
- undo
+ git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
+ check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
+ undo
'
test_expect_success 'merge new subproj history into subdir' '
- git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split &&
- check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git branch pre-split &&
+ check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
'
test_expect_success 'Check that prefix argument is required for split' '
- echo "You must provide the --prefix option." > expected &&
- test_must_fail git subtree split > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ echo "You must provide the --prefix option." > expected &&
+ test_must_fail git subtree split > actual 2>&1 &&
+ test_debug "echo -n expected: " &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual &&
+ rm -f expected actual
'
test_expect_success 'Check that the <prefix> exists for a split' '
- echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
- test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual
-# rm -f expected actual
+ echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
+ test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
+ test_debug "echo -n expected: " &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+ rm -f expected actual
'
test_expect_success 'check if --message works for split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- git branch spl1 "$spl1" &&
- check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
- undo
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ git branch spl1 "$spl1" &&
+ check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
+ undo
'
test_expect_success 'check split with --branch' '
@@ -215,92 +215,70 @@ test_expect_success 'check split with --branch' '
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
'
-test_expect_success 'check hash of split' '
- spl1=$(git subtree split --prefix subdir) &&
- undo &&
- git subtree split --prefix subdir --branch splitbr1test &&
- check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
- git checkout splitbr1test &&
- new_hash=$(git rev-parse HEAD~2) &&
- git checkout mainline &&
- check_equal ''"$new_hash"'' "$subdir_hash"
-'
-
-test_expect_success 'check hash of split' '
- spl1=$(git subtree split --prefix subdir) &&
- undo &&
- git subtree split --prefix subdir --branch splitbr1test &&
- check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
- git checkout splitbr1test &&
- new_hash=$(git rev-parse HEAD~2) &&
- git checkout mainline &&
- check_equal ''"$new_hash"'' "$subdir_hash"
-'
-
test_expect_success 'check split with --branch for an existing branch' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git branch splitbr2 sub1 &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
- check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ undo &&
+ git branch splitbr2 sub1 &&
+ git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
+ check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
'
test_expect_success 'check split with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
+ test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
'
test_expect_success 'check split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
- check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ undo &&
+ git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
+ check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
'
test_expect_success 'add main-sub8' '
- create subdir/main-sub8 &&
- git commit -m "main-sub8"
+ create subdir/main-sub8 &&
+ git commit -m "main-sub8"
'
# To the subproject!
cd ./subproj
test_expect_success 'merge split into subproj' '
- git fetch .. spl1 &&
- git branch spl1 FETCH_HEAD &&
- git merge FETCH_HEAD
+ git fetch .. spl1 &&
+ git branch spl1 FETCH_HEAD &&
+ git merge FETCH_HEAD
'
test_expect_success 'add sub9' '
- create sub9 &&
- git commit -m "sub9"
+ create sub9 &&
+ git commit -m "sub9"
'
# Back to mainline
cd ..
test_expect_success 'split for sub8' '
- split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
- git branch split2 "$split2"
+ split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
+ git branch split2 "$split2"
'
test_expect_success 'add main-sub10' '
- create subdir/main-sub10 &&
- git commit -m "main-sub10"
+ create subdir/main-sub10 &&
+ git commit -m "main-sub10"
'
test_expect_success 'split for sub10' '
- spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
- git branch spl3 "$spl3"
+ spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
+ git branch spl3 "$spl3"
'
# To the subproject!
cd ./subproj
test_expect_success 'merge split into subproj' '
- git fetch .. spl3 &&
- git branch spl3 FETCH_HEAD &&
- git merge FETCH_HEAD &&
- git branch subproj-merge-spl3
+ git fetch .. spl3 &&
+ git branch spl3 FETCH_HEAD &&
+ git merge FETCH_HEAD &&
+ git branch subproj-merge-spl3
'
chkm="main4 main6"
@@ -310,44 +288,44 @@ chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$subfiles" "$chkms $chks"
+ subfiles=''"$(git ls-files | fixnl)"'' &&
+ check_equal "$subfiles" "$chkms $chks"
'
test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" "$chkms $chks"
+ allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
+ check_equal "$allchanges" "$chkms $chks"
'
# Back to mainline
cd ..
test_expect_success 'pull from subproj' '
- git fetch ./subproj subproj-merge-spl3 &&
- git branch subproj-merge-spl3 FETCH_HEAD &&
- git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
+ git fetch ./subproj subproj-merge-spl3 &&
+ git branch subproj-merge-spl3 FETCH_HEAD &&
+ git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
'
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ mainfiles=''"$(git ls-files | fixnl)"'' &&
+ check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
test_expect_success 'make sure each filename changed exactly once in the entire history' '
- # main-sub?? and /subdir/main-sub?? both change, because those are the
- # changes that were split into their own history. And subdir/sub?? never
- # change, since they were *only* changed in the subtree branch.
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
+ # main-sub?? and /subdir/main-sub?? both change, because those are the
+ # changes that were split into their own history. And subdir/sub?? never
+ # change, since they were *only* changed in the subtree branch.
+ allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
+ check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
'
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
+ check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
'
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
- # They are meaningless to subproj since one side of the merge refers to the mainline
- check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
+ # They are meaningless to subproj since one side of the merge refers to the mainline
+ check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
'
# prepare second pair of repositories
@@ -355,27 +333,27 @@ mkdir test2
cd test2
test_expect_success 'init main' '
- test_create_repo main
+ test_create_repo main
'
cd main
test_expect_success 'add main1' '
- create main1 &&
- git commit -m "main1"
+ create main1 &&
+ git commit -m "main1"
'
cd ..
test_expect_success 'init sub' '
- test_create_repo sub
+ test_create_repo sub
'
cd sub
test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2"
+ create sub2 &&
+ git commit -m "sub2"
'
cd ../main
@@ -383,33 +361,33 @@ cd ../main
# check if split can find proper base without --onto
test_expect_success 'add sub as subdir in main' '
- git fetch ../sub master &&
- git branch sub2 FETCH_HEAD &&
- git subtree add --prefix subdir sub2
+ git fetch ../sub master &&
+ git branch sub2 FETCH_HEAD &&
+ git subtree add --prefix subdir sub2
'
cd ../sub
test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3"
+ create sub3 &&
+ git commit -m "sub3"
'
cd ../main
test_expect_success 'merge from sub' '
- git fetch ../sub master &&
- git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix subdir sub3
+ git fetch ../sub master &&
+ git branch sub3 FETCH_HEAD &&
+ git subtree merge --prefix subdir sub3
'
test_expect_success 'add main-sub4' '
- create subdir/main-sub4 &&
- git commit -m "main-sub4"
+ create subdir/main-sub4 &&
+ git commit -m "main-sub4"
'
test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix subdir --branch mainsub4
+ git subtree split --prefix subdir --branch mainsub4
'
# at this point, the new commit parent should be sub3 if it is not,
@@ -418,21 +396,21 @@ test_expect_success 'split for main-sub4 without --onto' '
# itself)
test_expect_success 'check that the commit parent is sub3' '
- check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
+ check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
'
test_expect_success 'add main-sub5' '
- mkdir subdir2 &&
- create subdir2/main-sub5 &&
- git commit -m "main-sub5"
+ mkdir subdir2 &&
+ create subdir2/main-sub5 &&
+ git commit -m "main-sub5"
'
test_expect_success 'split for main-sub5 without --onto' '
- # also test that we still can split out an entirely new subtree
- # if the parent of the first commit in the tree is not empty,
- # then the new subtree has accidently been attached to something
- git subtree split --prefix subdir2 --branch mainsub5 &&
- check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
+ # also test that we still can split out an entirely new subtree
+ # if the parent of the first commit in the tree is not empty,
+ # then the new subtree has accidently been attached to something
+ git subtree split --prefix subdir2 --branch mainsub5 &&
+ check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
'
# make sure no patch changes more than one file. The original set of commits
@@ -460,20 +438,18 @@ joincommits()
}
test_expect_success 'verify one file change per commit' '
- x= &&
- list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
-# test_debug "echo HERE" &&
-# test_debug "echo ''"$list"''" &&
- (git log --pretty=format:'"'commit: %H'"' | joincommits |
- ( while read commit a b; do
- test_debug "echo Verifying commit "''"$commit"''
- test_debug "echo a: "''"$a"''
- test_debug "echo b: "''"$b"''
- check_equal "$b" ""
- x=1
- done
- check_equal "$x" 1
- ))
+ x= &&
+ list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
+ (git log --pretty=format:'"'commit: %H'"' | joincommits |
+ (while read commit a b; do
+ test_debug "echo Verifying commit "''"$commit"''
+ test_debug "echo a: "''"$a"''
+ test_debug "echo b: "''"$b"''
+ check_equal "$b" ""
+ x=1
+ done
+ check_equal "$x" 1
+ ))
'
test_done
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3/8] contrib/subtree: Ignore testing directory
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/.gitignore | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/contrib/subtree/.gitignore b/contrib/subtree/.gitignore
index 91360a3..59aeeb4 100644
--- a/contrib/subtree/.gitignore
+++ b/contrib/subtree/.gitignore
@@ -1,6 +1,5 @@
*~
git-subtree
-git-subtree.xml
git-subtree.1
-mainline
-subproj
+git-subtree.xml
+t/trash\ directory.*
--
1.7.10.4
^ permalink raw reply related
* [PATCH 4/8] contrib/subtree: Code cleaning and refactoring
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Mostly prepare for the later tests refactoring.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/t/t7900-subtree.sh | 256 +++++++++++++++++++-----------------
1 file changed, 136 insertions(+), 120 deletions(-)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index c7f9e1a..3787408 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -4,7 +4,7 @@
#
test_description='Basic porcelain support for subtrees
-This test verifies the basic operation of the merge, pull, add
+This test verifies the basic operation of the add, pull, merge
and split subcommands of git subtree.
'
@@ -18,19 +18,6 @@ create()
git add "$1"
}
-
-check_equal()
-{
- test_debug 'echo'
- test_debug "echo \"check a:\" \"{$1}\""
- test_debug "echo \" b:\" \"{$2}\""
- if [ "$1" = "$2" ]; then
- return 0
- else
- return 1
- fi
-}
-
fixnl()
{
t=""
@@ -55,6 +42,43 @@ undo()
git reset --hard HEAD~
}
+test_equal()
+{
+ if test "$1" = "$2"
+ then
+ return 0
+ else
+ test_debug 'echo'
+ test_debug "echo \"check a:\" \"{$1}\""
+ test_debug "echo \" b:\" \"{$2}\""
+ return 1
+ fi
+}
+
+# Make sure no patch changes more than one file.
+# The original set of commits changed only one file each.
+# A multi-file change would imply that we pruned commits
+# too aggressively.
+join_commits()
+{
+ commit=
+ all=
+ while read x y; do
+ if [ -z "$x" ]; then
+ continue
+ elif [ "$x" = "commit:" ]; then
+ if [ -n "$commit" ]; then
+ echo "$commit $all"
+ all=
+ fi
+ commit="$y"
+ else
+ all="$all $y"
+ fi
+ done
+ echo "$commit $all"
+}
+
last_commit_message()
{
git log --pretty=format:%s -1
@@ -97,7 +121,7 @@ test_expect_success 'add main4' '
create main4 &&
git commit -m "main4" &&
git branch -m master mainline &&
- git branch subdir
+ git branch init
'
test_expect_success 'fetch subproj history' '
@@ -105,40 +129,43 @@ test_expect_success 'fetch subproj history' '
git branch sub1 FETCH_HEAD
'
-test_expect_success 'no subtree exists in main tree' '
- test_must_fail git subtree merge --prefix=subdir sub1
+test_expect_success 'no pull from non-existent subtree' '
+ test_must_fail git subtree pull --prefix=subdir ./subproj sub1
'
-test_expect_success 'no pull from non-existant subtree' '
- test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+test_expect_success 'no merge from non-existent subtree' '
+ test_must_fail git subtree merge --prefix=subdir FETCH_HEAD
'
-test_expect_success 'check if --message works for add' '
- git subtree add --prefix=subdir --message="Added subproject" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject" &&
+test_expect_success 'add subproj as subtree into subdir/ with --prefix' '
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''" &&
undo
'
-test_expect_success 'check if --message works as -m and --prefix as -P' '
- git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
+test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '
+ git subtree add --prefix=subdir --message="Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject" &&
undo
'
-test_expect_success 'check if --message works with squash too' '
- git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
+test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '
+ git subtree add -P subdir -m "Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject" &&
undo
'
-test_expect_success 'add subproj to mainline' '
- git subtree add --prefix=subdir/ FETCH_HEAD &&
- check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
+test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '
+ git subtree add --prefix=subdir --message="Added subproject with squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject with squash" &&
+ undo
'
-# this shouldn't actually do anything, since FETCH_HEAD is already a parent
-test_expect_success 'merge fetched subproj' '
- git merge -m "merge -s -ours" -s ours FETCH_HEAD
+test_expect_success 'merge the added subproj again, should do nothing' '
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ # this shouldn not actually do anything, since FETCH_HEAD
+ # is already a parent
+ git merge -s ours -m "merge -s -ours" FETCH_HEAD
'
test_expect_success 'add main-sub5' '
@@ -161,25 +188,30 @@ test_expect_success 'fetch new subproj history' '
git branch sub2 FETCH_HEAD
'
-test_expect_success 'check if --message works for merge' '
- git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
+test_expect_success 'merge new subproj history into subdir/ with --prefix' '
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\'' into mainline" &&
+ undo
+'
+
+test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '
+ git subtree merge --prefix=subdir --message="Merged changes from subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject" &&
undo
'
-test_expect_success 'check if --message for merge works with squash too' '
- git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
+test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '
+ git subtree merge --prefix=subdir --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject using squash" &&
undo
'
-test_expect_success 'merge new subproj history into subdir' '
+test_expect_success 'merge new subproj history into subdir/' '
git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split &&
- check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
+ git branch pre-split
'
-test_expect_success 'Check that prefix argument is required for split' '
+test_expect_success 'split requires option --prefix' '
echo "You must provide the --prefix option." > expected &&
test_must_fail git subtree split > actual 2>&1 &&
test_debug "echo -n expected: " &&
@@ -190,48 +222,56 @@ test_expect_success 'Check that prefix argument is required for split' '
rm -f expected actual
'
-test_expect_success 'Check that the <prefix> exists for a split' '
- echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
+test_expect_success 'split requires path given by option --prefix must exist' '
+ echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
test_debug "echo -n expected: " &&
test_debug "cat expected" &&
test_debug "echo -n actual: " &&
test_debug "cat actual" &&
- test_cmp expected actual
+ test_cmp expected actual &&
rm -f expected actual
'
-test_expect_success 'check if --message works for split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- git branch spl1 "$spl1" &&
- check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
+test_expect_success 'split subdir/ with --rejoin' '
+ spl1=$(git subtree split --prefix=subdir --annotate="*") &&
+ git branch spl1 "$spl1" &&
+ git subtree split --prefix=subdir --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$spl1'\''" &&
+ undo
+ '
+
+test_expect_success 'split subdir/ with --rejoin and --message' '
+ git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split & rejoin" &&
undo
'
-test_expect_success 'check split with --branch' '
- spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
- check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
-'
+test_expect_success 'split subdir/ with --branch' '
+ spl1=$(git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin) &&
+ undo &&
+ git subtree split --prefix=subdir --annotate="*" --branch splitbr1 &&
+ test_equal "$(git rev-parse splitbr1)" "$spl1"
+ '
-test_expect_success 'check split with --branch for an existing branch' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+test_expect_success 'split subdir/ with --branch for an existing branch' '
+ spl1=$(git subtree split --prefix=subdir --annotate="*" --message="Split & rejoin" --rejoin) &&
undo &&
git branch splitbr2 sub1 &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
- check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
+ git subtree split --prefix=subdir --annotate="*" --branch splitbr2 &&
+ test_equal "$(git rev-parse splitbr2)" "$spl1"
'
-test_expect_success 'check split with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
+test_expect_success 'split subdir/ with --branch for an incompatible branch' '
+ test_must_fail git subtree split --prefix=subdir --branch init
'
-test_expect_success 'check split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+test_expect_success 'check --unannotate' '
+ spl1=$(git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
- check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
+ git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --branch splitunann &&
+ test_equal "$(git rev-parse splitunann)" "$spl1" &&
+ test_equal "$(git log splitunann | grep subproj)" ""
'
test_expect_success 'add main-sub8' '
@@ -257,8 +297,8 @@ test_expect_success 'add sub9' '
cd ..
test_expect_success 'split for sub8' '
- split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
- git branch split2 "$split2"
+ spl2=$(git subtree split --prefix=subdir/ --annotate="*" --rejoin) &&
+ git branch spl2 "$spl2"
'
test_expect_success 'add main-sub10' '
@@ -267,7 +307,7 @@ test_expect_success 'add main-sub10' '
'
test_expect_success 'split for sub10' '
- spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
+ spl3=$(git subtree split --prefix=subdir --annotate="*" --rejoin) &&
git branch spl3 "$spl3"
'
@@ -288,13 +328,13 @@ chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$subfiles" "$chkms $chks"
+ subfiles=$(git ls-files | fixnl) &&
+ test_equal "$subfiles" "$chkms $chks"
'
-test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" "$chkms $chks"
+test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$chkms $chks"
'
# Back to mainline
@@ -307,25 +347,25 @@ test_expect_success 'pull from subproj' '
'
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ mainfiles=$(git ls-files | fixnl) &&
+ test_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
test_expect_success 'make sure each filename changed exactly once in the entire history' '
# main-sub?? and /subdir/main-sub?? both change, because those are the
# changes that were split into their own history. And subdir/sub?? never
# change, since they were *only* changed in the subtree branch.
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
'
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
+ test_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
'
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
# They are meaningless to subproj since one side of the merge refers to the mainline
- check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
+ test_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
'
# prepare second pair of repositories
@@ -363,7 +403,7 @@ cd ../main
test_expect_success 'add sub as subdir in main' '
git fetch ../sub master &&
git branch sub2 FETCH_HEAD &&
- git subtree add --prefix subdir sub2
+ git subtree add --prefix=subdir sub2
'
cd ../sub
@@ -378,7 +418,7 @@ cd ../main
test_expect_success 'merge from sub' '
git fetch ../sub master &&
git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix subdir sub3
+ git subtree merge --prefix=subdir sub3
'
test_expect_success 'add main-sub4' '
@@ -387,7 +427,7 @@ test_expect_success 'add main-sub4' '
'
test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix subdir --branch mainsub4
+ git subtree split --prefix=subdir --branch mainsub4
'
# at this point, the new commit parent should be sub3 if it is not,
@@ -396,7 +436,7 @@ test_expect_success 'split for main-sub4 without --onto' '
# itself)
test_expect_success 'check that the commit parent is sub3' '
- check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
+ test_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
'
test_expect_success 'add main-sub5' '
@@ -409,47 +449,23 @@ test_expect_success 'split for main-sub5 without --onto' '
# also test that we still can split out an entirely new subtree
# if the parent of the first commit in the tree is not empty,
# then the new subtree has accidently been attached to something
- git subtree split --prefix subdir2 --branch mainsub5 &&
- check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
+ git subtree split --prefix=subdir2 --branch mainsub5 &&
+ test_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
'
-# make sure no patch changes more than one file. The original set of commits
-# changed only one file each. A multi-file change would imply that we pruned
-# commits too aggressively.
-joincommits()
-{
- commit=
- all=
- while read x y; do
- #echo "{$x}" >&2
- if [ -z "$x" ]; then
- continue
- elif [ "$x" = "commit:" ]; then
- if [ -n "$commit" ]; then
- echo "$commit $all"
- all=
- fi
- commit="$y"
- else
- all="$all $y"
- fi
- done
- echo "$commit $all"
-}
-
test_expect_success 'verify one file change per commit' '
x= &&
- list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
- (git log --pretty=format:'"'commit: %H'"' | joincommits |
- (while read commit a b; do
- test_debug "echo Verifying commit "''"$commit"''
- test_debug "echo a: "''"$a"''
- test_debug "echo b: "''"$b"''
- check_equal "$b" ""
+ git log --pretty=format:"commit: %H" | join_commits |
+ (
+ while read commit a b; do
+ test_debug "echo Verifying commit $commit"
+ test_debug "echo a: $a"
+ test_debug "echo b: $b"
+ test_equal "$b" ""
x=1
done
- check_equal "$x" 1
- ))
+ test_equal "$x" 1
+ )
'
test_done
--
1.7.10.4
^ permalink raw reply related
* [PATCH 6/8] contrib/subtree: Handle '--prefix' argument with a slash appended
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
'git subtree merge' will fail if the argument of '--prefix' has a slash
appended.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 2 +-
contrib/subtree/t/t7900-subtree.sh | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 6c3929b..1b3df99 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -82,7 +82,7 @@ while [ $# -gt 0 ]; do
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
- -P) prefix="$1"; shift ;;
+ -P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index eee032d..5c6c73d 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -255,6 +255,26 @@ test_expect_success 'merge new subproj history into subdir/ with --squash and --
)
'
+next_test
+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir/ FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir/ FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
#
# Tests for 'git subtree split'
#
--
1.7.10.4
^ permalink raw reply related
* [PATCH 5/8] contrib/subtree: Make each test self-contained
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/t/t7900-subtree.sh | 1000 +++++++++++++++++++++++++-----------
1 file changed, 693 insertions(+), 307 deletions(-)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 3787408..eee032d 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -12,12 +12,6 @@ export TEST_DIRECTORY=$(pwd)/../../../t
. ../../../t/test-lib.sh
-create()
-{
- echo "$1" >"$1"
- git add "$1"
-}
-
fixnl()
{
t=""
@@ -37,11 +31,6 @@ multiline()
done
}
-undo()
-{
- git reset --hard HEAD~
-}
-
test_equal()
{
if test "$1" = "$2"
@@ -79,392 +68,789 @@ join_commits()
echo "$commit $all"
}
+test_create_commit() (
+ repo=$1
+ commit=$2
+ cd "$repo"
+ mkdir -p $(dirname "$commit") \
+ || error "Could not create directory for commit"
+ echo "$commit" >"$commit"
+ git add "$commit" || error "Could not add commit"
+ git commit -m "$commit" || error "Could not commit"
+)
+
last_commit_message()
{
git log --pretty=format:%s -1
}
-test_expect_success 'init subproj' '
- test_create_repo subproj
-'
-
-# To the subproject!
-cd subproj
-
-test_expect_success 'add sub1' '
- create sub1 &&
- git commit -m "sub1" &&
- git branch sub1 &&
- git branch -m master subproj
-'
-
-# Save this hash for testing later.
-
-subdir_hash=`git rev-parse HEAD`
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2" &&
- git branch sub2
-'
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3" &&
- git branch sub3
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'add main4' '
- create main4 &&
- git commit -m "main4" &&
- git branch -m master mainline &&
- git branch init
-'
+subtree_test_count=0
+next_test() {
+ subtree_test_count=$(($subtree_test_count+1))
+}
-test_expect_success 'fetch subproj history' '
- git fetch ./subproj sub1 &&
- git branch sub1 FETCH_HEAD
-'
+#
+# Tests for 'git subtree add'
+#
+next_test
test_expect_success 'no pull from non-existent subtree' '
- test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ test_must_fail git subtree pull --prefix=subdir ./subproj master
+ )
'
+next_test
test_expect_success 'no merge from non-existent subtree' '
- test_must_fail git subtree merge --prefix=subdir FETCH_HEAD
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ test_must_fail git subtree merge --prefix=subdir FETCH_HEAD
+ )
'
+next_test
test_expect_success 'add subproj as subtree into subdir/ with --prefix' '
- git subtree add --prefix=subdir FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
'
+next_test
test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '
- git subtree add --prefix=subdir --message="Added subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir --message="Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject"
+ )
'
+next_test
test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '
- git subtree add -P subdir -m "Added subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add -P subdir -m "Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject"
+ )
'
+next_test
test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '
- git subtree add --prefix=subdir --message="Added subproject with squash" --squash FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject with squash" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir --message="Added subproject with squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject with squash"
+ )
'
+next_test
test_expect_success 'merge the added subproj again, should do nothing' '
- git subtree add --prefix=subdir FETCH_HEAD &&
- # this shouldn not actually do anything, since FETCH_HEAD
- # is already a parent
- git merge -s ours -m "merge -s -ours" FETCH_HEAD
-'
-
-test_expect_success 'add main-sub5' '
- create subdir/main-sub5 &&
- git commit -m "subproj: main-sub5"
-'
-
-test_expect_success 'add main6' '
- create main6 &&
- git commit -m "main6 boring"
-'
-
-test_expect_success 'add main-sub7' '
- create subdir/main-sub7 &&
- git commit -m "subproj: main-sub7"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ # this shouldn not actually do anything, since FETCH_HEAD
+ # is already a parent
+ git merge -s ours -m "merge -s -ours" FETCH_HEAD
+ )
'
-test_expect_success 'fetch new subproj history' '
- git fetch ./subproj sub2 &&
- git branch sub2 FETCH_HEAD
-'
+#
+# Tests for 'git subtree merge'
+#
+next_test
test_expect_success 'merge new subproj history into subdir/ with --prefix' '
- git subtree merge --prefix=subdir FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\'' into mainline" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
'
+next_test
test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '
- git subtree merge --prefix=subdir --message="Merged changes from subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merged changes from subproject" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir --message="Merged changes from subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject"
+ )
'
+next_test
test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '
- git subtree merge --prefix=subdir --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merged changes from subproject using squash" &&
- undo
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_repo "$subtree_test_count" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject using squash"
+ )
'
-test_expect_success 'merge new subproj history into subdir/' '
- git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split
-'
+#
+# Tests for 'git subtree split'
+#
+next_test
test_expect_success 'split requires option --prefix' '
- echo "You must provide the --prefix option." > expected &&
- test_must_fail git subtree split > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ echo "You must provide the --prefix option." > expected &&
+ test_must_fail git subtree split > actual 2>&1 &&
+ test_debug "echo -n expected: " &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+ )
'
+next_test
test_expect_success 'split requires path given by option --prefix must exist' '
- echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
- test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
+ test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
+ test_debug "echo -n expected:" &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+ )
'
+next_test
test_expect_success 'split subdir/ with --rejoin' '
- spl1=$(git subtree split --prefix=subdir --annotate="*") &&
- git branch spl1 "$spl1" &&
- git subtree split --prefix=subdir --annotate="*" --rejoin &&
- test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$spl1'\''" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
+ git subtree split --prefix=subdir --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$split_hash'\''"
+ )
'
+next_test
test_expect_success 'split subdir/ with --rejoin and --message' '
- git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
- test_equal "$(last_commit_message)" "Split & rejoin" &&
- undo
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split & rejoin"
+ )
'
+next_test
test_expect_success 'split subdir/ with --branch' '
- spl1=$(git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin) &&
- undo &&
- git subtree split --prefix=subdir --annotate="*" --branch splitbr1 &&
- test_equal "$(git rev-parse splitbr1)" "$spl1"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ test_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
'
+next_test
test_expect_success 'split subdir/ with --branch for an existing branch' '
- spl1=$(git subtree split --prefix=subdir --annotate="*" --message="Split & rejoin" --rejoin) &&
- undo &&
- git branch splitbr2 sub1 &&
- git subtree split --prefix=subdir --annotate="*" --branch splitbr2 &&
- test_equal "$(git rev-parse splitbr2)" "$spl1"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git branch subproj-br FETCH_HEAD &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ test_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
'
+next_test
test_expect_success 'split subdir/ with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix=subdir --branch init
-'
-
-test_expect_success 'check --unannotate' '
- spl1=$(git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --branch splitunann &&
- test_equal "$(git rev-parse splitunann)" "$spl1" &&
- test_equal "$(git log splitunann | grep subproj)" ""
-'
-
-test_expect_success 'add main-sub8' '
- create subdir/main-sub8 &&
- git commit -m "main-sub8"
-'
-
-# To the subproject!
-cd ./subproj
-
-test_expect_success 'merge split into subproj' '
- git fetch .. spl1 &&
- git branch spl1 FETCH_HEAD &&
- git merge FETCH_HEAD
-'
-
-test_expect_success 'add sub9' '
- create sub9 &&
- git commit -m "sub9"
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'split for sub8' '
- spl2=$(git subtree split --prefix=subdir/ --annotate="*" --rejoin) &&
- git branch spl2 "$spl2"
-'
-
-test_expect_success 'add main-sub10' '
- create subdir/main-sub10 &&
- git commit -m "main-sub10"
-'
-
-test_expect_success 'split for sub10' '
- spl3=$(git subtree split --prefix=subdir --annotate="*" --rejoin) &&
- git branch spl3 "$spl3"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git branch init HEAD &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ test_must_fail git subtree split --prefix=subdir --branch init
+ )
'
-# To the subproject!
-cd ./subproj
+#
+# Validity checking
+#
-test_expect_success 'merge split into subproj' '
- git fetch .. spl3 &&
- git branch spl3 FETCH_HEAD &&
- git merge FETCH_HEAD &&
- git branch subproj-merge-spl3
-'
+next_test
+test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD &&
-chkm="main4 main6"
-chkms="main-sub10 main-sub5 main-sub7 main-sub8"
-chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
-chks="sub1 sub2 sub3 sub9"
-chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
-test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles=$(git ls-files | fixnl) &&
- test_equal "$subfiles" "$chkms $chks"
+ subfiles=$(git ls-files | fixnl) &&
+ test_equal "$subfiles" "$chkms $chks"
+ )
'
+next_test
test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '
- allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
- test_equal "$allchanges" "$chkms $chks"
-'
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD &&
-# Back to mainline
-cd ..
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
-test_expect_success 'pull from subproj' '
- git fetch ./subproj subproj-merge-spl3 &&
- git branch subproj-merge-spl3 FETCH_HEAD &&
- git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$chkms $chks"
+ )
'
+next_test
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=$(git ls-files | fixnl) &&
- test_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
+ chkm="main1 main2" &&
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ mainfiles=$(git ls-files | fixnl) &&
+ test_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ )
'
+next_test
test_expect_success 'make sure each filename changed exactly once in the entire history' '
- # main-sub?? and /subdir/main-sub?? both change, because those are the
- # changes that were split into their own history. And subdir/sub?? never
- # change, since they were *only* changed in the subtree branch.
- allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
- test_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
+ chkm="main1 main2" &&
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+
+ # main-sub?? and /subdir/main-sub?? both change, because those are the
+ # changes that were split into their own history. And subdir/sub?? never
+ # change, since they were *only* changed in the subtree branch.
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
+ )
'
+next_test
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- test_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
-'
-
-test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
- # They are meaningless to subproj since one side of the merge refers to the mainline
- test_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
-'
-
-# prepare second pair of repositories
-mkdir test2
-cd test2
-
-test_expect_success 'init main' '
- test_create_repo main
-'
-
-cd main
-
-test_expect_success 'add main1' '
- create main1 &&
- git commit -m "main1"
-'
-
-cd ..
-
-test_expect_success 'init sub' '
- test_create_repo sub
-'
-
-cd sub
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2"
-'
-
-cd ../main
-
-# check if split can find proper base without --onto
-
-test_expect_success 'add sub as subdir in main' '
- git fetch ../sub master &&
- git branch sub2 FETCH_HEAD &&
- git subtree add --prefix=subdir sub2
-'
-
-cd ../sub
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3"
-'
-
-cd ../main
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
-test_expect_success 'merge from sub' '
- git fetch ../sub master &&
- git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix=subdir sub3
+ test_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
+ )
'
-test_expect_success 'add main-sub4' '
- create subdir/main-sub4 &&
- git commit -m "main-sub4"
-'
+next_test
+test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub3 &&
+ test_create_commit "$subtree_test_count" subdir/main-sub3 &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
-test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix=subdir --branch mainsub4
+ # They are meaningless to subproj since one side of the merge refers to the mainline
+ test_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
+ )
'
-# at this point, the new commit parent should be sub3 if it is not,
-# something went wrong (the "newparent" of "master~" commit should
-# have been sub3, but it was not, because its cache was not set to
-# itself)
+#
+# A new set of tests
+#
-test_expect_success 'check that the commit parent is sub3' '
- test_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
+next_test
+test_expect_success 'make sure "git subtree split" find the correct parent' '
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git branch subproj-ref FETCH_HEAD &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br &&
+
+ # at this point, the new commit parent should be subproj-ref, if it is
+ # not, something went wrong (the "newparent" of "master~" commit should
+ # have been sub2, but it was not, because its cache was not set to
+ # itself)
+ test_equal "$(git log --pretty=format:%P -1 subproj-br)" "$(git rev-parse subproj-ref)"
+ )
'
-test_expect_success 'add main-sub5' '
- mkdir subdir2 &&
- create subdir2/main-sub5 &&
- git commit -m "main-sub5"
-'
+next_test
+test_expect_success 'split a new subtree without --onto option' '
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br
+ ) &&
+ test_create_commit "$subtree_test_count" subdir2/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
-test_expect_success 'split for main-sub5 without --onto' '
- # also test that we still can split out an entirely new subtree
- # if the parent of the first commit in the tree is not empty,
- # then the new subtree has accidently been attached to something
- git subtree split --prefix=subdir2 --branch mainsub5 &&
- test_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
+ # also test that we still can split out an entirely new subtree
+ # if the parent of the first commit in the tree is not empty,
+ # then the new subtree has accidently been attached to something
+ git subtree split --prefix=subdir2 --branch subproj2-br &&
+ test_equal "$(git log --pretty=format:%P -1 subproj2-br)" ""
+ )
'
+next_test
test_expect_success 'verify one file change per commit' '
- x= &&
- git log --pretty=format:"commit: %H" | join_commits |
- (
- while read commit a b; do
- test_debug "echo Verifying commit $commit"
- test_debug "echo a: $a"
- test_debug "echo b: $b"
- test_equal "$b" ""
- x=1
- done
- test_equal "$x" 1
+ test_create_repo "$subtree_test_count" &&
+ test_create_repo "$subtree_test_count/subproj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/subproj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git branch sub1 FETCH_HEAD &&
+ git subtree add --prefix=subdir sub1
+ ) &&
+ test_create_commit "$subtree_test_count/subproj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" subdir/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br
+ ) &&
+ test_create_commit "$subtree_test_count" subdir2/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix=subdir2 --branch subproj2-br &&
+
+ x= &&
+ git log --pretty=format:"commit: %H" | join_commits |
+ (
+ while read commit a b; do
+ test_debug "echo Verifying commit $commit"
+ test_debug "echo a: $a"
+ test_debug "echo b: $b"
+ test_equal "$b" ""
+ x=1
+ done
+ test_equal "$x" 1
+ )
)
'
--
1.7.10.4
^ permalink raw reply related
* [PATCH 7/8] contrib/subtree: Remove --annotate
From: David A. Greene @ 2013-02-18 20:56 UTC (permalink / raw)
To: git, Techlive Zheng, James Nylen; +Cc: David A. Greene
In-Reply-To: <1361221013-12756-1-git-send-email-greened@obbligato.org>
From: "David A. Greene" <greened@obbligato.org>
Remove --annotate. This obviates the need for an --unannotate
command. We really want a more generalized commit message rewrite
mechanism.
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 6 +----
contrib/subtree/t/t7900-subtree.sh | 50 ++++++++++++++++++------------------
2 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 1b3df99..2aceadc 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -21,7 +21,6 @@ d show debug messages
P,prefix= the name of the subdir to split out
m,message= use the given message as the commit message for the merge commit
options for 'split'
-annotate= add a prefix to commit message of new commits
b,branch= create a new branch from the split subtree
ignore-joins ignore prior --rejoin commits
onto= try connecting new tree to an existing one
@@ -43,7 +42,6 @@ command=
onto=
rejoin=
ignore_joins=
-annotate=
squash=
message=
@@ -79,8 +77,6 @@ while [ $# -gt 0 ]; do
case "$opt" in
-q) quiet=1 ;;
-d) debug=1 ;;
- --annotate) annotate="$1"; shift ;;
- --no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
-P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
@@ -311,7 +307,7 @@ copy_commit()
GIT_COMMITTER_NAME \
GIT_COMMITTER_EMAIL \
GIT_COMMITTER_DATE
- (echo -n "$annotate"; cat ) |
+ (echo -n ""; cat ) |
git commit-tree "$2" $3 # reads the rest of stdin
) || die "Can't copy commit $1"
}
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 5c6c73d..fa2a6c3 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -338,8 +338,8 @@ test_expect_success 'split subdir/ with --rejoin' '
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --rejoin &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --rejoin &&
test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$split_hash'\''"
)
'
@@ -363,7 +363,7 @@ test_expect_success 'split subdir/ with --rejoin and --message' '
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
+ git subtree split --prefix=subdir --message="Split & rejoin" --rejoin &&
test_equal "$(last_commit_message)" "Split & rejoin"
)
'
@@ -387,8 +387,8 @@ test_expect_success 'split subdir/ with --branch' '
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --branch subproj-br &&
test_equal "$(git rev-parse subproj-br)" "$split_hash"
)
'
@@ -413,8 +413,8 @@ test_expect_success 'split subdir/ with --branch for an existing branch' '
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --branch subproj-br &&
test_equal "$(git rev-parse subproj-br)" "$split_hash"
)
'
@@ -466,7 +466,7 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -477,12 +477,12 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
@@ -517,7 +517,7 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -528,12 +528,12 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
@@ -568,7 +568,7 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -579,12 +579,12 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
@@ -623,7 +623,7 @@ test_expect_success 'make sure each filename changed exactly once in the entire
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -634,12 +634,12 @@ test_expect_success 'make sure each filename changed exactly once in the entire
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
@@ -682,7 +682,7 @@ test_expect_success 'make sure the --rejoin commits never make it into subproj'
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -693,12 +693,12 @@ test_expect_success 'make sure the --rejoin commits never make it into subproj'
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
@@ -731,7 +731,7 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
cd "$subtree_test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/subproj" sub3 &&
test_create_commit "$subtree_test_count" subdir/main-sub3 &&
@@ -742,12 +742,12 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
test_create_commit "$subtree_test_count/subproj" sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count" subdir/main-sub4 &&
(
cd "$subtree_test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$subtree_test_count/subproj" &&
--
1.7.10.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox