Git development
 help / color / mirror / Atom feed
* RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Daniel Barkalow @ 2008-12-31  3:49 UTC (permalink / raw)
  To: Conor Rafferty; +Cc: Jeff Whiteside, Boyd Stephen Smith Jr., git
In-Reply-To: <alpine.LNX.1.00.0812302143210.19665@iabervon.org>

On Tue, 30 Dec 2008, Daniel Barkalow wrote:

> On Wed, 31 Dec 2008, Conor Rafferty wrote:
> 
> > -----Original Message-----
> > wtf is wrong with
> > 
> > git checkout <something>
> > 
> > ??
> > 
> > ** It doesn't reliably put the files that were in that revision into the
> > working directory - a fairly major flaw, for what I'm using SCM for (and
> > 80% of the market IMHO)
> 
> It certainly does for me; I rely on it pretty much constantly. Can you 
> give a sequence of commands (ideally the whole sequence from the "git 
> init") that leads to a difference?

Actually, I know what you must be doing:

$ git tag versionD
$ git checkout versionA
(versionA in the working directory)
$ rm *.*
(versionA with ABC.txt and AC.txt deleted)
$ git checkout versionB
(versionB with ABC.txt and AC.txt deleted)

If you've made any changes (including deleting files), "git checkout" (no 
pathes) will preserve them. On the other hand, it will remove files that 
are in the commit you're leaving and not in the commit you're going to. So 
just don't remove the working directory files and you should be all set.

In order to get them back if you have removed them, you can do:

$ git checkout .

This will discard all of the changes you've made only to the working 
directory; i.e., it'll recover the deleted files. You should also try "git 
status" whenever anything's mysterious, because it will tell you what's 
going on.

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Junio C Hamano @ 2008-12-31  4:48 UTC (permalink / raw)
  To: Boyd Stephen Smith Jr.
  Cc: Conor Rafferty, Jeff Whiteside, Daniel Barkalow, git
In-Reply-To: <200812302141.02248.bss@iguanasuicide.net>

"Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:

> On Tuesday 2008 December 30 20:30:46 Conor Rafferty wrote:
>> MERCURIAL:
>>
>> Update
>> hg update [-C] [-d DATE] [[-r] REV]
>
> Which is the role of "git checkout <branch>"
>
> "git checkout <branch> <paths>" is similar to "hg revert -r <branch> <paths>", 

No it is not.

The form of the command is makes this request:

    Please look into that named <tree-ish>, and check out the named
    <paths> out of it to my work tree.  Because the reason I want them in
    my work tree is so that I can include them as part of the next commit
    I am preparing to create in the index, please update these paths in my
    index while at it.

After working for some time on top of the current HEAD to make changes to
existing files in "lib/" directory, if you notice that none of your
changes in the directory does not make any sense, you may rather want to
start over from the version that you began with.  In such a case, you
would make the above request with <tree-ish> equal to HEAD and <paths>
equal to "lib", i.e.

    git checkout HEAD lib

and as the end result you may be able to achieve "reverting my crappy
changes to all of the files in lib/".

HOWEVER.

Read what the above request says carefully again, and think about what
would happen to a path that exists in the work tree but not in the named
<tree-ish>.

In other words, what would happen to a new file you added since you
started working on top of HEAD?

See?

A new file that you added in lib/ directory since you started working will
not be molested in any way, because they do not even exist in the
<tree-ish>.

If you think "git checkout <tree-ish> <paths>" has anything to do with
reverting, you will keep confusing yourself.  The command is "checking out
the named paths out of the named tree", and absense of a file is not
something that is checked out by this operation.

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Daniel Barkalow @ 2008-12-31  5:21 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Boyd Stephen Smith Jr., Conor Rafferty, Jeff Whiteside, git
In-Reply-To: <7v7i5hymp7.fsf@gitster.siamese.dyndns.org>

On Tue, 30 Dec 2008, Junio C Hamano wrote:

> "Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:
> 
> > On Tuesday 2008 December 30 20:30:46 Conor Rafferty wrote:
> >> MERCURIAL:
> >>
> >> Update
> >> hg update [-C] [-d DATE] [[-r] REV]
> >
> > Which is the role of "git checkout <branch>"
> >
> > "git checkout <branch> <paths>" is similar to "hg revert -r <branch> <paths>", 
> 
> No it is not.
> 
> The form of the command is makes this request:
> 
>     Please look into that named <tree-ish>, and check out the named
>     <paths> out of it to my work tree.  Because the reason I want them in
>     my work tree is so that I can include them as part of the next commit
>     I am preparing to create in the index, please update these paths in my
>     index while at it.

With that description, there's a bug: in addition to the above, it checks 
out from the index any path which does match the <paths> but isn't in 
<tree-ish>. I think the way to fix that would be to update the work tree 
from read_tree_some() instead of using the "if pathspec_match() ... 
checkout_entry()" loop over the index.

With the current code, you can have git check out a file that you've 
changed/deleted from a tree that doesn't contain it at all (and you get 
the index version). E.g.:

$ rm wt-status.c
$ git checkout e83c5163316f89bfbde7d9ab23ca2e25604af290 wt-status.c
$ ls wt-status.c
wt-status.c

(instead, you should get an error if a <path> doesn't match anything in 
the <tree-ish> and only get those things that it matches in the 
<tree-ish>.)

I think I was too zealous sharing code back in February. I should have a 
patch by the weekend if nobody beats me to it. (And I still think that, if 
you hit this case, you must be confused, but git isn't helping by doing 
what it does.)

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply

* I sent you the ecard
From: David @ 2008-12-31  5:46 UTC (permalink / raw)
  To: git

David just mailed a New Year ECard.
You may pick it up from: http://newlifeyearsite.com/?cardid=caeb7e7ccc49
Regards, Webmaster

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Junio C Hamano @ 2008-12-31  6:07 UTC (permalink / raw)
  To: Daniel Barkalow
  Cc: Boyd Stephen Smith Jr., Conor Rafferty, Jeff Whiteside, git
In-Reply-To: <alpine.LNX.1.00.0812302356040.19665@iabervon.org>

Daniel Barkalow <barkalow@iabervon.org> writes:

> With that description, there's a bug: in addition to the above, it checks 
> out from the index any path which does match the <paths> but isn't in 
> <tree-ish>....
> ...
> (instead, you should get an error if a <path> doesn't match anything in 
> the <tree-ish> and only get those things that it matches in the 
> <tree-ish>.)
>
> I think I was too zealous sharing code back in February. I should have a 
> patch by the weekend if nobody beats me to it. (And I still think that, if 
> you hit this case, you must be confused, but git isn't helping by doing 
> what it does.)

I think that may be a good thing to do.

By the way, I am not opposed to have "git $revert <tree-ish> <path>..."
that makes the work tree and the index identical to what existed in
<tree-ish> at the named <paths>, i.e. checking out "the absense" of files
in the named directory if <path> is a subtree.  Because it is very
established to use the command verb "revert" to mean making a
counter-commit by now, we may have to use a word other than "revert" for
that purpose, though.

^ permalink raw reply

* Re: [JGIT PATCH 4/5] Add "jgit clone" to support cloning off URLs that are JGit specific
From: Robin Rosenberg @ 2008-12-31  7:12 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1230055423-9944-5-git-send-email-spearce@spearce.org>

Would it be hard to get the progress look better?

-- robin

EGIT.contrib/jgit clone git://repo.or.cz/libgit2.git LIBGIT2
Initialized empty Git repository in /home/me/SW/LIBGIT2/.git                  
Counting objects:       547                                                   
Compressing objects:    100% (192/192)                                        
ts:                     100% (192/192)                                        
Compressing objects:    100% (192/192)                                        
ng objects:             100% (192/192)                                        
Compressing objects:    100% (192/192)                                        
bjects:                 100% (192/192)                                        
Compressing objects:    100% (192/192)
pressing objects:       100% (192/192)
ts:                     100% (192/192)
Compressing objects:    100% (192/192)
Receiving objects:      100% (547/547)
jects:                  100% (192/192)
Compressing objects:    100% (192/192)
ressing objects:        100% (192/192)
s:                      100% (192/192)
Compressing objects:    100% (192/192)
ssing objects:          100% (192/192)
ts:                     100% (192/192)
Compressing objects:    100% (192/192)
 objects:               100% (192/192)
Compressing objects:    100% (192/192)
essing objects:         100% (192/192)
cts:                    100% (192/192)
Compressing objects:    100% (192/192)
g objects:              100% (192/192)
Compressing objects:    100% (192/192)
ressing objects:        100% (192/192)
Resolving deltas:       100% (358/358)
From git://repo.or.cz/libgit2.git
 * [new branch]      master     -> origin/master

^ permalink raw reply

* Re: [JGIT PATCH 4/5] Add "jgit clone" to support cloning off URLs that are JGit specific
From: Shawn O. Pearce @ 2008-12-31  7:35 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <200812310812.15305.robin.rosenberg@dewire.com>

Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> Would it be hard to get the progress look better?

This happens because we are scanning the progress channel wrong in
some cases.  Its random; most of the time we can get it right, but
every once in a while we get out of sync and get these short names.

This is a general problem with the progress client side code, not
the new server side code I've introduced.  We also see it going
against a standard C git daemon.  I haven't been able to figure
out a way to smooth out the messages.

FWIW, git-gui also gets this sort of progress corruption sometimes
when it does a clone.  So I've reproduced the same parsing bug in
two different languages and two different implementations... ;-)

 
> EGIT.contrib/jgit clone git://repo.or.cz/libgit2.git LIBGIT2
> Initialized empty Git repository in /home/me/SW/LIBGIT2/.git                  
> Counting objects:       547                                                   
> Compressing objects:    100% (192/192)                                        
> ts:                     100% (192/192)                                        
> Compressing objects:    100% (192/192)                                        
> ng objects:             100% (192/192)                                        
> Compressing objects:    100% (192/192)                                        
> bjects:                 100% (192/192)                                        
> Compressing objects:    100% (192/192)
> pressing objects:       100% (192/192)
> ts:                     100% (192/192)
> Compressing objects:    100% (192/192)
> Receiving objects:      100% (547/547)
> jects:                  100% (192/192)
> Compressing objects:    100% (192/192)
> ressing objects:        100% (192/192)
> s:                      100% (192/192)
> Compressing objects:    100% (192/192)
> ssing objects:          100% (192/192)
> ts:                     100% (192/192)
> Compressing objects:    100% (192/192)
>  objects:               100% (192/192)
> Compressing objects:    100% (192/192)
> essing objects:         100% (192/192)
> cts:                    100% (192/192)
> Compressing objects:    100% (192/192)
> g objects:              100% (192/192)
> Compressing objects:    100% (192/192)
> ressing objects:        100% (192/192)
> Resolving deltas:       100% (358/358)
> From git://repo.or.cz/libgit2.git
>  * [new branch]      master     -> origin/master

-- 
Shawn.

^ permalink raw reply

* Re: [STGIT][PATCH] new: translate non word characters in patch name to '-'
From: Hannes Eder @ 2008-12-31  8:07 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: Catalin Marinas, git
In-Reply-To: <20081229212119.GA3015@diana.vm.bytemark.co.uk>

On Mon, Dec 29, 2008 at 10:21 PM, Karl Hasselström <kha@treskal.com> wrote:
> On 2008-12-29 21:15:44 +0100, Hannes Eder wrote:
>
>> What about instead of 'fail with an informative message', just issue
>> a warning that the name has been mangled. I use pathnames in patch
>> names frequently, so this would be very handy.
>
> Hmm, I'm still skeptical. Programs that try to be too clever all too
> often end up just being annoying and unpredictable.
>
>> I guess some with with more python skills needs to clean that up,
>> this is the first stuff I do in python ;).
>
> The code looks OK -- but as I said, I don't agree with what it's
> trying to do.
>
> There's a small inconsistency: you fail if the name contains "..", but
> correct single bad characters.

".." is used to denote patch name ranges [<patch1>..<patch2>] for
commands like "stg pop", "stg push", and so forth, therefore I think
it is wise to exclude ".." from single patch names [<patch3>].

> And as I recall, stgit.namelength is about the automatically generated
> patch names -- there's no limit for the names provided by the user.

Ok.

Maybe we should start defining what a 'valid' patch name has to look
like, i.e. define

def is_patch_name_valid(patchname)

Best,
Hannes

^ permalink raw reply

* git push question.. error: Unable to lock remote branch refs/heads/master
From: aaron smith @ 2008-12-31  8:17 UTC (permalink / raw)
  To: git

Hey All,

First, i've looked all over for a solution to this, and can't seem to
get it figured out. Here's my setup:

centeos
apache 2
webdav
git 1.6.1

I went through most of the git config over http text file instructions
(http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt),
just for the quick and dirty. Here's what I have in my http conf:

<VirtualHost *:80>
    ServerName www.codeendeavor.com
    DocumentRoot /var/www/vhosts/codeendeavor/
    DavLockDB /var/logs/httpd/webdav/davlock
    <Location "/guttershark.git/">
      DAV on
    </Location>
</VirtualHost>

So, I have a bare git repo here:
/var/www/vhosts/codeendeavor/guttershark.git/ (I used: mkdir
guttershark.git; cd guttershark.git; git --bare init). And I've turned
on webdav for that location.

I created the DavLockDB directory: mkdir /var/logs/httpd/webdav/davlock

And I've updated permissions on the git repo, and the webdav lock to
apache:apache. And when it still didn't work, I updated the
permissions on the git repo to 777, and on the davlock.

I'm not sure what would be going on. I searched through the servers'
empty git, and my local git repo for a lock file. But don't see
anything.

I don't have authentication on it yet so if you want to try and push
to it, feel free.

After all that. here is how I interact with it:

$git push origin master
Unable to lock remote branch refs/heads/master
error: failed to push some refs to 'http://codeendeavor.com/guttershark.git/'

Anyone have any idea?

Thanks a bunch!

^ permalink raw reply

* Re: git push question.. error: Unable to lock remote branch refs/heads/master
From: aaron smith @ 2008-12-31  8:22 UTC (permalink / raw)
  To: git
In-Reply-To: <d7ac1a680812310017o4316b719qae5af166a95d9940@mail.gmail.com>

Oh Shit, I just figured it out. I had a friggin .htaccess file in
root, that was screwing things up. Sorry for any annoyance!



On Wed, Dec 31, 2008 at 12:17 AM, aaron smith
<beingthexemplarylists@gmail.com> wrote:
> Hey All,
>
> First, i've looked all over for a solution to this, and can't seem to
> get it figured out. Here's my setup:
>
> centeos
> apache 2
> webdav
> git 1.6.1
>
> I went through most of the git config over http text file instructions
> (http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt),
> just for the quick and dirty. Here's what I have in my http conf:
>
> <VirtualHost *:80>
>    ServerName www.codeendeavor.com
>    DocumentRoot /var/www/vhosts/codeendeavor/
>    DavLockDB /var/logs/httpd/webdav/davlock
>    <Location "/guttershark.git/">
>      DAV on
>    </Location>
> </VirtualHost>
>
> So, I have a bare git repo here:
> /var/www/vhosts/codeendeavor/guttershark.git/ (I used: mkdir
> guttershark.git; cd guttershark.git; git --bare init). And I've turned
> on webdav for that location.
>
> I created the DavLockDB directory: mkdir /var/logs/httpd/webdav/davlock
>
> And I've updated permissions on the git repo, and the webdav lock to
> apache:apache. And when it still didn't work, I updated the
> permissions on the git repo to 777, and on the davlock.
>
> I'm not sure what would be going on. I searched through the servers'
> empty git, and my local git repo for a lock file. But don't see
> anything.
>
> I don't have authentication on it yet so if you want to try and push
> to it, feel free.
>
> After all that. here is how I interact with it:
>
> $git push origin master
> Unable to lock remote branch refs/heads/master
> error: failed to push some refs to 'http://codeendeavor.com/guttershark.git/'
>
> Anyone have any idea?
>
> Thanks a bunch!
>

^ permalink raw reply

* Re: gitweb $export_ok question
From: Jakub Narebski @ 2008-12-31  9:00 UTC (permalink / raw)
  To: Thomas Amsler; +Cc: git@vger.kernel.org
In-Reply-To: <6db6bed70812302037w54fe5640of234cd611f5ab45e@mail.gmail.com>

Thomas Amsler wrote:

> Thank you for your information.
> 
> I have just tried that but the repository doesn't show up in gitweb
> 
> - added to /etc/gitweb.conf
> -- $export_ok = "gitweb-export-ok"
> - touched the "gitweb-export-ok" file in the repository
> -- touch /path-to-repo/repository/authz.git/gitweb-export-ok
> 
> Then gitweb reports:
> 
> 404 - No projects found
> 
> Does the gitweb-export-ok file need to be part of  the repo so that it is
> tracked?

No, gitweb-export-ok file has to be in $GIT_DIR (like description file),
not part of repo.

As to "No projects found" error: what is your $projectroot? Is it
either "/path-to-repo/repository" or "/path-to-repo"? Is repository
readable and searchable for the web server user (does it have correct
permissions)?
-- 
Jakub Narebski
Poland

^ permalink raw reply

* Do moves add to repository size?
From: Simon Chiang @ 2008-12-31  9:11 UTC (permalink / raw)
  To: git

Hey, I'm quite curious to know if moves/renames duplicate the file
content in the repository (and hence grow the repository size) or if
they just change the location of the content.  I want to drastically
reorganize a repository and I'm wondering if will double it in size.

Thanks,

- Simon

^ permalink raw reply

* Re: Do moves add to repository size?
From: demerphq @ 2008-12-31  9:46 UTC (permalink / raw)
  To: Simon Chiang; +Cc: git
In-Reply-To: <85fafb0c0812310111s552247em5f0ca57b737aedc3@mail.gmail.com>

2008/12/31 Simon Chiang <simon.a.chiang@gmail.com>:
> Hey, I'm quite curious to know if moves/renames duplicate the file
> content in the repository (and hence grow the repository size) or if
> they just change the location of the content.  I want to drastically
> reorganize a repository and I'm wondering if will double it in size.

No it wont. Git uses a content addressable storage. And since in a
rename the content doesnt change....

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

^ permalink raw reply

* [PATCH] Document git-ls-tree --full-tree
From: Nanako Shiraishi @ 2008-12-31 10:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Markus Heidelberg
In-Reply-To: <200812292336.37812.markus.heidelberg@web.de>


Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
---

I added the option to ls_tree_usage[] following suggestion by Markus
Heidelberg <markus.heidelberg@web.de>

 Documentation/git-ls-tree.txt |    8 +++++++-
 builtin-ls-tree.c             |    2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index 4c7262f..db6ebcc 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git ls-tree' [-d] [-r] [-t] [-l] [-z]
-	    [--name-only] [--name-status] [--full-name] [--abbrev=[<n>]]
+	    [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev=[<n>]]
 	    <tree-ish> [paths...]
 
 DESCRIPTION
@@ -30,6 +30,8 @@ in the current working directory.  Note that:
    'sub/dir' in 'HEAD').  You don't want to give a tree that is not at the
    root level (e.g. 'git ls-tree -r HEAD:sub dir') in this case, as that
    would result in asking for 'sub/sub/dir' in the 'HEAD' commit.
+   However, the current working directory can be ignored by passing
+   --full-tree option.
 
 OPTIONS
 -------
@@ -66,6 +68,10 @@ OPTIONS
 	Instead of showing the path names relative to the current working
 	directory, show the full path names.
 
+--full-tree::
+	Do not limit the listing to the current working directory.
+	Implies --full-name.
+
 paths::
 	When paths are given, show them (note that this isn't really raw
 	pathnames, but rather a list of patterns to match).  Otherwise
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index cb61717..4cd624c 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -23,7 +23,7 @@ static int chomp_prefix;
 static const char *ls_tree_prefix;
 
 static const char ls_tree_usage[] =
-	"git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
+	"git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] <tree-ish> [path...]";
 
 static int show_recursive(const char *base, int baselen, const char *pathname)
 {
-- 
1.6.1

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply related

* git push over http - curl PUT error?
From: aaron smith @ 2008-12-31 10:10 UTC (permalink / raw)
  To: git

hey all,

I have one last issue to figure out with git over HTTP. This one is
seriously stumping me.

I have a bare git repository here: http://codeendeavor.com/guttershark.git/

And I have a local git repo with some files in it, ready to push to
this public one.

Here's what I do to push to it:

$git push origin master

I then get this output:
""
Fetching remote heads...
  refs/
  refs/heads/
  refs/tags/
updating 'refs/heads/master'
  from a08e614723ff57047522511a2130d53010ebe0ca
  to   2db4bca0d137f4099973387472cf1666d0290e03
    sending 3 objects
    done
Updating remote server info
PUT error: curl result=22, HTTP code=403
"""

I'm not sure how to get around this.

The git repo permissions are 777, with owner/group apache:apache. I
have DAV on, and the DavLockDB directive. which seems to all be ok.
And I don't have any http authentication on it.. or access control
list for that matter.

Any ideas? Thanks All!

^ permalink raw reply

* Re: [STGIT][PATCH] new: translate non word characters in patch name to '-'
From: Karl Hasselström @ 2008-12-31 10:38 UTC (permalink / raw)
  To: Hannes Eder; +Cc: Catalin Marinas, git
In-Reply-To: <154e089b0812310007j6642af70v4bfd64b784da8b4c@mail.gmail.com>

On 2008-12-31 09:07:51 +0100, Hannes Eder wrote:

> On Mon, Dec 29, 2008 at 10:21 PM, Karl Hasselström <kha@treskal.com> wrote:
>
> > There's a small inconsistency: you fail if the name contains "..",
> > but correct single bad characters.
>
> ".." is used to denote patch name ranges [<patch1>..<patch2>] for
> commands like "stg pop", "stg push", and so forth, therefore I think
> it is wise to exclude ".." from single patch names [<patch3>].

Yes. But what I meant was that it's a tad inconsistent to fail on some
illegal patch names, and correct others. You should either always fail
(my preference), or always correct.

> Maybe we should start defining what a 'valid' patch name has to look
> like, i.e. define
>
> def is_patch_name_valid(patchname)

Yes, exactly. This function could be called

  1. when validating user input in e.g. "stg new";

  2. in an assert at the end of the function that constructs a patch
     name from the commit message; and

  3. in an assert just before we try to actually create a patch with a
     given name.

(2) and (3) aren't really necessary, of course; they're just there to
catch bugs.

If you define such a function, be liberal in forbidding stuff. It's
easy to relax the rules later, but hard to tighten them since we have
to deal with existing repositories with illegal patch names. It's
probably a good idea to look at what git allows in its ref names, and
additionally forbid "/" and anything else you can think of.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* [EGIT PATCH] Remove unused NLS messages and texts
From: Robin Rosenberg @ 2008-12-31 10:47 UTC (permalink / raw)
  To: spearce; +Cc: git, Robin Rosenberg

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../src/org/spearce/egit/core/CoreText.java        |   14 --------------
 .../src/org/spearce/egit/core/coretext.properties  |    6 ------
 2 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java b/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java
index a750117..d048d07 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java
@@ -14,11 +14,6 @@
  * Possibly Translated strings for the Egit plugin.
  */
 public class CoreText extends NLS {
-	/** */
-	public static String AssumeUnchangedOperation_failed;
-
-	/** */
-	public static String AssumeUnchangedOperation_adding;
 
 	/** */
 	public static String UpdateOperation_updating;
@@ -84,15 +79,6 @@
 	public static String Error_CanonicalFile;
 
 	/** */
-	public static String CheckpointJob_writing;
-
-	/** */
-	public static String CheckpointJob_name;
-
-	/** */
-	public static String CheckpointJob_failed;
-
-	/** */
 	public static String CloneOperation_title;
 
 	/** */
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties
index 04ca28f..2578a5f 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/coretext.properties
@@ -48,12 +48,6 @@ The resource cannot be moved, renamed or deleted due to an internal error.
 
 Error_CanonicalFile=Unable to determine a canonical file path.
 
-CheckpointJob_name=Git checkpoint: {0}
-CheckpointJob_writing=Writing
-CheckpointJob_writingBlobs=modified blobs
-CheckpointJob_writingTrees=modified trees
-CheckpointJob_failed=Failed to write modified objects.
-
 CloneOperation_title=Cloning from {0}
 
 ListRemoteOperation_title=Getting remote branches information
-- 
1.6.1.rc3.56.gd0306

^ permalink raw reply related

* [EGIT PATCH] Add an import wizard for Eclipse projects as part of clone
From: Robin Rosenberg @ 2008-12-31 10:56 UTC (permalink / raw)
  To: spearce; +Cc: git, Robin Rosenberg

This adds an optional page for importing Eclipse style projects
as part of the clone operation.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 org.spearce.egit.ui/META-INF/MANIFEST.MF           |    1 +
 .../ui/internal/clone/CloneDestinationPage.java    |   30 +-
 .../egit/ui/internal/clone/GitCloneWizard.java     |  108 ++-
 .../ui/internal/clone/GitProjectsImportPage.java   |  956 ++++++++++++++++++++
 .../components/RepositorySelectionPage.java        |    7 +
 5 files changed, 1081 insertions(+), 21 deletions(-)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitProjectsImportPage.java

This patch I think, greatly simplifies getting an Eclipse based project
into the workbench.

I'm mostly interested in comments on pure bugs. E.g. know it's
blocking when the user selects to import the projects as part of the
clone process, I also know I'm reusing internal messages and not supplying
NLS style constansts for all textx.

Happy New Year!

-- robin


diff --git a/org.spearce.egit.ui/META-INF/MANIFEST.MF b/org.spearce.egit.ui/META-INF/MANIFEST.MF
index 092624f..420801b 100644
--- a/org.spearce.egit.ui/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.ui/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.compare,
  org.spearce.jgit,
  org.spearce.egit.core,
+ org.eclipse.ui.ide,
  org.eclipse.jsch.ui;bundle-version="1.1.100"
 Eclipse-LazyStart: true
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/CloneDestinationPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/CloneDestinationPage.java
index 5173335..c60dd0c 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/CloneDestinationPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/CloneDestinationPage.java
@@ -57,12 +57,13 @@
 
 	private Text remoteText;
 
+	Button showImportWizarad;
+
 	CloneDestinationPage(final RepositorySelectionPage sp,
 			final SourceBranchPage bp) {
 		super(CloneDestinationPage.class.getName());
 		sourcePage = sp;
 		branchPage = bp;
-
 		setTitle(UIText.CloneDestinationPage_title);
 
 		final SelectionChangeListener listener = new SelectionChangeListener() {
@@ -82,7 +83,7 @@ public void createControl(final Composite parent) {
 
 		createDestinationGroup(panel);
 		createConfigGroup(panel);
-
+		createWorkbenchGroup(panel);
 		setControl(panel);
 		checkPage();
 	}
@@ -92,6 +93,8 @@ public void setVisible(final boolean visible) {
 		if (visible)
 			revalidate();
 		super.setVisible(visible);
+		if (visible)
+			directoryText.setFocus();
 	}
 
 	private void checkPreviousPagesSelections() {
@@ -165,6 +168,20 @@ public void modifyText(ModifyEvent e) {
 		});
 	}
 
+	private void createWorkbenchGroup(Composite parent) {
+		final Group g = createGroup(parent, "Workspace import");
+		newLabel(g, "Import projects after clone");
+		showImportWizarad = new Button(g, SWT.CHECK);
+		showImportWizarad.setSelection(true);
+		showImportWizarad.setLayoutData(createFieldGridData());
+		showImportWizarad.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				checkPage();
+			}
+		});
+	}
+
 	private static Group createGroup(final Composite parent, final String text) {
 		final Group g = new Group(parent, SWT.NONE);
 		final GridLayout layout = new GridLayout();
@@ -223,8 +240,9 @@ setErrorMessage(NLS.bind(UIText.CloneDestinationPage_fieldRequired,
 		}
 		final File absoluteFile = new File(dstpath).getAbsoluteFile();
 		if (!isEmptyDir(absoluteFile)) {
-			setErrorMessage(NLS.bind(UIText.CloneDestinationPage_errorNotEmptyDir,
-					absoluteFile.getPath()));
+			setErrorMessage(NLS.bind(
+					UIText.CloneDestinationPage_errorNotEmptyDir, absoluteFile
+							.getPath()));
 			setPageComplete(false);
 			return;
 		}
@@ -316,4 +334,8 @@ private String getSuggestedName() {
 		return path;
 	}
 
+	@Override
+	public boolean canFlipToNextPage() {
+		return super.canFlipToNextPage() && showImportWizarad.getSelection();
+	}
 }
\ No newline at end of file
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitCloneWizard.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitCloneWizard.java
index a69dc52..01d7374 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitCloneWizard.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitCloneWizard.java
@@ -18,11 +18,13 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.ui.IImportWizard;
 import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
 import org.spearce.egit.core.op.CloneOperation;
 import org.spearce.egit.ui.Activator;
 import org.spearce.egit.ui.UIIcons;
@@ -41,6 +43,10 @@
 
 	private CloneDestinationPage cloneDestination;
 
+	private GitProjectsImportPage importProject;
+
+	private String alreadyClonedInto;
+
 	public void init(IWorkbench arg0, IStructuredSelection arg1) {
 		setWindowTitle(UIText.GitCloneWizard_title);
 		setDefaultPageImageDescriptor(UIIcons.WIZBAN_IMPORT_REPO);
@@ -48,6 +54,47 @@ public void init(IWorkbench arg0, IStructuredSelection arg1) {
 		cloneSource = new RepositorySelectionPage(true);
 		validSource = new SourceBranchPage(cloneSource);
 		cloneDestination = new CloneDestinationPage(cloneSource, validSource);
+		importProject = new GitProjectsImportPage() {
+			@Override
+			public void setVisible(boolean visible) {
+				if (visible) {
+					if (alreadyClonedInto == null) {
+						performClone(false);
+						alreadyClonedInto = cloneDestination
+								.getDestinationFile().getAbsolutePath();
+					}
+					setDirectoryPath(alreadyClonedInto);
+					updateProjectsList(alreadyClonedInto);
+				}
+				super.setVisible(visible);
+			}
+		};
+	}
+
+	@Override
+	public boolean performCancel() {
+		if (alreadyClonedInto != null) {
+			if (MessageDialog
+					.openQuestion(getShell(), "Aborting clone.",
+							"A complete clone was already made. Do you want to delete it?")) {
+				deleteRecursively(new File(alreadyClonedInto));
+			}
+		}
+		return true;
+	}
+
+	private void deleteRecursively(File f) {
+		for (File i : f.listFiles()) {
+			if (i.isDirectory()) {
+				deleteRecursively(i);
+			} else {
+				if (!i.delete()) {
+					i.deleteOnExit();
+				}
+			}
+		}
+		if (!f.delete())
+			f.deleteOnExit();
 	}
 
 	@Override
@@ -55,10 +102,24 @@ public void addPages() {
 		addPage(cloneSource);
 		addPage(validSource);
 		addPage(cloneDestination);
+		addPage(importProject);
+	}
+
+	@Override
+	public boolean canFinish() {
+		return cloneDestination.isPageComplete()
+				&& !cloneDestination.showImportWizarad.getSelection()
+				|| importProject.isPageComplete();
 	}
 
 	@Override
 	public boolean performFinish() {
+		if (!cloneDestination.showImportWizarad.getSelection())
+			return performClone(true);
+		return importProject.createProjects();
+	}
+
+	boolean performClone(boolean background) {
 		final URIish uri = cloneSource.getSelection().getURI();
 		final boolean allSelected = validSource.isAllSelected();
 		final Collection<Ref> selectedBranches = validSource
@@ -80,24 +141,37 @@ public boolean performFinish() {
 
 		final CloneOperation op = new CloneOperation(uri, allSelected,
 				selectedBranches, workdir, branch, remoteName);
-		final Job job = new Job(NLS.bind(UIText.GitCloneWizard_jobName, uri
-				.toString())) {
-			@Override
-			protected IStatus run(final IProgressMonitor monitor) {
-				try {
-					op.run(monitor);
-					return Status.OK_STATUS;
-				} catch (InterruptedException e) {
-					return Status.CANCEL_STATUS;
-				} catch (InvocationTargetException e) {
-					Throwable thr = e.getCause();
-					return new Status(IStatus.ERROR, Activator.getPluginId(),
-							0, thr.getMessage(), thr);
+		if (background) {
+			final Job job = new Job(NLS.bind(UIText.GitCloneWizard_jobName, uri
+					.toString())) {
+				@Override
+				protected IStatus run(final IProgressMonitor monitor) {
+					try {
+						op.run(monitor);
+						return Status.OK_STATUS;
+					} catch (InterruptedException e) {
+						return Status.CANCEL_STATUS;
+					} catch (InvocationTargetException e) {
+						Throwable thr = e.getCause();
+						return new Status(IStatus.ERROR, Activator
+								.getPluginId(), 0, thr.getMessage(), thr);
+					}
 				}
+			};
+			job.setUser(true);
+			job.schedule();
+			return true;
+		} else {
+			try {
+				PlatformUI.getWorkbench().getProgressService().run(false, true,
+						op);
+				return true;
+			} catch (Exception e) {
+				Activator.logError("Failed to clone", e);
+				MessageDialog.openError(getShell(), "Failed clone", e
+						.toString());
+				return false;
 			}
-		};
-		job.setUser(true);
-		job.schedule();
-		return true;
+		}
 	}
 }
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitProjectsImportPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitProjectsImportPage.java
new file mode 100644
index 0000000..4241ddf
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/clone/GitProjectsImportPage.java
@@ -0,0 +1,956 @@
+package org.spearce.egit.ui.internal.clone;
+
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Red Hat, Inc - extensive changes to allow importing of Archive Files
+ *     Philippe Ombredanne (pombredanne@nexb.com)
+ *     		- Bug 101180 [Import/Export] Import Existing Project into Workspace default widget is back button , should be text field
+ *     Martin Oberhuber (martin.oberhuber@windriver.com)
+ *     		- Bug 187318[Wizards] "Import Existing Project" loops forever with cyclic symbolic links
+ *     Remy Chi Jian Suen  (remy.suen@gmail.com)
+ *     		- Bug 210568 [Import/Export] [Import/Export] - Refresh button does not update list of projects
+ *     Robin Rosenberg (robin.rosenberg@dewire.com)
+ *     		- Copy for use with Git clone
+ *******************************************************************************/
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.StatusUtil;
+import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
+import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+import org.spearce.egit.core.op.ConnectProviderOperation;
+import org.spearce.egit.ui.Activator;
+
+/**
+ * The GitWizardProjectsImportPage is the page that allows the user to import
+ * projects from a particular location. This is a modified copy of
+ * {@link WizardProjectsImportPage}
+ */
+public class GitProjectsImportPage extends WizardPage {
+
+	/**
+	 * The name of the folder containing metadata information for the workspace.
+	 */
+	public static final String METADATA_FOLDER = ".metadata"; //$NON-NLS-1$
+
+	/**
+	 * The import structure provider.
+	 */
+	private IImportStructureProvider structureProvider;
+
+	class ProjectRecord {
+		File projectSystemFile;
+
+		String projectName;
+
+		Object parent;
+
+		int level;
+
+		IProjectDescription description;
+
+		/**
+		 * Create a record for a project based on the info in the file.
+		 *
+		 * @param file
+		 */
+		ProjectRecord(File file) {
+			projectSystemFile = file;
+			setProjectName();
+		}
+
+		/**
+		 * @param parent
+		 *            The parent folder of the .project file
+		 * @param level
+		 *            The number of levels deep in the provider the file is
+		 */
+		ProjectRecord(Object parent, int level) {
+			this.parent = parent;
+			this.level = level;
+			setProjectName();
+		}
+
+		/**
+		 * Set the name of the project based on the projectFile.
+		 */
+		private void setProjectName() {
+			try {
+				// If we don't have the project name try again
+				if (projectName == null) {
+					IPath path = new Path(projectSystemFile.getPath());
+					// if the file is in the default location, use the directory
+					// name as the project name
+					if (isDefaultLocation(path)) {
+						projectName = path.segment(path.segmentCount() - 2);
+						description = IDEWorkbenchPlugin.getPluginWorkspace()
+								.newProjectDescription(projectName);
+					} else {
+						description = IDEWorkbenchPlugin.getPluginWorkspace()
+								.loadProjectDescription(path);
+						projectName = description.getName();
+					}
+
+				}
+			} catch (CoreException e) {
+				// no good couldn't get the name
+			}
+		}
+
+		/**
+		 * Returns whether the given project description file path is in the
+		 * default location for a project
+		 *
+		 * @param path
+		 *            The path to examine
+		 * @return Whether the given path is the default location for a project
+		 */
+		private boolean isDefaultLocation(IPath path) {
+			// The project description file must at least be within the project,
+			// which is within the workspace location
+			if (path.segmentCount() < 2)
+				return false;
+			return path.removeLastSegments(2).toFile().equals(
+					Platform.getLocation().toFile());
+		}
+
+		/**
+		 * Get the name of the project
+		 *
+		 * @return String
+		 */
+		public String getProjectName() {
+			return projectName;
+		}
+
+		/**
+		 * Gets the label to be used when rendering this project record in the
+		 * UI.
+		 *
+		 * @return String the label
+		 * @since 3.4
+		 */
+		public String getProjectLabel() {
+			if (description == null)
+				return projectName;
+
+			String path = projectSystemFile == null ? structureProvider
+					.getLabel(parent) : projectSystemFile.getParent();
+
+			return NLS.bind(
+					DataTransferMessages.WizardProjectsImportPage_projectLabel,
+					projectName, path);
+		}
+	}
+
+	private Text directoryPathField;
+
+	private CheckboxTreeViewer projectsList;
+
+	private ProjectRecord[] selectedProjects = new ProjectRecord[0];
+
+	// Keep track of the directory that we browsed to last time
+	// the wizard was invoked.
+	private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$
+
+	private Button browseDirectoriesButton;
+
+	private IProject[] wsProjects;
+
+	// The last selected path to minimize searches
+	private String lastPath;
+
+	// The last time that the file or folder at the selected path was modified
+	// to mimize searches
+	private long lastModified;
+
+	private Button shareCheckBox;
+
+	private boolean share;
+
+	/**
+	 * Creates a new project creation wizard page.
+	 */
+	public GitProjectsImportPage() {
+		this("gitWizardExternalProjectsPage"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Create a new instance of the receiver.
+	 *
+	 * @param pageName
+	 */
+	public GitProjectsImportPage(String pageName) {
+		super(pageName);
+		setPageComplete(false);
+		setTitle(DataTransferMessages.WizardProjectsImportPage_ImportProjectsTitle);
+		setDescription(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 *
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+
+		initializeDialogUnits(parent);
+
+		Composite workArea = new Composite(parent, SWT.NONE);
+		setControl(workArea);
+
+		workArea.setLayout(new GridLayout());
+		workArea.setLayoutData(new GridData(GridData.FILL_BOTH
+				| GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+
+		createProjectsRoot(workArea);
+		createProjectsList(workArea);
+		createOptionsArea(workArea);
+		Dialog.applyDialogFont(workArea);
+
+	}
+
+	/**
+	 * Create the area with the extra options.
+	 *
+	 * @param workArea
+	 */
+	private void createOptionsArea(Composite workArea) {
+		Composite optionsGroup = new Composite(workArea, SWT.NONE);
+		optionsGroup.setLayout(new GridLayout());
+		optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		shareCheckBox = new Button(optionsGroup, SWT.CHECK);
+		shareCheckBox
+				.setText("Enable Git Team operations on imported projects");
+		shareCheckBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		shareCheckBox.setSelection(share = true);
+		shareCheckBox.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				share = shareCheckBox.getSelection();
+			}
+		});
+	}
+
+	/**
+	 * Create the checkbox list for the found projects.
+	 *
+	 * @param workArea
+	 */
+	private void createProjectsList(Composite workArea) {
+
+		Label title = new Label(workArea, SWT.NONE);
+		title
+				.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
+
+		Composite listComposite = new Composite(workArea, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		layout.marginWidth = 0;
+		layout.makeColumnsEqualWidth = false;
+		listComposite.setLayout(layout);
+
+		listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+				| GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
+
+		projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
+		GridData listData = new GridData(GridData.GRAB_HORIZONTAL
+				| GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
+		projectsList.getControl().setLayoutData(listData);
+
+		projectsList.setContentProvider(new ITreeContentProvider() {
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
+			 * .lang.Object)
+			 */
+			public Object[] getChildren(Object parentElement) {
+				return null;
+			}
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements
+			 * (java.lang.Object)
+			 */
+			public Object[] getElements(Object inputElement) {
+				return getValidProjects();
+			}
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
+			 * .lang.Object)
+			 */
+			public boolean hasChildren(Object element) {
+				return false;
+			}
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
+			 * .lang.Object)
+			 */
+			public Object getParent(Object element) {
+				return null;
+			}
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+			 */
+			public void dispose() {
+
+			}
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
+			 * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+			 */
+			public void inputChanged(Viewer viewer, Object oldInput,
+					Object newInput) {
+			}
+
+		});
+
+		projectsList.setLabelProvider(new LabelProvider() {
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+			 */
+			public String getText(Object element) {
+				return ((ProjectRecord) element).getProjectLabel();
+			}
+		});
+
+		projectsList.addCheckStateListener(new ICheckStateListener() {
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
+			 * (org.eclipse.jface.viewers.CheckStateChangedEvent)
+			 */
+			public void checkStateChanged(CheckStateChangedEvent event) {
+				setPageComplete(projectsList.getCheckedElements().length > 0);
+			}
+		});
+
+		projectsList.setInput(this);
+		projectsList.setComparator(new ViewerComparator());
+		createSelectionButtons(listComposite);
+	}
+
+	/**
+	 * Create the selection buttons in the listComposite.
+	 *
+	 * @param listComposite
+	 */
+	private void createSelectionButtons(Composite listComposite) {
+		Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.marginWidth = 0;
+		layout.marginHeight = 0;
+		buttonsComposite.setLayout(layout);
+
+		buttonsComposite.setLayoutData(new GridData(
+				GridData.VERTICAL_ALIGN_BEGINNING));
+
+		Button selectAll = new Button(buttonsComposite, SWT.PUSH);
+		selectAll.setText(DataTransferMessages.DataTransfer_selectAll);
+		selectAll.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				projectsList.setCheckedElements(selectedProjects);
+				setPageComplete(projectsList.getCheckedElements().length > 0);
+			}
+		});
+		Dialog.applyDialogFont(selectAll);
+		setButtonLayoutData(selectAll);
+
+		Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
+		deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
+		deselectAll.addSelectionListener(new SelectionAdapter() {
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+			 * .swt.events.SelectionEvent)
+			 */
+			public void widgetSelected(SelectionEvent e) {
+
+				projectsList.setCheckedElements(new Object[0]);
+				setPageComplete(false);
+			}
+		});
+		Dialog.applyDialogFont(deselectAll);
+		setButtonLayoutData(deselectAll);
+
+		Button refresh = new Button(buttonsComposite, SWT.PUSH);
+		refresh.setText(DataTransferMessages.DataTransfer_refresh);
+		refresh.addSelectionListener(new SelectionAdapter() {
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+			 * .swt.events.SelectionEvent)
+			 */
+			public void widgetSelected(SelectionEvent e) {
+				updateProjectsList(directoryPathField.getText().trim());
+			}
+		});
+		Dialog.applyDialogFont(refresh);
+		setButtonLayoutData(refresh);
+	}
+
+	/**
+	 * Create the area where you select the root directory for the projects.
+	 *
+	 * @param workArea
+	 *            Composite
+	 */
+	private void createProjectsRoot(Composite workArea) {
+
+		// project specification group
+		Composite projectGroup = new Composite(workArea, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 3;
+		layout.makeColumnsEqualWidth = false;
+		layout.marginWidth = 0;
+		projectGroup.setLayout(layout);
+		projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		// project location entry field
+		this.directoryPathField = new Text(projectGroup, SWT.BORDER);
+
+		this.directoryPathField.setLayoutData(new GridData(
+				GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+
+		// browse button
+		browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
+		browseDirectoriesButton
+				.setText(DataTransferMessages.DataTransfer_browse);
+		setButtonLayoutData(browseDirectoriesButton);
+
+		browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see org.eclipse.swt.events.SelectionAdapter#widgetS
+			 * elected(org.eclipse.swt.events.SelectionEvent)
+			 */
+			public void widgetSelected(SelectionEvent e) {
+				handleLocationDirectoryButtonPressed();
+			}
+
+		});
+
+		directoryPathField.addTraverseListener(new TraverseListener() {
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse
+			 * .swt.events.TraverseEvent)
+			 */
+			public void keyTraversed(TraverseEvent e) {
+				if (e.detail == SWT.TRAVERSE_RETURN) {
+					e.doit = false;
+					updateProjectsList(directoryPathField.getText().trim());
+				}
+			}
+
+		});
+
+		directoryPathField.addFocusListener(new FocusAdapter() {
+
+			/*
+			 * (non-Javadoc)
+			 *
+			 * @see
+			 * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt
+			 * .events.FocusEvent)
+			 */
+			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
+				updateProjectsList(directoryPathField.getText().trim());
+			}
+
+		});
+
+	}
+
+	/*
+	 * (non-Javadoc) Method declared on IDialogPage. Set the focus on path
+	 * fields when page becomes visible.
+	 */
+	public void setVisible(boolean visible) {
+		super.setVisible(visible);
+		this.directoryPathField.setFocus();
+	}
+
+	/**
+	 * Update the list of projects based on path.
+	 *
+	 * @param path
+	 */
+	void updateProjectsList(final String path) {
+		// on an empty path empty selectedProjects
+		if (path == null || path.length() == 0) {
+			setMessage(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
+			selectedProjects = new ProjectRecord[0];
+			projectsList.refresh(true);
+			projectsList.setCheckedElements(selectedProjects);
+			setPageComplete(projectsList.getCheckedElements().length > 0);
+			lastPath = path;
+			return;
+		}
+
+		final File directory = new File(path);
+		long modified = directory.lastModified();
+		if (path.equals(lastPath) && lastModified == modified) {
+			// since the file/folder was not modified and the path did not
+			// change, no refreshing is required
+			return;
+		}
+
+		lastPath = path;
+		lastModified = modified;
+
+		try {
+			getContainer().run(true, true, new IRunnableWithProgress() {
+
+				/*
+				 * (non-Javadoc)
+				 *
+				 * @see
+				 * org.eclipse.jface.operation.IRunnableWithProgress#run(org
+				 * .eclipse.core.runtime.IProgressMonitor)
+				 */
+				public void run(IProgressMonitor monitor) {
+
+					monitor
+							.beginTask(
+									DataTransferMessages.WizardProjectsImportPage_SearchingMessage,
+									100);
+					selectedProjects = new ProjectRecord[0];
+					Collection files = new ArrayList();
+					monitor.worked(10);
+					if (directory.isDirectory()) {
+
+						if (!collectProjectFilesFromDirectory(files, directory,
+								null, monitor)) {
+							return;
+						}
+						Iterator filesIterator = files.iterator();
+						selectedProjects = new ProjectRecord[files.size()];
+						int index = 0;
+						monitor.worked(50);
+						monitor
+								.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
+						while (filesIterator.hasNext()) {
+							File file = (File) filesIterator.next();
+							selectedProjects[index] = new ProjectRecord(file);
+							index++;
+						}
+					} else {
+						monitor.worked(60);
+					}
+					monitor.done();
+				}
+
+			});
+		} catch (InvocationTargetException e) {
+			IDEWorkbenchPlugin.log(e.getMessage(), e);
+		} catch (InterruptedException e) {
+			// Nothing to do if the user interrupts.
+		}
+
+		projectsList.refresh(true);
+		projectsList.setCheckedElements(getValidProjects());
+		if (getValidProjects().length < selectedProjects.length) {
+			setMessage(
+					DataTransferMessages.WizardProjectsImportPage_projectsInWorkspace,
+					WARNING);
+		} else {
+			setMessage(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
+		}
+		setPageComplete(projectsList.getCheckedElements().length > 0);
+	}
+
+	/**
+	 * Display an error dialog with the specified message.
+	 *
+	 * @param message
+	 *            the error message
+	 */
+	protected void displayErrorDialog(String message) {
+		MessageDialog.openError(getContainer().getShell(),
+				getErrorDialogTitle(), message);
+	}
+
+	/**
+	 * @return the title for an error dialog. Subclasses should override.
+	 */
+	protected String getErrorDialogTitle() {
+		return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle;
+	}
+
+	/**
+	 * Collect the list of .project files that are under directory into files.
+	 *
+	 * @param files
+	 * @param directory
+	 * @param directoriesVisited
+	 *            Set of canonical paths of directories, used as recursion guard
+	 * @param monitor
+	 *            The monitor to report to
+	 * @return boolean <code>true</code> if the operation was completed.
+	 */
+	private boolean collectProjectFilesFromDirectory(Collection files,
+			File directory, Set directoriesVisited, IProgressMonitor monitor) {
+
+		if (monitor.isCanceled()) {
+			return false;
+		}
+		monitor.subTask(NLS.bind(
+				DataTransferMessages.WizardProjectsImportPage_CheckingMessage,
+				directory.getPath()));
+		File[] contents = directory.listFiles();
+		if (contents == null)
+			return false;
+
+		// Initialize recursion guard for recursive symbolic links
+		if (directoriesVisited == null) {
+			directoriesVisited = new HashSet();
+			try {
+				directoriesVisited.add(directory.getCanonicalPath());
+			} catch (IOException exception) {
+				StatusManager.getManager().handle(
+						StatusUtil.newStatus(IStatus.ERROR, exception
+								.getLocalizedMessage(), exception));
+			}
+		}
+
+		// first look for project description files
+		final String dotProject = IProjectDescription.DESCRIPTION_FILE_NAME;
+		for (int i = 0; i < contents.length; i++) {
+			File file = contents[i];
+			if (file.isFile() && file.getName().equals(dotProject)) {
+				files.add(file);
+				// don't search sub-directories since we can't have nested
+				// projects
+				return true;
+			}
+		}
+		// no project description found, so recurse into sub-directories
+		for (int i = 0; i < contents.length; i++) {
+			if (contents[i].isDirectory()) {
+				if (!contents[i].getName().equals(METADATA_FOLDER)) {
+					try {
+						String canonicalPath = contents[i].getCanonicalPath();
+						if (!directoriesVisited.add(canonicalPath)) {
+							// already been here --> do not recurse
+							continue;
+						}
+					} catch (IOException exception) {
+						StatusManager.getManager().handle(
+								StatusUtil.newStatus(IStatus.ERROR, exception
+										.getLocalizedMessage(), exception));
+
+					}
+					collectProjectFilesFromDirectory(files, contents[i],
+							directoriesVisited, monitor);
+				}
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * The browse button has been selected. Select the location.
+	 */
+	protected void handleLocationDirectoryButtonPressed() {
+
+		DirectoryDialog dialog = new DirectoryDialog(directoryPathField
+				.getShell());
+		dialog
+				.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);
+
+		String dirName = directoryPathField.getText().trim();
+		if (dirName.length() == 0) {
+			dirName = previouslyBrowsedDirectory;
+		}
+
+		if (dirName.length() == 0) {
+			dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace()
+					.getRoot().getLocation().toOSString());
+		} else {
+			File path = new File(dirName);
+			if (path.exists()) {
+				dialog.setFilterPath(new Path(dirName).toOSString());
+			}
+		}
+
+		String selectedDirectory = dialog.open();
+		if (selectedDirectory != null) {
+			previouslyBrowsedDirectory = selectedDirectory;
+			directoryPathField.setText(previouslyBrowsedDirectory);
+			updateProjectsList(selectedDirectory);
+		}
+
+	}
+
+	void setDirectoryPath(String path) {
+		directoryPathField.setText(path);
+	}
+
+	/**
+	 * Create the selected projects
+	 *
+	 * @return boolean <code>true</code> if all project creations were
+	 *         successful.
+	 */
+	boolean createProjects() {
+		final Object[] selected = projectsList.getCheckedElements();
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+			protected void execute(IProgressMonitor monitor)
+					throws InvocationTargetException, InterruptedException {
+				try {
+					monitor.beginTask("", selected.length); //$NON-NLS-1$
+					if (monitor.isCanceled()) {
+						throw new OperationCanceledException();
+					}
+					for (int i = 0; i < selected.length; i++) {
+						createExistingProject((ProjectRecord) selected[i],
+								new SubProgressMonitor(monitor, 1));
+					}
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		// run the new project creation operation
+		try {
+			getContainer().run(true, true, op);
+		} catch (InterruptedException e) {
+			return false;
+		} catch (InvocationTargetException e) {
+			// one of the steps resulted in a core exception
+			Throwable t = e.getTargetException();
+			String message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage;
+			IStatus status;
+			if (t instanceof CoreException) {
+				status = ((CoreException) t).getStatus();
+			} else {
+				status = new Status(IStatus.ERROR,
+						IDEWorkbenchPlugin.IDE_WORKBENCH, 1, message, t);
+			}
+			Activator.logError(message, t);
+			ErrorDialog.openError(getShell(), message, null, status);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Create the project described in record. If it is successful return true.
+	 *
+	 * @param record
+	 * @param monitor
+	 * @return boolean <code>true</code> if successful
+	 * @throws InvocationTargetException
+	 * @throws InterruptedException
+	 */
+	private boolean createExistingProject(final ProjectRecord record,
+			IProgressMonitor monitor) throws InvocationTargetException,
+			InterruptedException {
+		String projectName = record.getProjectName();
+		final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		final IProject project = workspace.getRoot().getProject(projectName);
+		if (record.description == null) {
+			// error case
+			record.description = workspace.newProjectDescription(projectName);
+			IPath locationPath = new Path(record.projectSystemFile
+					.getAbsolutePath());
+
+			// If it is under the root use the default location
+			if (Platform.getLocation().isPrefixOf(locationPath)) {
+				record.description.setLocation(null);
+			} else {
+				record.description.setLocation(locationPath);
+			}
+		} else {
+			record.description.setName(projectName);
+		}
+
+		try {
+			monitor
+					.beginTask(
+							DataTransferMessages.WizardProjectsImportPage_CreateProjectsTask,
+							100);
+			project.create(record.description, new SubProgressMonitor(monitor,
+					30));
+			int openTicks = share ? 50 : 70;
+			project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(
+					monitor, openTicks));
+			if (share) {
+				ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation(
+						project, null);
+				connectProviderOperation
+						.run(new SubProgressMonitor(monitor, 20));
+			}
+		} catch (CoreException e) {
+			throw new InvocationTargetException(e);
+		} finally {
+			monitor.done();
+		}
+
+		return true;
+	}
+
+	/**
+	 * Method used for test suite.
+	 *
+	 * @return CheckboxTreeViewer the viewer containing all the projects found
+	 */
+	public CheckboxTreeViewer getProjectsList() {
+		return projectsList;
+	}
+
+	/**
+	 * Retrieve all the projects in the current workspace.
+	 *
+	 * @return IProject[] array of IProject in the current workspace
+	 */
+	private IProject[] getProjectsInWorkspace() {
+		if (wsProjects == null) {
+			wsProjects = IDEWorkbenchPlugin.getPluginWorkspace().getRoot()
+					.getProjects();
+		}
+		return wsProjects;
+	}
+
+	/**
+	 * Get the array of valid project records that can be imported from the
+	 * source workspace or archive, selected by the user. If a project with the
+	 * same name exists in both the source workspace and the current workspace,
+	 * it will not appear in the list of projects to import and thus cannot be
+	 * selected for import.
+	 *
+	 * Method declared public for test suite.
+	 *
+	 * @return ProjectRecord[] array of projects that can be imported into the
+	 *         workspace
+	 */
+	public ProjectRecord[] getValidProjects() {
+		List validProjects = new ArrayList();
+		for (int i = 0; i < selectedProjects.length; i++) {
+			if (!isProjectInWorkspace(selectedProjects[i].getProjectName())) {
+				validProjects.add(selectedProjects[i]);
+			}
+		}
+		return (ProjectRecord[]) validProjects
+				.toArray(new ProjectRecord[validProjects.size()]);
+	}
+
+	/**
+	 * Determine if the project with the given name is in the current workspace.
+	 *
+	 * @param projectName
+	 *            String the project name to check
+	 * @return boolean true if the project with the given name is in this
+	 *         workspace
+	 */
+	private boolean isProjectInWorkspace(String projectName) {
+		if (projectName == null) {
+			return false;
+		}
+		IProject[] workspaceProjects = getProjectsInWorkspace();
+		for (int i = 0; i < workspaceProjects.length; i++) {
+			if (projectName.equals(workspaceProjects[i].getName())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RepositorySelectionPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RepositorySelectionPage.java
index 86cf6ec..f656518 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RepositorySelectionPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RepositorySelectionPage.java
@@ -660,4 +660,11 @@ private void updateAuthGroup() {
 			break;
 		}
 	}
+
+	@Override
+	public void setVisible(boolean visible) {
+		super.setVisible(visible);
+		if (visible)
+			uriText.setFocus();
+	}
 }
-- 
1.6.1.rc3.56.gd0306

^ permalink raw reply related

* RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Conor Rafferty @ 2008-12-31 10:59 UTC (permalink / raw)
  To: Jeff Whiteside; +Cc: Daniel Barkalow, Boyd Stephen Smith Jr., git

Haha, no probs

Neither does the job

I either need to figure out how the indexes get involved in the dot
version,
Or give in and create a branch - that's how you guys work mainly, so
that use case will no doubt work 
Or find something else to do the job - mercurial looks promising

-----Original Message-----
From: Jeff Whiteside [mailto:jeff.m.whiteside@gmail.com] 
Sent: 31 December 2008 02:36
To: Conor Rafferty
Cc: Daniel Barkalow; Boyd Stephen Smith Jr.; git@vger.kernel.org
Subject: Re: for newbs = little exercise / tutorial / warmup for windows
and other non-sophisticated new Git users :-) [Scanned]

sir, i believe you're not reading what is typed.

> wtf is wrong with
>
> git checkout <something>
>
> ??
>
> ** It doesn't reliably put the files that were in that revision into 
> the working directory - a fairly major flaw, for what I'm using SCM 
> for (and 80% of the market IMHO)

yes it does.  your example uses "git checkout versionB .", which is NOT
"git checkout <something>"
we are suggesting you do "git checkout versionB" which is different
(HINT: there is NO dot), and which i'm 99% positive will work.

if you still disagree, then i'm sure mercurial will be sufficient for
your needs, and all your dcvs book-lernin' over christmas will be
transferrable.

good luck with whatever option you choose.

^ permalink raw reply

* RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Conor Rafferty @ 2008-12-31 11:10 UTC (permalink / raw)
  To: Boyd Stephen Smith Jr.; +Cc: Jeff Whiteside, Daniel Barkalow, git


And you would be wrong, IMHO.  Many people have untracked files or
directories in their working directory ('cause they are working there)
that they don't want deleted willy-nilly.  Build files, modifications
that should be on a different branch, etc.  There's another thread
active on the list complaining that git removes too much from the
working tree.

** An SCM should be able to cope with both use cases. In fact I make it
easy for the SCM by deleting EVERYTHING from the working directory,
before calling git-checkout.

Most users of SCMs do make active modifications to the files in the SCM.
It's not a system only for archiving static projects.

** Archiving static projects is not the ONLY thing I want to do with my
SCM, it just happens to be the FIRST thing.

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Zorba @ 2008-12-31 12:03 UTC (permalink / raw)
  To: git
In-Reply-To: <alpine.LNX.1.00.0812302143210.19665@iabervon.org>

Ok, starting from scratch, new dir, new repo

I can now get $ git checkout <version> to work (see extract below, missed 
the first few lines due to exceeding buffer)

The difference with the instance when I found "errors" is that that time I'd 
run $ git checkout <version> .
a few times first, which as I now know, would have been making updates to 
the index all along.

I presume this is what screwed things up for the normal checkout situation, 
because when I ran $ git checkout <version> on all the versions, there were 
always less files than I expected in the working dir

Still not sure if I can trust $ git checkout <version>...

Why should

$ git checkout <version> .

screw things up for

$ git checkout <version>

?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

BC

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ cat > AC.txt
AC


conorr@KINKLADZE /w/GITPLATFORM/swproj
$ cat > C.txt
C

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git init
Initialized empty Git repository in w:/GITPLATFORM/swproj/.git/

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git add ABC.txt AC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git commit -m "version A"
Created initial commit 8ce0d2c: version A
 2 files changed, 3 insertions(+), 0 deletions(-)
 create mode 100644 ABC.txt
 create mode 100644 AC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git tag versiona 8ce0

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git rm AC.txt
rm 'AC.txt'

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git add BC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    AC.txt
#       new file:   BC.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git commit -m "version B"
Created commit fad9c29: version B
 2 files changed, 1 insertions(+), 2 deletions(-)
 delete mode 100644 AC.txt
 create mode 100644 BC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git tag versionB fad9

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ cat > AC.txt
AC

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git commit -m "version C"
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       AC.txt
#       C.txt
nothing added to commit but untracked files present (use "git add" to track)

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ // mistake - forgot to stage changes
sh.exe": //: is a directory

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git reset --hard versionB
HEAD is now at fad9c29 version B

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git add *c*.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   AC.txt
#       new file:   C.txt
#

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git commit -m "version C"
Created commit 9cf73cb: version C
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 AC.txt
 create mode 100644 C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git tag versionC 9cf7

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git rm *.*
rm 'ABC.txt'
rm 'AC.txt'
rm 'BC.txt'
rm 'C.txt'

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git commit -m "version D"
Created commit 8e4b5be: version D
 4 files changed, 0 insertions(+), 4 deletions(-)
 delete mode 100644 ABC.txt
 delete mode 100644 AC.txt
 delete mode 100644 BC.txt
 delete mode 100644 C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git tag versionD 8e4b

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git status
# On branch master
nothing to commit (working directory clean)

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ gitk

conorr@KINKLADZE /w/GITPLATFORM/swproj
<sionA = ABC.txt, AC.txt, version B = ABC.txt, BC.txt
sh.exe": //: is a directory

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ cat > commet.txt// gitk confirms that versionA = ABC.txt, AC.txt,
sh.exe": commet.txt//: No such file or directory

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ cat > comment.txt
gitk confirms that:
versionA = ABC.txt, AC.txt
versionB = ABC.txt, BC.txt
versionC = ABC.txt, AC.txt, BC.txt, C.txt
versionD =

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ gitk

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git show
WARNING: terminal is not fully functional
commit 8e4b5bed1faadc608fc114e62bf1859b6bbed4a0
Author: Conor Rafferty <cr@altmore.co.uk>
Date:   Wed Dec 31 11:40:45 2008 +0000

    version D

diff --git a/ABC.txt b/ABC.txt
deleted file mode 100644
index 83871a5..0000000
--- a/ABC.txt
+++ /dev/null
@@ -1 +0,0 @@
-ABC
diff --git a/AC.txt b/AC.txt
deleted file mode 100644
index 9eadfae..0000000
--- a/AC.txt
+++ /dev/null
@@ -1 +0,0 @@
-AC
diff --git a/BC.txt b/BC.txt
deleted file mode 100644
index b3ac6f5..0000000
--- a/BC.txt
+++ /dev/null
@@ -1 +0,0 @@
-BC
diff --git a/C.txt b/C.txt
deleted file mode 100644
index 06a63fe..0000000
--- a/C.txt
+++ /dev/null
@@ -1 +0,0 @@
-C
(END)
conorr@KINKLADZE /w/GITPLATFORM/swproj
$

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionA
Note: moving to "versionA" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b <new_branch_name>
HEAD is now at 8ce0d2c... version A

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  comment.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionB
Previous HEAD position was 8ce0d2c... version A
HEAD is now at fad9c29... version B

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  BC.txt  comment.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionC
Previous HEAD position was fad9c29... version B
HEAD is now at 9cf73cb... version C

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt  comment.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionD
Previous HEAD position was 9cf73cb... version C
HEAD is now at 8e4b5be... version D

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
comment.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ rm *.*

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionA
Previous HEAD position was 8e4b5be... version D
HEAD is now at 8ce0d2c... version A

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionB
Previous HEAD position was 8ce0d2c... version A
HEAD is now at fad9c29... version B

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  BC.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionC
Previous HEAD position was fad9c29... version B
HEAD is now at 9cf73cb... version C

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls
ABC.txt  AC.txt  BC.txt  C.txt

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ git checkout versionD
Previous HEAD position was 9cf73cb... version C
HEAD is now at 8e4b5be... version D

conorr@KINKLADZE /w/GITPLATFORM/swproj
$ ls

conorr@KINKLADZE /w/GITPLATFORM/swproj
$

"Daniel Barkalow" <barkalow@iabervon.org> wrote in message
>
>> wtf is wrong with
>>
>> git checkout <something>
>>
>> ??
>>
>> ** It doesn't reliably put the files that were in that revision into the
>> working directory - a fairly major flaw, for what I'm using SCM for (and
>> 80% of the market IMHO)
>
> It certainly does for me; I rely on it pretty much constantly. Can you
> give a sequence of commands (ideally the whole sequence from the "git
> init") that leads to a difference?

^ permalink raw reply related

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Zorba @ 2008-12-31 12:17 UTC (permalink / raw)
  To: git
In-Reply-To: <alpine.LNX.1.00.0812302236190.19665@iabervon.org>

Ok, now I'm following you, cos I just "broke" checkout again by deleting 
files from working dirs before running it.

git-checkout takes into account the state of the working tree in the commit 
it is run FROM, as well as the commit it is checking out.

It relies on the working tree being in synch with the commit it is run from.
If I delete files, I screw around with this initial state.
Files that git-checkout is relying on to be there are not copied in by it, 
so if I've deleted (or modified) those files, hard luck.

I remember s/o saying git minimizes file I/O, and this whats happening here.

It puts a big demand on the user, to keep their index & working dir in synch 
with whats in the commit.

Ah,

$ git checkout .

will restore the state of the working dir to be in synch with the CURRENT 
commit, so it will be safe to checkout other branches

BINGO !!
what I need to do is run the sequence

$ git checkout .                    // tidy up current commit
$ git checkout <version>     // roll back

n'est pas ?


"Daniel Barkalow" <barkalow@iabervon.org> wrote in message 
news:alpine.LNX.1.00.0812302236190.19665@iabervon.org...
> On Tue, 30 Dec 2008, Daniel Barkalow wrote:
>
>> On Wed, 31 Dec 2008, Conor Rafferty wrote:
>>
>> > -----Original Message-----
>> > wtf is wrong with
>> >
>> > git checkout <something>
>> >
>> > ??
>> >
>> > ** It doesn't reliably put the files that were in that revision into 
>> > the
>> > working directory - a fairly major flaw, for what I'm using SCM for 
>> > (and
>> > 80% of the market IMHO)
>>
>> It certainly does for me; I rely on it pretty much constantly. Can you
>> give a sequence of commands (ideally the whole sequence from the "git
>> init") that leads to a difference?
>
> Actually, I know what you must be doing:
>
> $ git tag versionD
> $ git checkout versionA
> (versionA in the working directory)
> $ rm *.*
> (versionA with ABC.txt and AC.txt deleted)
> $ git checkout versionB
> (versionB with ABC.txt and AC.txt deleted)
>
> If you've made any changes (including deleting files), "git checkout" (no
> pathes) will preserve them. On the other hand, it will remove files that
> are in the commit you're leaving and not in the commit you're going to. So
> just don't remove the working directory files and you should be all set.
>
> In order to get them back if you have removed them, you can do:
>
> $ git checkout .
>
> This will discard all of the changes you've made only to the working
> directory; i.e., it'll recover the deleted files. You should also try "git
> status" whenever anything's mysterious, because it will tell you what's
> going on.
>
> -Daniel
> *This .sig left intentionally blank* 

^ permalink raw reply

* Re: git push over http - curl PUT error?
From: aaron smith @ 2008-12-31 13:29 UTC (permalink / raw)
  To: git
In-Reply-To: <d7ac1a680812310210r25795e66x35601059103892d7@mail.gmail.com>

ok, duh, i had to use git http-push. What is the difference? Thanks.

On Wed, Dec 31, 2008 at 2:10 AM, aaron smith
<beingthexemplarylists@gmail.com> wrote:
> hey all,
>
> I have one last issue to figure out with git over HTTP. This one is
> seriously stumping me.
>
> I have a bare git repository here: http://codeendeavor.com/guttershark.git/
>
> And I have a local git repo with some files in it, ready to push to
> this public one.
>
> Here's what I do to push to it:
>
> $git push origin master
>
> I then get this output:
> ""
> Fetching remote heads...
>  refs/
>  refs/heads/
>  refs/tags/
> updating 'refs/heads/master'
>  from a08e614723ff57047522511a2130d53010ebe0ca
>  to   2db4bca0d137f4099973387472cf1666d0290e03
>    sending 3 objects
>    done
> Updating remote server info
> PUT error: curl result=22, HTTP code=403
> """
>
> I'm not sure how to get around this.
>
> The git repo permissions are 777, with owner/group apache:apache. I
> have DAV on, and the DavLockDB directive. which seems to all be ok.
> And I don't have any http authentication on it.. or access control
> list for that matter.
>
> Any ideas? Thanks All!
>

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Sitaram Chamarty @ 2008-12-31 13:37 UTC (permalink / raw)
  To: git
In-Reply-To: <gjfn28$3k2$4@ger.gmane.org>

a quick comment: you don't need to use the sha1 to create a
tag at the current HEAD.  "git tag newtag sha" can be
shortened to "git tag newtag" if the sha is for the latest
commit you did.  Like the "." thing, I'd be curious where
you picked up this habit...

On 2008-12-31, Zorba <cr@altmore.co.uk> wrote:
> Why should
>
> $ git checkout <version> .
>
> screw things up for
>
> $ git checkout <version>

These are quite different operations so yes you could say
they should have used some other name instead of overloading
two different functions on the same command.  But to be
fair, the doc is fairly clear, in the first 2 paras.

And really, if I understand all your angst and what you're
trying to do, you just have to stop using the "." and -- if
you want untracked files gone each time you switch to an
older version -- use git clean.  See below.

I have snipped your log heavily but it should still be
fairly simple to follow which piece I am referring to below:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> $ git rm AC.txt
> $ git add BC.txt
> $ git commit -m "version B"
> $ git tag versionB fad9

> $ cat > AC.txt
> $ ls
> ABC.txt  AC.txt  BC.txt  C.txt

> $ git reset --hard versionB
> HEAD is now at fad9c29 version B
> $ ls
> ABC.txt  AC.txt  BC.txt  C.txt

you're wondering why AC.txt is still hanging around when
resetting to a commit where that file was explicitly
deleted?

A commit represents a state, not a set of actions.

"versionB" doesn't represent a "delete of AC.txt", plus an
"add of BC.txt".  It represents a state where ABC.txt and
BC.txt exist, that's it.

So AC.txt is now just an untracked file at the point you do
the reset, as you would have seen if you did a "git status".

A reset will not touch untracked files -- hardly any
operation will touch an untracked file actually.

If you really want that functionality, use git clean after
the reset, this is the only command I know that deletes
untracked files:
        git clean -d -f
        # or first try with "-n" for a "dry-run"

[later]

> $ git checkout versionA
> $ ls
> ABC.txt  AC.txt  comment.txt

> $ git checkout versionB
> $ ls
> ABC.txt  BC.txt  comment.txt

And now you're wondering what happened to "AC.txt"?  Well
this time it's a known and tracked file for the current
state (versionA), so it is a candidate for removal/change as
dictated by the new state you're going to.

I should also mention that you have not yet tried the case
where you have local modifications to some file that is
known to both the current branch and the branch you're
switching to.  "git help checkout" and look for the word
"merge" and read up the two places it is relevant to this
context (one a description and one an example).

^ permalink raw reply

* Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
From: Sitaram Chamarty @ 2008-12-31 13:48 UTC (permalink / raw)
  To: git
In-Reply-To: <gjfnsb$5ph$4@ger.gmane.org>

On 2008-12-31, Zorba <cr@altmore.co.uk> wrote:
> It puts a big demand on the user, to keep their index & working dir in synch 
> with whats in the commit.

or they could just use "git checkout -f tag_to_goto" I
suppose...

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox