Git development
 help / color / mirror / Atom feed
* Re: git-branch --print-current
From: Junio C Hamano @ 2009-01-05  3:55 UTC (permalink / raw)
  To: Shawn O. Pearce
  Cc: demerphq, Karl Chen, Miklos Vajna, David Aguilar,
	Git mailing list
In-Reply-To: <20090105021832.GA20973@spearce.org>

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Junio C Hamano <gitster@pobox.com> wrote:
>> demerphq <demerphq@gmail.com> writes:
>> 
>> > The version im using, from git version 1.6.0.4.724.ga0d3a produces the
>> > following error:
>> >
>> > cut: ./HEAD: No such file or directory
>> >
>> > when in the .git/refs directory.
>> 
>> Personally, I think you are nuts to be in .git/refs and want to use that
>> information for anything useful, but if it is an easy enough fix, a patch
>> would be useful.
>
> I agree, its nuts to be there.  But this also does show up in 1.6.1.
> What's odd is the output of rev-parse --git-dir is wrong:
>
>   $ cd .git/refs
>   $ git rev-parse --git-dir
>   .
>
> Its *not* ".", its "..", I'm *in* the directory.  This throws off
> a lot of the other operations we do in __git_ps1, like detecting
> the repository state by checking MERGE_HEAD or rebase-apply.
>
> I think we should fix rev-parse --git-dir if we can, not the bash
> completion code.

Sigh, yeah, that is what I thought would be happening.

^ permalink raw reply

* [PATCH] Permit a wider range of repository names in jgit daemon requests
From: Shawn O. Pearce @ 2009-01-05  2:46 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <200901040048.01520.robin.rosenberg@dewire.com>

The earlier restriction was too narrow for some applications, for
example repositories named "jgit.dev" and "jgit.test" are perfectly
valid Git repositories and should still be able to be served by
the daemon.

By blocking out only uses of ".." as a path component and Windows
UNC paths (by blocking "\") we can reasonably prevent the client
from escaping the base dirctories configured in the daemon.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
  Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
  > tisdag 23 december 2008 01:27:23 skrev Shawn O. Pearce:
  > > +	private static final Pattern SAFE_REPOSITORY_NAME = Pattern
  > > +			.compile("^[A-Za-z][A-Za-z0-9/_ -]+(\\.git)?$");
  > 
  > This restriction is too strict. Wouldn't any path not containing ".." be valid? In particular this did not work with my "EGIT.contrib" repo. I
  > have a lot of repos with names llike "name.purpose". Just adding
  > '.' to the character set isn't really enough.

  Yup.
  
 .../src/org/spearce/jgit/transport/Daemon.java     |   42 +++++++++----------
 1 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
index 646c88d..d39fd04 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
@@ -51,7 +51,6 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 import org.spearce.jgit.lib.Repository;
 
@@ -62,9 +61,6 @@
 
 	private static final int BACKLOG = 5;
 
-	private static final Pattern SAFE_REPOSITORY_NAME = Pattern
-			.compile("^[A-Za-z][A-Za-z0-9/_ -]+(\\.git)?$");
-
 	private InetSocketAddress myAddress;
 
 	private final DaemonService[] services;
@@ -292,24 +288,26 @@ synchronized (exports) {
 				return db;
 		}
 
-		if (SAFE_REPOSITORY_NAME.matcher(name).matches()) {
-			final File[] search;
-			synchronized (exportBase) {
-				search = exportBase.toArray(new File[exportBase.size()]);
-			}
-			for (final File f : search) {
-				db = openRepository(new File(f, name));
-				if (db != null)
-					return db;
-
-				db = openRepository(new File(f, name + ".git"));
-				if (db != null)
-					return db;
-
-				db = openRepository(new File(f, name + "/.git"));
-				if (db != null)
-					return db;
-			}
+		if (name.startsWith("../") || name.contains("/../")
+				|| name.contains("\\"))
+			return null;
+
+		final File[] search;
+		synchronized (exportBase) {
+			search = exportBase.toArray(new File[exportBase.size()]);
+		}
+		for (final File f : search) {
+			db = openRepository(new File(f, name));
+			if (db != null)
+				return db;
+
+			db = openRepository(new File(f, name + ".git"));
+			if (db != null)
+				return db;
+
+			db = openRepository(new File(f, name + "/.git"));
+			if (db != null)
+				return db;
 		}
 		return null;
 	}
-- 
1.6.1.94.g9388

-- 
Shawn.

^ permalink raw reply related

* configure clobbers LDFLAGS
From: Paul Jarc @ 2009-01-05  2:27 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

(I'm not subscribed; Mail-Followup-To set.)

In a couple of tests, configure clobbers the LDFLAGS value set by the
caller.  This patch fixes it.


paul

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: git-ldflags.diff --]
[-- Type: text/x-patch, Size: 813 bytes --]

diff --git a/configure.ac b/configure.ac
index 8821b50..0a5fc8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,7 +127,7 @@ else
       SAVE_LDFLAGS="${LDFLAGS}"
       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
       AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_wl_rpath=yes], [ld_wl_rpath=no])
-      LDFLAGS="${SAVE_LD_FLAGS}"
+      LDFLAGS="${SAVE_LDFLAGS}"
    ])
    if test "$ld_wl_rpath" = "yes"; then
       AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
@@ -136,7 +136,7 @@ else
          SAVE_LDFLAGS="${LDFLAGS}"
          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
          AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_rpath=yes], [ld_rpath=no])
-         LDFLAGS="${SAVE_LD_FLAGS}"
+         LDFLAGS="${SAVE_LDFLAGS}"
       ])
       if test "$ld_rpath" = "yes"; then
          AC_SUBST(CC_LD_DYNPATH, [-rpath])

^ permalink raw reply related

* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types,   added serialVersionUID, removed unnecessery throws.
From: Shawn O. Pearce @ 2009-01-05  2:19 UTC (permalink / raw)
  To: Vasyl' Vavrychuk; +Cc: git
In-Reply-To: <gjrgip$al9$1@ger.gmane.org>

Vasyl' Vavrychuk <vvavrychuk@gmail.com> wrote:
> Not sure what is right:
> public abstract class AnyObjectId implements Comparable<ObjectId> {
> or
> public abstract class AnyObjectId implements Comparable<AnyObjectId> {
> 
> IMHO second, but class AnyObjectId contains some compareTo(ObjectId).
 
Hmmph.  That probably can be AnyObjectId.  At one point we only had
ObjectId, then AnyObjectId was introduced as a base so we can have
the immutable AnyObjectId and the mutable MutableObjectId subclasses.

compareTo doesn't care about the mutable state of its argument, this
is probably left-over code that didn't get converted when we added
the AnyObjectId base class.

So it should be the second, and the compareTo method should be made
to match that.

-- 
Shawn.

^ permalink raw reply

* Re: git-branch --print-current
From: Shawn O. Pearce @ 2009-01-05  2:18 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: demerphq, Karl Chen, Miklos Vajna, David Aguilar,
	Git mailing list
In-Reply-To: <7v1vvitwio.fsf@gitster.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> wrote:
> demerphq <demerphq@gmail.com> writes:
> 
> > The version im using, from git version 1.6.0.4.724.ga0d3a produces the
> > following error:
> >
> > cut: ./HEAD: No such file or directory
> >
> > when in the .git/refs directory.
> 
> Personally, I think you are nuts to be in .git/refs and want to use that
> information for anything useful, but if it is an easy enough fix, a patch
> would be useful.

I agree, its nuts to be there.  But this also does show up in 1.6.1.
What's odd is the output of rev-parse --git-dir is wrong:

  $ cd .git/refs
  $ git rev-parse --git-dir
  .

Its *not* ".", its "..", I'm *in* the directory.  This throws off
a lot of the other operations we do in __git_ps1, like detecting
the repository state by checking MERGE_HEAD or rebase-apply.

I think we should fix rev-parse --git-dir if we can, not the bash
completion code.

-- 
Shawn.

^ permalink raw reply

* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-05  1:13 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Shawn O. Pearce, git
In-Reply-To: <200901050004.41531.robin.rosenberg.lists@dewire.com>

Robin Rosenberg wrote:
> söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
>> Also fixed:
>> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
>> 2. Possible NullPointerException warning.
>> 3. Unnecessery function parameter warning.
> 
> Thanks for your interest in the projects. 
> Most changes from a 30 seconds review look reasonable.
> However we don't apply changes this way. From your comments it seems we'd require about
> five patches since the changes are of very different types.

I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.

> 
> -- robin
> 
>> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> index ee5f277..e8bcc79 100644
>> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
>>   org.spearce.egit.ui,
>>   org.spearce.jgit,
>>   org.eclipse.core.filesystem
>> -Eclipse-LazyStart: true
>> +Bundle-ActivationPolicy: lazy
> 
> Any pointers on this? (so I can learn)
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4

> 
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> index c01c1c3..61c32ce 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> @@ -50,11 +50,11 @@
>>  	GitFileHistory(final IResource rsrc, final int flags,
>>  			final IProgressMonitor monitor) {
>>  		resource = rsrc;
>> -		walk = buildWalk(flags);
>> +		walk = buildWalk(/*flags*/);
>>  		revisions = buildRevisions(monitor, flags);
>>  	}
>> -	private KidWalk buildWalk(final int flags) {
>> +	private KidWalk buildWalk(/*final int flags*/) {
> Can't we just drop the parameter completely and wipe every trace of it?
OK

>>  		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
>>  		if (rm == null) {
>>  			Activator.logError("Git not attached to project "
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> index 04130db..db5f20b 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> @@ -48,9 +48,9 @@
>>   * a Git repository.
>>   */
>>  public class GitProjectData {
>> -	private static final Map projectDataCache = new HashMap();
>> +	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>>  
>> -	private static final Map repositoryCache = new HashMap();
>> +	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
> Been thinking about doing this myself but always found something more interesting to do. Good.

Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?

>> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> index dcc53cd..4700510 100644
>> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> @@ -175,8 +175,9 @@ public void back(int delta) {
>>  			// space so this prunes our search more quickly.
>>  			//
>>  			ptr -= Constants.OBJECT_ID_LENGTH;
>> -			while (raw[--ptr] != ' ')
>> -				/* nothing */;
>> +			while (raw[--ptr] != ' ') {
>> +				/* nothing */
>> +			}
> Not sure if this buys us anything. I wouldn't react if original code was either way, but
> changing it seems unnecessary.

With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning

^ permalink raw reply

* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-05  1:08 UTC (permalink / raw)
  To: git; +Cc: Shawn O. Pearce, git
In-Reply-To: <200901050004.41531.robin.rosenberg.lists@dewire.com>

Robin Rosenberg wrote:
> söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
>> Also fixed:
>> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
>> 2. Possible NullPointerException warning.
>> 3. Unnecessery function parameter warning.
> 
> Thanks for your interest in the projects. 
> Most changes from a 30 seconds review look reasonable.
> However we don't apply changes this way. From your comments it seems we'd require about
> five patches since the changes are of very different types.

I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.

> 
> -- robin
> 
>> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> index ee5f277..e8bcc79 100644
>> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
>>   org.spearce.egit.ui,
>>   org.spearce.jgit,
>>   org.eclipse.core.filesystem
>> -Eclipse-LazyStart: true
>> +Bundle-ActivationPolicy: lazy
> 
> Any pointers on this? (so I can learn)
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4

> 
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> index c01c1c3..61c32ce 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
>> @@ -50,11 +50,11 @@
>>  	GitFileHistory(final IResource rsrc, final int flags,
>>  			final IProgressMonitor monitor) {
>>  		resource = rsrc;
>> -		walk = buildWalk(flags);
>> +		walk = buildWalk(/*flags*/);
>>  		revisions = buildRevisions(monitor, flags);
>>  	}
>> -	private KidWalk buildWalk(final int flags) {
>> +	private KidWalk buildWalk(/*final int flags*/) {
> Can't we just drop the parameter completely and wipe every trace of it?
OK

>>  		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
>>  		if (rm == null) {
>>  			Activator.logError("Git not attached to project "
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> index 04130db..db5f20b 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> @@ -48,9 +48,9 @@
>>   * a Git repository.
>>   */
>>  public class GitProjectData {
>> -	private static final Map projectDataCache = new HashMap();
>> +	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>>  
>> -	private static final Map repositoryCache = new HashMap();
>> +	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
> Been thinking about doing this myself but always found something more interesting to do. Good.

Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?

>> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> index dcc53cd..4700510 100644
>> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> @@ -175,8 +175,9 @@ public void back(int delta) {
>>  			// space so this prunes our search more quickly.
>>  			//
>>  			ptr -= Constants.OBJECT_ID_LENGTH;
>> -			while (raw[--ptr] != ' ')
>> -				/* nothing */;
>> +			while (raw[--ptr] != ' ') {
>> +				/* nothing */
>> +			}
> Not sure if this buys us anything. I wouldn't react if original code was either way, but
> changing it seems unnecessary.

With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning

^ permalink raw reply

* Re: git-branch --print-current
From: Junio C Hamano @ 2009-01-05  0:41 UTC (permalink / raw)
  To: demerphq
  Cc: Shawn O. Pearce, Karl Chen, Miklos Vajna, David Aguilar,
	Git mailing list
In-Reply-To: <9b18b3110901040535m1f67cb7er95823d31443ee971@mail.gmail.com>

demerphq <demerphq@gmail.com> writes:

> The version im using, from git version 1.6.0.4.724.ga0d3a produces the
> following error:
>
> cut: ./HEAD: No such file or directory
>
> when in the .git/refs directory.

Personally, I think you are nuts to be in .git/refs and want to use that
information for anything useful, but if it is an easy enough fix, a patch
would be useful.

Shawn?

^ permalink raw reply

* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types,   added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-04 23:26 UTC (permalink / raw)
  To: git
In-Reply-To: <gjrcni$9q$1@ger.gmane.org>

Not sure what is right:
public abstract class AnyObjectId implements Comparable<ObjectId> {
or
public abstract class AnyObjectId implements Comparable<AnyObjectId> {

IMHO second, but class AnyObjectId contains some compareTo(ObjectId).

Also not sure if this bunch of changes is complete enough. Maybe it's better to make more fixes in this direction and then commit.

^ permalink raw reply

* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Robin Rosenberg @ 2009-01-04 23:04 UTC (permalink / raw)
  To: Vasyl' Vavrychuk, Shawn O. Pearce; +Cc: git
In-Reply-To: <gjrcni$9q$1@ger.gmane.org>


söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
> Also fixed:
> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
> 2. Possible NullPointerException warning.
> 3. Unnecessery function parameter warning.

Thanks for your interest in the projects. Most changes from a 30 seconds review look reasonable.
However we don't apply changes this way. From your comments it seems we'd require about
five patches since the changes are of very different types.

-- robin

> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> index ee5f277..e8bcc79 100644
> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
>   org.spearce.egit.ui,
>   org.spearce.jgit,
>   org.eclipse.core.filesystem
> -Eclipse-LazyStart: true
> +Bundle-ActivationPolicy: lazy

Any pointers on this? (so I can learn)

> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
> index c01c1c3..61c32ce 100644
> --- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
> @@ -50,11 +50,11 @@
>  	GitFileHistory(final IResource rsrc, final int flags,
>  			final IProgressMonitor monitor) {
>  		resource = rsrc;
> -		walk = buildWalk(flags);
> +		walk = buildWalk(/*flags*/);
>  		revisions = buildRevisions(monitor, flags);
>  	}
> -	private KidWalk buildWalk(final int flags) {
> +	private KidWalk buildWalk(/*final int flags*/) {
Can't we just drop the parameter completely and wipe every trace of it?

>  		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
>  		if (rm == null) {
>  			Activator.logError("Git not attached to project "
> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> index 04130db..db5f20b 100644
> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> @@ -48,9 +48,9 @@
>   * a Git repository.
>   */
>  public class GitProjectData {
> -	private static final Map projectDataCache = new HashMap();
> +	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>  
> -	private static final Map repositoryCache = new HashMap();
> +	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
Been thinking about doing this myself but always found something more interesting to do. Good.

> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> index dcc53cd..4700510 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> @@ -175,8 +175,9 @@ public void back(int delta) {
>  			// space so this prunes our search more quickly.
>  			//
>  			ptr -= Constants.OBJECT_ID_LENGTH;
> -			while (raw[--ptr] != ' ')
> -				/* nothing */;
> +			while (raw[--ptr] != ' ') {
> +				/* nothing */
> +			}
Not sure if this buys us anything. I wouldn't react if original code was either way, but
changing it seems unnecessary.

-- robin

^ permalink raw reply

* Re: [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Miklos Vajna @ 2009-01-04 22:47 UTC (permalink / raw)
  To: Markus Heidelberg; +Cc: gitster, git
In-Reply-To: <200901041901.18801.markus.heidelberg@web.de>

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

On Sun, Jan 04, 2009 at 07:01:18PM +0100, Markus Heidelberg <markus.heidelberg@web.de> wrote:
> > AFAIK sending patches against next is not preferred at all.
> 
> From Documentation/SubmittingPatches:
> 
>     If you are preparing a work based on "next" branch,
>     that is fine, but please mark it as such.

Ouch, then sorry for the misinformation. (Especially that it turns out
Junio added that line in 45d2b286.)

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* [EGIT PATCH] Sorting commit items by click on the table header in commit dialog.
From: Vasyl' Vavrychuk @ 2009-01-04 22:46 UTC (permalink / raw)
  To: git

In order to implement new feature I have replaced class associated with every table row.
CommitItem class encapsulate data that commit dialog manipulates with.
Comparators are written using idiom from http://tobega.blogspot.com/2008/05/beautiful-enums.html.
Clicks on a certain column are handled in HeaderSelectionListener class.

Signed-off-by: Vasyl Vavrychuk <vvavrychuk@gmail.com>
---
 .../egit/ui/internal/actions/CommitAction.java     |    2 +-
 .../egit/ui/internal/dialogs/CommitDialog.java     |  248 ++++++++++++++------
 2 files changed, 176 insertions(+), 74 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
index d703048..779596c 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
@@ -139,7 +139,7 @@ private void loadPreviousCommit() {
 	private void performCommit(CommitDialog commitDialog, String commitMessage)
 			throws TeamException {
 		// System.out.println("Commit Message: " + commitMessage);
-		IFile[] selectedItems = commitDialog.getSelectedItems();
+		IFile[] selectedItems = commitDialog.getSelectedFiles();
 
 		HashMap<Repository, Tree> treeMap = new HashMap<Repository, Tree>();
 		try {
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
index 4f932f2..a0598ff 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
@@ -15,6 +15,7 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Iterator;
 
 import org.eclipse.core.resources.IFile;
@@ -28,9 +29,11 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyAdapter;
 import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Image;
@@ -62,56 +65,38 @@
  */
 public class CommitDialog extends Dialog {
 
+	class CommitContentProvider implements IStructuredContentProvider {
+
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			// Empty
+		}
+
+		public void dispose() {
+			// Empty
+		}
+
+		public Object[] getElements(Object inputElement) {
+			return items.toArray();
+		}
+
+	}
+
 	class CommitLabelProvider extends WorkbenchLabelProvider implements
 			ITableLabelProvider {
 		public String getColumnText(Object obj, int columnIndex) {
-			IFile file = (IFile) obj;
-			if (columnIndex == 1)
-				return file.getProject().getName() + ": "
-						+ file.getProjectRelativePath();
+			CommitItem item = (CommitItem) obj;
 
-			else if (columnIndex == 0) {
-				String prefix = "Unknown";
+			switch (columnIndex) {
+			case 0:
+				return item.status;
 
-				try {
-					RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(file.getProject());
-
-					Repository repo = repositoryMapping.getRepository();
-					GitIndex index = repo.getIndex();
-					Tree headTree = repo.mapTree("HEAD");
-
-					String repoPath = repositoryMapping
-							.getRepoRelativePath(file);
-					TreeEntry headEntry = headTree.findBlobMember(repoPath);
-					boolean headExists = headTree.existsBlob(repoPath);
-
-					Entry indexEntry = index.getEntry(repoPath);
-					if (headEntry == null) {
-						prefix = "Added";
-						if (indexEntry.isModified(repositoryMapping.getWorkDir()))
-							prefix = "Added, index diff";
-					} else if (indexEntry == null) {
-						prefix = "Removed";
-					} else if (headExists
-							&& !headEntry.getId().equals(
-									indexEntry.getObjectId())) {
-						prefix = "Modified";
-
-
-						if (indexEntry.isModified(repositoryMapping.getWorkDir()))
-							prefix = "Mod., index diff";
-					} else if (!new File(repositoryMapping.getWorkDir(), indexEntry.getName()).isFile()) {
-						prefix = "Rem., not staged";
-					} else if (indexEntry.isModified(repositoryMapping.getWorkDir())) {
-						prefix = "Mod., not staged";
-					}
-
-				} catch (Exception e) {
-				}
+			case 1:
+				return item.file.getProject().getName() + ": "
+						+ item.file.getProjectRelativePath();
 
-				return prefix;
+			default:
+				return null;
 			}
-			return null;
 		}
 
 		public Image getColumnImage(Object element, int columnIndex) {
@@ -121,7 +106,7 @@ public Image getColumnImage(Object element, int columnIndex) {
 		}
 	}
 
-	ArrayList<IFile> files;
+	ArrayList<CommitItem> items = new ArrayList<CommitItem>();
 
 	/**
 	 * @param parentShell
@@ -227,30 +212,17 @@ public void widgetDefaultSelected(SelectionEvent arg0) {
 		TableColumn statCol = new TableColumn(resourcesTable, SWT.LEFT);
 		statCol.setText("Status");
 		statCol.setWidth(150);
+		statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));
 
 		TableColumn resourceCol = new TableColumn(resourcesTable, SWT.LEFT);
 		resourceCol.setText("File");
 		resourceCol.setWidth(415);
+		resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
 
 		filesViewer = new CheckboxTableViewer(resourcesTable);
-		filesViewer.setContentProvider(new IStructuredContentProvider() {
-
-			public void inputChanged(Viewer viewer, Object oldInput,
-					Object newInput) {
-				// Empty
-			}
-
-			public void dispose() {
-				// Empty
-			}
-
-			public Object[] getElements(Object inputElement) {
-				return files.toArray();
-			}
-
-		});
+		filesViewer.setContentProvider(new CommitContentProvider());
 		filesViewer.setLabelProvider(new CommitLabelProvider());
-		filesViewer.setInput(files);
+		filesViewer.setInput(items);
 		filesViewer.setAllChecked(true);
 		filesViewer.getTable().setMenu(getContextMenu());
 
@@ -271,15 +243,15 @@ public void handleEvent(Event arg0) {
 				try {
 					ArrayList<GitIndex> changedIndexes = new ArrayList<GitIndex>();
 					for (Iterator<Object> it = sel.iterator(); it.hasNext();) {
-						IFile file = (IFile) it.next();
+						CommitItem commitItem = (CommitItem) it.next();
 
-						IProject project = file.getProject();
+						IProject project = commitItem.file.getProject();
 						RepositoryMapping map = RepositoryMapping.getMapping(project);
 
 						Repository repo = map.getRepository();
 						GitIndex index = null;
 						index = repo.getIndex();
-						Entry entry = index.getEntry(map.getRepoRelativePath(file));
+						Entry entry = index.getEntry(map.getRepoRelativePath(commitItem.file));
 						if (entry != null && entry.isModified(map.getWorkDir())) {
 							entry.update(new File(map.getWorkDir(), entry.getName()));
 							if (!changedIndexes.contains(index))
@@ -302,6 +274,47 @@ public void handleEvent(Event arg0) {
 		return menu;
 	}
 
+	private static String getFileStatus(IFile file) {
+		String prefix = "Unknown";
+
+		try {
+			RepositoryMapping repositoryMapping = RepositoryMapping
+					.getMapping(file.getProject());
+
+			Repository repo = repositoryMapping.getRepository();
+			GitIndex index = repo.getIndex();
+			Tree headTree = repo.mapTree("HEAD");
+
+			String repoPath = repositoryMapping.getRepoRelativePath(file);
+			TreeEntry headEntry = headTree.findBlobMember(repoPath);
+			boolean headExists = headTree.existsBlob(repoPath);
+
+			Entry indexEntry = index.getEntry(repoPath);
+			if (headEntry == null) {
+				prefix = "Added";
+				if (indexEntry.isModified(repositoryMapping.getWorkDir()))
+					prefix = "Added, index diff";
+			} else if (indexEntry == null) {
+				prefix = "Removed";
+			} else if (headExists
+					&& !headEntry.getId().equals(indexEntry.getObjectId())) {
+				prefix = "Modified";
+
+				if (indexEntry.isModified(repositoryMapping.getWorkDir()))
+					prefix = "Mod., index diff";
+			} else if (!new File(repositoryMapping.getWorkDir(), indexEntry
+					.getName()).isFile()) {
+				prefix = "Rem., not staged";
+			} else if (indexEntry.isModified(repositoryMapping.getWorkDir())) {
+				prefix = "Mod., not staged";
+			}
+
+		} catch (Exception e) {
+		}
+
+		return prefix;
+	}
+
 	/**
 	 * @return The message the user entered
 	 */
@@ -323,7 +336,7 @@ public void setCommitMessage(String s) {
 	private boolean amending = false;
 	private boolean amendAllowed = true;
 
-	private ArrayList<IFile> selectedItems = new ArrayList<IFile>();
+	private ArrayList<IFile> selectedFiles = new ArrayList<IFile>();
 	private String previousCommitMessage = "";
 
 	/**
@@ -331,15 +344,51 @@ public void setCommitMessage(String s) {
 	 *
 	 * @param items
 	 */
-	public void setSelectedItems(IFile[] items) {
-		Collections.addAll(selectedItems, items);
+	public void setSelectedFiles(IFile[] items) {
+		Collections.addAll(selectedFiles, items);
 	}
 
 	/**
 	 * @return the resources selected by the user to commit.
 	 */
-	public IFile[] getSelectedItems() {
-		return selectedItems.toArray(new IFile[0]);
+	public IFile[] getSelectedFiles() {
+		return selectedFiles.toArray(new IFile[0]);
+	}
+
+	class HeaderSelectionListener extends SelectionAdapter {
+
+		private CommitItem.Order order;
+
+		private boolean reversed;
+
+		public HeaderSelectionListener(CommitItem.Order order) {
+			this.order = order;
+		}
+
+		@Override
+		public void widgetSelected(SelectionEvent e) {
+			TableColumn column = (TableColumn)e.widget;
+			Table table = column.getParent();
+
+			if (column == table.getSortColumn()) {
+				reversed = !reversed;
+			} else {
+				reversed = false;
+			}
+			table.setSortColumn(column);
+
+			Comparator<CommitItem> comparator;
+			if (reversed) {
+				comparator = order.descending();
+				table.setSortDirection(SWT.DOWN);
+			} else {
+				comparator = order;
+				table.setSortDirection(SWT.UP);
+			}
+
+			filesViewer.setComparator(new CommitViewerComparator(comparator));
+		}
+
 	}
 
 	@Override
@@ -350,9 +399,9 @@ protected void okPressed() {
 		amending = amendingButton.getSelection();
 		
 		Object[] checkedElements = filesViewer.getCheckedElements();
-		selectedItems.clear();
+		selectedFiles.clear();
 		for (Object obj : checkedElements)
-			selectedItems.add((IFile) obj);
+			selectedFiles.add(((CommitItem) obj).file);
 
 		if (commitMessage.trim().length() == 0) {
 			MessageDialog.openWarning(getShell(), "No message", "You must enter a commit message");
@@ -368,7 +417,7 @@ protected void okPressed() {
 			}
 		} else author = null;
 
-		if (selectedItems.isEmpty() && !amending) {
+		if (selectedFiles.isEmpty() && !amending) {
 			MessageDialog.openWarning(getShell(), "No items selected", "No items are currently selected to be committed.");
 			return;
 		}
@@ -382,7 +431,13 @@ protected void okPressed() {
 	 * @param files potentially affected by a new commit
 	 */
 	public void setFileList(ArrayList<IFile> files) {
-		this.files = files;
+		items.clear();
+		for (IFile file : files) {
+			CommitItem item = new CommitItem();
+			item.status = getFileStatus(file);
+			item.file = file;
+			items.add(item);
+		}
 	}
 
 	@Override
@@ -468,3 +523,50 @@ protected int getShellStyle() {
 		return super.getShellStyle() | SWT.RESIZE;
 	}
 }
+
+class CommitItem {
+	String status;
+
+	IFile file;
+
+	public static enum Order implements Comparator<CommitItem> {
+		ByStatus() {
+
+			public int compare(CommitItem o1, CommitItem o2) {
+				return o1.status.compareTo(o2.status);
+			}
+
+		},
+
+		ByFile() {
+
+			public int compare(CommitItem o1, CommitItem o2) {
+				return o1.file.getProjectRelativePath().toString().
+					compareTo(o2.file.getProjectRelativePath().toString());
+			}
+
+		};
+
+		public Comparator<CommitItem> ascending() {
+			return this;
+		}
+
+		public Comparator<CommitItem> descending() {
+			return Collections.reverseOrder(this);
+		}
+	}
+}
+
+class CommitViewerComparator extends ViewerComparator {
+
+	public CommitViewerComparator(Comparator comparator){
+		super(comparator);
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public int compare(Viewer viewer, Object e1, Object e2) {
+		return getComparator().compare(e1, e2);
+	}
+
+}
-- 
1.5.6.1.1071.g76fb

^ permalink raw reply related

* Re: git-rev-parse --symbolic-abbrev-name
From: Miklos Vajna @ 2009-01-04 22:38 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Junio C Hamano, Karl Chen, David Aguilar, Git mailing list
In-Reply-To: <1a69a9d80901041223r1f3d2956ne05996793bb23e97@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On Sun, Jan 04, 2009 at 03:23:03PM -0500, Arnaud Lacombe <lacombar@gmail.com> wrote:
> ps: I choose --symbolic-short-name as the opposite of
> --symbolic-full-name for consistency.
> ps2: sorry for the bogus mime-type

That's not a problem, just don't attach your patch. Please read
Documentation/SubmittingPatches.

Thanks.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: unclear description of git-rm on kernel.org
From: Miklos Vajna @ 2009-01-04 22:35 UTC (permalink / raw)
  To: alec resnick; +Cc: git
In-Reply-To: <62a60dd90901041410j283866e5ja39c3bda447fed36@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

On Sun, Jan 04, 2009 at 05:10:11PM -0500, alec resnick <alec@sproutward.org> wrote:
> I was trying to remove a number of files from a git repo I had.  I
> read http://kernel.org/pub/software/scm/git/docs/v1.4.4.4/git-rm.html

Ugh, why are you reading that ancient version?

I would try:

http://www.kernel.org/pub/software/scm/git/docs/git-rm.html

> I'd be happy to make the changes to the webpage; I don't know how to
> do that or if it's appropriate.

They are generated from asciidoc files from the Documentation/ dir, but
documentation fixes are welcome against 1.6.1.x or master only, I'm
afraid.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-04 22:20 UTC (permalink / raw)
  To: git

Also fixed:
1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
2. Possible NullPointerException warning.
3. Unnecessery function parameter warning.

Signed-off-by: Vasyl Vavrychuk <vvavrychuk@gmail.com>
---
 org.spearce.egit.core.test/META-INF/MANIFEST.MF    |    2 +-
 org.spearce.egit.core/META-INF/MANIFEST.MF         |    2 +-
 .../egit/core/internal/storage/GitFileHistory.java |    4 +-
 .../spearce/egit/core/project/GitProjectData.java  |   18 +++----
 .../egit/core/project/RepositoryFinder.java        |    5 +-
 org.spearce.egit.ui/META-INF/MANIFEST.MF           |    2 +-
 .../egit/ui/internal/actions/RepositoryAction.java |    2 +-
 .../tst/org/spearce/jgit/lib/T0002_Tree.java       |    4 +-
 org.spearce.jgit/META-INF/MANIFEST.MF              |    2 +-
 .../jgit/errors/InvalidPatternException.java       |    2 +
 .../jgit/errors/NoClosingBracketException.java     |    1 +
 .../jgit/errors/RevisionSyntaxException.java       |    1 +
 .../src/org/spearce/jgit/lib/AnyObjectId.java      |    6 +--
 .../src/org/spearce/jgit/lib/GitIndex.java         |   29 +++++------
 .../src/org/spearce/jgit/lib/ObjectIdMap.java      |    1 -
 .../src/org/spearce/jgit/lib/ObjectWriter.java     |    1 -
 .../src/org/spearce/jgit/lib/TreeIterator.java     |    2 +-
 .../jgit/lib/TreeVisitorWithCurrentDirectory.java  |    5 +-
 .../src/org/spearce/jgit/revwalk/RevWalk.java      |    3 +-
 .../jgit/transport/DefaultSshSessionFactory.java   |    2 +-
 .../spearce/jgit/treewalk/CanonicalTreeParser.java |    5 +-
 .../src/org/spearce/jgit/util/Base64.java          |   52 ++++++++++++--------
 22 files changed, 76 insertions(+), 75 deletions(-)

diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
index ee5f277..e8bcc79 100644
--- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.egit.ui,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.core.resources,
  org.eclipse.jdt.core,
  org.eclipse.jdt.junit,
diff --git a/org.spearce.egit.core/META-INF/MANIFEST.MF b/org.spearce.egit.core/META-INF/MANIFEST.MF
index 6c95084..43fc566 100644
--- a/org.spearce.egit.core/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.core/META-INF/MANIFEST.MF
@@ -16,5 +16,5 @@ Export-Package: org.spearce.egit.core.internal.storage;x-friends:="org.spearce.e
  org.spearce.egit.core,
  org.spearce.egit.core.op,
  org.spearce.egit.core.project
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
index c01c1c3..61c32ce 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
@@ -50,11 +50,11 @@
 	GitFileHistory(final IResource rsrc, final int flags,
 			final IProgressMonitor monitor) {
 		resource = rsrc;
-		walk = buildWalk(flags);
+		walk = buildWalk(/*flags*/);
 		revisions = buildRevisions(monitor, flags);
 	}
 
-	private KidWalk buildWalk(final int flags) {
+	private KidWalk buildWalk(/*final int flags*/) {
 		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
 		if (rm == null) {
 			Activator.logError("Git not attached to project "
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
index 04130db..db5f20b 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
@@ -48,9 +48,9 @@
  * a Git repository.
  */
 public class GitProjectData {
-	private static final Map projectDataCache = new HashMap();
+	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
 
-	private static final Map repositoryCache = new HashMap();
+	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
 
 	private static RepositoryChangeListener[] repositoryChangeListeners = {};
 
@@ -193,7 +193,7 @@ private synchronized static void uncache(final IProject p) {
 	}
 
 	private synchronized static GitProjectData lookup(final IProject p) {
-		return (GitProjectData) projectDataCache.get(p);
+		return projectDataCache.get(p);
 	}
 
 	private synchronized static Repository lookupRepository(final File gitDir)
@@ -206,11 +206,11 @@ private synchronized static Repository lookupRepository(final File gitDir)
 			}
 		}
 
-		final Reference r = (Reference) repositoryCache.get(gitDir);
+		final Reference r = repositoryCache.get(gitDir);
 		Repository d = r != null ? (Repository) r.get() : null;
 		if (d == null) {
 			d = new Repository(gitDir);
-			repositoryCache.put(gitDir, new WeakReference(d));
+			repositoryCache.put(gitDir, new WeakReference<Repository>(d));
 		}
 		return d;
 	}
@@ -229,9 +229,9 @@ public static void reconfigureWindowCache() {
 
 	private final IProject project;
 
-	private final Collection mappings;
+	private final Collection<RepositoryMapping> mappings = new ArrayList<RepositoryMapping>();
 
-	private final Set protectedResources;
+	private final Set<IResource> protectedResources = new HashSet<IResource>();
 
 	/**
 	 * Construct a {@link GitProjectData} for the mapping
@@ -241,8 +241,6 @@ public static void reconfigureWindowCache() {
 	 */
 	public GitProjectData(final IProject p) {
 		project = p;
-		mappings = new ArrayList();
-		protectedResources = new HashSet();
 	}
 
 	/**
@@ -257,7 +255,7 @@ public IProject getProject() {
 	 *
 	 * @param newMappings
 	 */
-	public void setRepositoryMappings(final Collection newMappings) {
+	public void setRepositoryMappings(final Collection<RepositoryMapping> newMappings) {
 		mappings.clear();
 		mappings.addAll(newMappings);
 		remapAll();
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
index c33f3a0..2b4b16f 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
@@ -47,7 +47,7 @@
 public class RepositoryFinder {
 	private final IProject proj;
 
-	private final Collection results;
+	private final Collection<RepositoryMapping> results = new ArrayList<RepositoryMapping>();
 
 	/**
 	 * Create a new finder to locate Git repositories for a project.
@@ -58,7 +58,6 @@
 	 */
 	public RepositoryFinder(final IProject p) {
 		proj = p;
-		results = new ArrayList();
 	}
 
 	/**
@@ -72,7 +71,7 @@ public RepositoryFinder(final IProject p) {
 	 *             Eclipse was unable to access its workspace, and threw up on
 	 *             us. We're throwing it back at the caller.
 	 */
-	public Collection find(IProgressMonitor m) throws CoreException {
+	public Collection<RepositoryMapping> find(IProgressMonitor m) throws CoreException {
 		if (m == null) {
 			m = new NullProgressMonitor();
 		}
diff --git a/org.spearce.egit.ui/META-INF/MANIFEST.MF b/org.spearce.egit.ui/META-INF/MANIFEST.MF
index ec1df4d..019ef6e 100644
--- a/org.spearce.egit.ui/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.ui/META-INF/MANIFEST.MF
@@ -20,7 +20,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.jgit,
  org.spearce.egit.core,
  org.eclipse.jsch.ui;bundle-version="1.1.100"
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Import-Package: org.eclipse.jsch.core,
  org.eclipse.jsch.internal.core
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/RepositoryAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/RepositoryAction.java
index 8c250ca..362437e 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/RepositoryAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/RepositoryAction.java
@@ -100,7 +100,7 @@ protected Repository getRepository(boolean warn) {
 				mapping = repositoryMapping;
 			if (repositoryMapping == null)
 				return null;
-			if (repositoryMapping != null && mapping.getRepository() != repositoryMapping.getRepository()) {
+			if (mapping.getRepository() != repositoryMapping.getRepository()) {
 				if (warn)
 					MessageDialog.openError(getShell(), "Multiple Repositories Selection", "Cannot perform reset on multiple repositories simultaneously.\n\nPlease select items from only one repository.");
 				return null;
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
index fcb4d96..97f299c 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
@@ -236,7 +236,7 @@ public void test006_addDeepTree() throws IOException {
 
 	public void test007_manyFileLookup() throws IOException {
 		final Tree t = new Tree(db);
-		final List files = new ArrayList(26 * 26);
+		final List<FileTreeEntry> files = new ArrayList<FileTreeEntry>(26 * 26);
 		for (char level1 = 'a'; level1 <= 'z'; level1++) {
 			for (char level2 = 'a'; level2 <= 'z'; level2++) {
 				final String n = "." + level1 + level2 + "9";
@@ -251,7 +251,7 @@ public void test007_manyFileLookup() throws IOException {
 		assertNotNull(ents);
 		assertEquals(files.size(), ents.length);
 		for (int k = 0; k < ents.length; k++) {
-			assertTrue("File " + ((FileTreeEntry) files.get(k)).getName()
+			assertTrue("File " + files.get(k).getName()
 					+ " is at " + k + ".", files.get(k) == ents[k]);
 		}
 	}
diff --git a/org.spearce.jgit/META-INF/MANIFEST.MF b/org.spearce.jgit/META-INF/MANIFEST.MF
index 36f92f2..459e8f3 100644
--- a/org.spearce.jgit/META-INF/MANIFEST.MF
+++ b/org.spearce.jgit/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@ Export-Package: org.spearce.jgit.dircache,
  org.spearce.jgit.treewalk,
  org.spearce.jgit.treewalk.filter,
  org.spearce.jgit.util
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ClassPath: .
 Require-Bundle: com.jcraft.jsch;visibility:=reexport
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidPatternException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidPatternException.java
index 15d159b..e7be0d6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidPatternException.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidPatternException.java
@@ -42,6 +42,8 @@
  *
  */
 public class InvalidPatternException extends Exception {
+	private static final long serialVersionUID = 1L;
+
 	private final String pattern;
 
 	/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/NoClosingBracketException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/NoClosingBracketException.java
index 1a93906..8fe9ab1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/errors/NoClosingBracketException.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/NoClosingBracketException.java
@@ -42,6 +42,7 @@
  * side or a character class which is open to the right side.
  */
 public class NoClosingBracketException extends InvalidPatternException {
+	private static final long serialVersionUID = 1L;
 
 	/**
 	 * @param indexOfOpeningBracket
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/RevisionSyntaxException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/RevisionSyntaxException.java
index ac425bb..f943879 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/errors/RevisionSyntaxException.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/RevisionSyntaxException.java
@@ -45,6 +45,7 @@
  * properly formatted.
  */
 public class RevisionSyntaxException extends IOException {
+	private static final long serialVersionUID = 1L;
 
 	private final String revstr;
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
index a534202..f3e4534 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
@@ -52,7 +52,7 @@
  * with this instance can alter at any time, if this instance is modified to
  * represent a different object name.
  */
-public abstract class AnyObjectId implements Comparable {
+public abstract class AnyObjectId implements Comparable<ObjectId> {
 	static final int RAW_LEN = Constants.OBJECT_ID_LENGTH;
 
 	static final int STR_LEN = RAW_LEN * 2;
@@ -178,10 +178,6 @@ public int compareTo(final ObjectId other) {
 		return NB.compareUInt32(w5, other.w5);
 	}
 
-	public int compareTo(final Object other) {
-		return compareTo(((ObjectId) other));
-	}
-
 	int compareTo(final byte[] bs, final int p) {
 		int cmp;
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index bafddef..7c3f1b4 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -107,18 +107,16 @@
 
 	private final Repository db;
 
-	private Map entries = new TreeMap(new Comparator() {
-		public int compare(Object arg0, Object arg1) {
-			byte[] a = (byte[]) arg0;
-			byte[] b = (byte[]) arg1;
-			for (int i = 0; i < a.length && i < b.length; ++i) {
-				int c = a[i] - b[i];
+	private Map<byte[], Entry> entries = new TreeMap<byte[], Entry>(new Comparator<byte[]>() {
+		public int compare(byte[] o1, byte[] o2) {
+			for (int i = 0; i < o1.length && i < o2.length; ++i) {
+				int c = o1[i] - o2[i];
 				if (c != 0)
 					return c;
 			}
-			if (a.length < b.length)
+			if (o1.length < o2.length)
 				return -1;
-			else if (a.length > b.length)
+			else if (o1.length > o2.length)
 				return 1;
 			return 0;
 		}
@@ -161,7 +159,7 @@ public void rereadIfNecessary() throws IOException {
 	 */
 	public Entry add(File wd, File f) throws IOException {
 		byte[] key = makeKey(wd, f);
-		Entry e = (Entry) entries.get(key);
+		Entry e = entries.get(key);
 		if (e == null) {
 			e = new Entry(key, f, 0);
 			entries.put(key, e);
@@ -302,7 +300,7 @@ static boolean File_hasExecute() {
 		return FS.INSTANCE.supportsExecute();
 	}
 
-	static byte[] makeKey(File wd, File f) throws IOException {
+	static byte[] makeKey(File wd, File f) {
 		if (!f.getPath().startsWith(wd.getPath()))
 			throw new Error("Path is not in working dir");
 		String relName = Repository.stripWorkDir(wd, f);
@@ -362,8 +360,7 @@ Entry(byte[] key, File f, int stage)
 			flags = (short) ((stage << 12) | name.length); // TODO: fix flags
 		}
 
-		Entry(TreeEntry f, int stage)
-				throws UnsupportedEncodingException {
+		Entry(TreeEntry f, int stage) {
 			ctime = -1; // hmm
 			mtime = -1;
 			dev = -1;
@@ -810,7 +807,7 @@ public ObjectId writeTree() throws IOException {
 		checkWriteOk();
 		ObjectWriter writer = new ObjectWriter(db);
 		Tree current = new Tree(db);
-		Stack trees = new Stack();
+		Stack<Tree> trees = new Stack<Tree>();
 		trees.push(current);
 		String[] prevName = new String[0];
 		for (Iterator i = entries.values().iterator(); i.hasNext();) {
@@ -844,7 +841,7 @@ public ObjectId writeTree() throws IOException {
 			current.setId(writer.writeTree(current));
 			trees.pop();
 			if (!trees.isEmpty())
-				current = (Tree) trees.peek();
+				current = trees.peek();
 		}
 		return current.getTreeId();
 	}
@@ -886,7 +883,7 @@ int longestCommonPath(String[] a, String[] b) {
 	 * @return The index entries sorted
 	 */
 	public Entry[] getMembers() {
-		return (Entry[]) entries.values().toArray(new Entry[entries.size()]);
+		return entries.values().toArray(new Entry[entries.size()]);
 	}
 
 	/**
@@ -897,7 +894,7 @@ int longestCommonPath(String[] a, String[] b) {
 	 * @throws UnsupportedEncodingException
 	 */
 	public Entry getEntry(String path) throws UnsupportedEncodingException {
-		return (Entry) entries.get(Repository.gitInternalSlash(Constants.encode(path)));
+		return entries.get(Repository.gitInternalSlash(Constants.encode(path)));
 	}
 
 	/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
index 600d0f4..d3c7f1d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
@@ -178,7 +178,6 @@ public boolean isEmpty() {
 		return true;
 	}
 
-	@SuppressWarnings("unchecked")
 	public V put(ObjectId key, V value) {
 		return submap(key).put(key, value);
 	}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
index 6c2cd4f..e84798a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
@@ -289,7 +289,6 @@ public ObjectId computeBlobSha1(final long len, final InputStream is)
 		return writeObject(Constants.OBJ_BLOB, len, is, false);
 	}
 
-	@SuppressWarnings("null")
 	ObjectId writeObject(final int type, long len, final InputStream is,
 			boolean store) throws IOException {
 		final File t;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeIterator.java
index 2344a3c..ec52078 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeIterator.java
@@ -76,7 +76,7 @@
 		 * Visit leaves first, then node
 		 */
 		POSTORDER
-	};
+	}
 
 	/**
 	 * Construct a {@link TreeIterator} for visiting all non-tree nodes.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java
index 55854b2..e227adb 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java
@@ -46,12 +46,11 @@
  * Abstract TreeVisitor for visiting all files known by a Tree.
  */
 public abstract class TreeVisitorWithCurrentDirectory implements TreeVisitor {
-	private final ArrayList stack;
+	private final ArrayList<File> stack = new ArrayList<File>(16);
 
 	private File currentDirectory;
 
 	protected TreeVisitorWithCurrentDirectory(final File rootDirectory) {
-		stack = new ArrayList(16);
 		currentDirectory = rootDirectory;
 	}
 
@@ -67,6 +66,6 @@ public void startVisitTree(final Tree t) throws IOException {
 	}
 
 	public void endVisitTree(final Tree t) throws IOException {
-		currentDirectory = (File) stack.remove(stack.size() - 1);
+		currentDirectory = stack.remove(stack.size() - 1);
 	}
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
index d7e4c58..8d25125 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
@@ -1014,8 +1014,7 @@ protected RevCommit createCommit(final AnyObjectId id) {
 		return new RevCommit(id);
 	}
 
-	void carryFlagsImpl(final RevCommit c) throws MissingObjectException,
-			IncorrectObjectTypeException, IOException {
+	void carryFlagsImpl(final RevCommit c) {
 		final int carry = c.flags & carryFlags;
 		if (carry != 0)
 			RevCommit.carryFlags(c, carry);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java b/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java
index 89beab7..0d522df 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java
@@ -153,7 +153,7 @@ private void knownHosts(final JSch sch) throws JSchException {
 		}
 	}
 
-	private void identities() throws JSchException {
+	private void identities() {
 		final File home = FS.userHome();
 		if (home == null)
 			return;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
index dcc53cd..4700510 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
@@ -175,8 +175,9 @@ public void back(int delta) {
 			// space so this prunes our search more quickly.
 			//
 			ptr -= Constants.OBJECT_ID_LENGTH;
-			while (raw[--ptr] != ' ')
-				/* nothing */;
+			while (raw[--ptr] != ' ') {
+				/* nothing */
+			}
 			if (--ptr < Constants.OBJECT_ID_LENGTH) {
 				if (delta != 0)
 					throw new ArrayIndexOutOfBoundsException(delta);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/Base64.java b/org.spearce.jgit/src/org/spearce/jgit/util/Base64.java
index 8c45539..d81867b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/Base64.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/Base64.java
@@ -7,6 +7,9 @@
 
 package org.spearce.jgit.util;
 
+import java.io.Closeable;
+import java.io.IOException;
+
 
 /**
  * Encodes and decodes to and from Base64 notation.
@@ -175,11 +178,20 @@
     private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
     private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
 
+    private static void closeStream(Closeable stream) {
+        if (stream != null) {
+            try {
+                stream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 
     /** Defeats instantiation. */
-    private Base64(){}
-
-
+    private Base64() {
+        //suppress empty block warning
+    }
 
 /* ********  E N C O D I N G   M E T H O D S  ******** */
 
@@ -353,10 +365,10 @@ public static String encodeObject( java.io.Serializable serializableObject, int 
         }   // end catch
         finally
         {
-            try{ oos.close();   } catch( Exception e ){}
-            try{ gzos.close();  } catch( Exception e ){}
-            try{ b64os.close(); } catch( Exception e ){}
-            try{ baos.close();  } catch( Exception e ){}
+            closeStream(oos);
+            closeStream(gzos);
+            closeStream(b64os);
+            closeStream(baos);
         }   // end finally
 
         // Return value according to relevant encoding.
@@ -486,9 +498,9 @@ public static String encodeBytes( byte[] source, int off, int len, int options )
             }   // end catch
             finally
             {
-                try{ gzos.close();  } catch( Exception e ){}
-                try{ b64os.close(); } catch( Exception e ){}
-                try{ baos.close();  } catch( Exception e ){}
+                closeStream(gzos);
+                closeStream(b64os);
+                closeStream(baos);
             }   // end finally
 
             // Return value according to relevant encoding.
@@ -763,9 +775,9 @@ else if( source[ srcOffset + 3 ] == EQUALS_SIGN )
                 }   // end catch
                 finally
                 {
-                    try{ baos.close(); } catch( Exception e ){}
-                    try{ gzis.close(); } catch( Exception e ){}
-                    try{ bais.close(); } catch( Exception e ){}
+                    closeStream(baos);
+                    closeStream(gzis);
+                    closeStream(bais);
                 }   // end finally
 
             }   // end if: gzipped
@@ -804,17 +816,15 @@ public static Object decodeToObject( String encodedObject )
         catch( java.io.IOException e )
         {
             e.printStackTrace();
-            obj = null;
         }   // end catch
         catch( java.lang.ClassNotFoundException e )
         {
             e.printStackTrace();
-            obj = null;
         }   // end catch
         finally
         {
-            try{ bais.close(); } catch( Exception e ){}
-            try{ ois.close();  } catch( Exception e ){}
+            closeStream(bais);
+            closeStream(ois);
         }   // end finally
 
         return obj;
@@ -849,7 +859,7 @@ public static boolean encodeToFile( byte[] dataToEncode, String filename )
         }   // end catch: IOException
         finally
         {
-            try{ bos.close(); } catch( Exception e ){}
+            closeStream(bos);
         }   // end finally
 
         return success;
@@ -882,7 +892,7 @@ public static boolean decodeToFile( String dataToDecode, String filename )
         }   // end catch: IOException
         finally
         {
-                try{ bos.close(); } catch( Exception e ){}
+            closeStream(bos);
         }   // end finally
 
         return success;
@@ -940,7 +950,7 @@ public static boolean decodeToFile( String dataToDecode, String filename )
         }   // end catch: IOException
         finally
         {
-            try{ bis.close(); } catch( Exception e) {}
+            closeStream(bis);
         }   // end finally
 
         return decodedData;
@@ -988,7 +998,7 @@ public static String encodeFromFile( String filename )
         }   // end catch: IOException
         finally
         {
-            try{ bis.close(); } catch( Exception e) {}
+            closeStream(bis);
         }   // end finally
 
         return encodedData;
-- 
1.5.6.1.1071.g76fb

^ permalink raw reply related

* unclear description of git-rm on kernel.org
From: alec resnick @ 2009-01-04 22:10 UTC (permalink / raw)
  To: git

Hi!

I was trying to remove a number of files from a git repo I had.  I
read http://kernel.org/pub/software/scm/git/docs/v1.4.4.4/git-rm.html
which I interpreted to mean that git-rm removed only from the index,
and not from the working tree.  In retrospect, the short description
is clear: "git-rm - Remove files from the working tree and from the
index," but I was confused by the language:
"<file>…

    Files to remove from the index and optionally, from the working
tree as well.
-f

    Remove files from the working tree as well as from the index."

Because of "optionally" and the very existence of the "-f" option
suggests that you have to do something extra to ask git-rm to mess
with the working tree.

The manpage is much clearer, and while I recovered the files I
accidentally removed simply with git checkout, I suggest that the
webpage be made a bit clearer.  In particular, adding info about how
to _only_ remove files from the index would be helpful.

I'd be happy to make the changes to the webpage; I don't know how to
do that or if it's appropriate.

Thanks!


-a.

^ permalink raw reply

* Re: [PATCH] gitweb: merge boolean feature subroutines
From: Jakub Narebski @ 2009-01-04 22:07 UTC (permalink / raw)
  To: Matt Kraai; +Cc: demerphq, Junio C Hamano, git
In-Reply-To: <20090104155858.GC4205@ftbfs.org>

Matt Kraai <kraai@ftbfs.org> writes:

> I agree that what you suggest is better than the alternatives you
> present.  Unfortunately, none of them match the current behavior.
> Here's the current code:
> 
> 	if ($val eq 'true') {
> 		return 1;
> 	} elsif ($val eq 'false') {
> 		return 0;
> 	}
> 
> 	return $_[0];
> 
> Is there a way to use the form you suggest while falling back to the
> default if $val isn't set to 'true' or 'false'?

IIRC the return value is actually threestate: 1 for true, 0 for false,
and undef for non-bool config value.

BTW. git_get_project_config currently emulates old one git-config call
per configuration variable, with git-config normalizing boolean values
(returning 'true' or 'false'). But it could return Perl truish or Perl
falsish instead, as we now use "git config -l -z" + caching config
variables, and it is Perl that does normalization of boolean values.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* Re: git-branch --print-current
From: Jakub Narebski @ 2009-01-04 21:48 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: Karl Chen, Arnaud Lacombe, Git mailing list
In-Reply-To: <20090104180208.GA12298@chistera.yi.org>

Adeodato Simó <dato@net.com.org.es> writes:
> * Karl Chen [Sun, 04 Jan 2009 04:40:51 -0800]:
> 
> >     Arnaud> $ git branch | awk '/^\*/ {print $2}'
> 
> > Yet another addition to the list of ways to pipeline it, this one
> > probably the shortest :)
> 
> Heh, if we're playing golf:
> 
>               $ git branch | sed -n 's/^\* //p'

Even if you want to reimplement __git_ps1 provided with bash
completion in completion/git-completion.bash instead of reusing it,
you still have to deal with many situations: not being in git
repository, being on detached HEAD, being in intermediate state
(during git-am, git-rebase, git-bisect etc.), etc.  Additionally you
would probably want name of git repository and relative path inside
git repository in prompt.

Therefore you need to use script anyway. And for scripting you should
use plumbing (which output format shouldn't change) and not porcelain
git-branch (which output might change, for example having '-v' on by
default, or something; and you might have color.ui set to true by
mistake and have to deal with color codes). And then you don't need
sed nor awk: POSIX shell features would be enough:

  BR=$(git symbolic-ref HEAD 2>/dev/null)
  BR=${BR#refs/heads/}
  BR=${BR:-HEAD} # one of possibilities to show detached HEAD / no branch

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH v2 tested-v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X
From: Marcel M. Cary @ 2009-01-04 21:47 UTC (permalink / raw)
  To: gitster; +Cc: git, jnareb, ae, j.sixt, git-dev, Marcel M. Cary
In-Reply-To: <8C7E36D0-C037-427D-B6E2-4050CC767CD0@marzelpan.de>

On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment
if available and shows the logical path by default rather than the
physical one.

Unset PWD before running /bin/pwd in both cd_to_toplevel and its
test.

Still use the external /bin/pwd because in my Bash on Linux,
the builtin pwd prints the same result whether or not PWD is set.

Signed-off-by: Marcel M. Cary <marcel@oak.homeunix.org>
Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)
---

> please add
> 
> Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)

Now with the OS, in detail.


 git-sh-setup.sh           |    2 +-
 t/t2300-cd-to-toplevel.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f07d96b..2142308 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -96,7 +96,7 @@ cd_to_toplevel () {
 		..|../*|*/..|*/../*)
 			# Interpret $cdup relative to the physical, not logical, cwd.
 			# Probably /bin/pwd is more portable than passing -P to cd or pwd.
-			phys="$(/bin/pwd)/$cdup"
+			phys="$(unset PWD; /bin/pwd)/$cdup"
 			;;
 		*)
 			# There's no "..", so no need to make things absolute.
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
index beddb4e..e42cbfe 100755
--- a/t/t2300-cd-to-toplevel.sh
+++ b/t/t2300-cd-to-toplevel.sh
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
 			cd '"'$1'"' &&
 			. git-sh-setup &&
 			cd_to_toplevel &&
-			[ "$(/bin/pwd)" = "$TOPLEVEL" ]
+			[ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
 		)
 	'
 }
 
-TOPLEVEL="$(/bin/pwd)/repo"
+TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
 mkdir -p repo/sub/dir
 mv .git repo/
 SUBDIRECTORY_OK=1
-- 
1.6.1

^ permalink raw reply related

* [PATCH v2 tested] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X
From: Marcel M. Cary @ 2009-01-04 21:27 UTC (permalink / raw)
  To: gitster; +Cc: git, jnareb, ae, j.sixt, git-dev, Marcel M. Cary
In-Reply-To: <AC726FD4-AE7F-4EC0-82E5-62C6D03C4E5A@marzelpan.de>

On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment
if available and shows the logical path by default rather than the
physical one.

Unset PWD before running /bin/pwd in both cd_to_toplevel and its
test.

Still use the external /bin/pwd because in my Bash on Linux,
the builtin pwd prints the same result whether or not PWD is set.

Signed-off-by: Marcel M. Cary <marcel@oak.homeunix.org>
Tested-by: Marcel Koeppen <git-dev@marzelpan.de>
---

Junio C Hamano wrote:
> I think I saw a success report on the list.  Care to resend it with
> Sign-off (by you) and
> 
>         Tested-by: tester <test@er.xz> (on PLATFORM)
> 
> lines as you see necessary for application?

Same as before but with S-o-b/T-b lines.

Marcel Koeppen wrote:
> [I don't know why my replies get lost, so I dropped all individual
> recipients on this third try...]

I noticed that Brian Gernhardt's message also didn't make it to the
list, even though it was addressed to the list.  I'm not sure why.


 git-sh-setup.sh           |    2 +-
 t/t2300-cd-to-toplevel.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f07d96b..2142308 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -96,7 +96,7 @@ cd_to_toplevel () {
 		..|../*|*/..|*/../*)
 			# Interpret $cdup relative to the physical, not logical, cwd.
 			# Probably /bin/pwd is more portable than passing -P to cd or pwd.
-			phys="$(/bin/pwd)/$cdup"
+			phys="$(unset PWD; /bin/pwd)/$cdup"
 			;;
 		*)
 			# There's no "..", so no need to make things absolute.
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
index beddb4e..e42cbfe 100755
--- a/t/t2300-cd-to-toplevel.sh
+++ b/t/t2300-cd-to-toplevel.sh
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
 			cd '"'$1'"' &&
 			. git-sh-setup &&
 			cd_to_toplevel &&
-			[ "$(/bin/pwd)" = "$TOPLEVEL" ]
+			[ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
 		)
 	'
 }
 
-TOPLEVEL="$(/bin/pwd)/repo"
+TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
 mkdir -p repo/sub/dir
 mv .git repo/
 SUBDIRECTORY_OK=1
-- 
1.6.1

^ permalink raw reply related

* Re: [PATCH] gitweb: merge boolean feature subroutines
From: Junio C Hamano @ 2009-01-04 21:25 UTC (permalink / raw)
  To: demerphq; +Cc: Matt Kraai, git
In-Reply-To: <9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>

demerphq <demerphq@gmail.com> writes:

> Is it really deep perl magic to do:
>
>   return $val eq 'true';
>
> instead of
>
>   return $val eq 'true' ? 1 : 0;

No, neither are magicky.  But your argument to favor the former over the
latter that goes down to XS level was all about deep magic, and you wrote
yourself:

> ... It is not a good idea to use 0 as a replacement for perls false, as
> the two have different behaviour.

My point is that any caller that cares about the differences of "Perl's
true false" and 0 when talking about a function that returns a yes/no
value is already soaked too deep in Perl's deep magic.  I would want the
code to be maintainable by people who does not care the deep voodoo, and
for that reason, I do not want the callers to care.

Having said that, I think it is perfectly fine to favor returning "$val eq
'true'" over returning "$val eq 'true ? 1 : 0".  But that is not because
it is truer way to say false from Perl experts' point of view, but because
it is shorter and more to the point.

^ permalink raw reply

* Re: git-rev-parse --symbolic-abbrev-name
From: Arnaud Lacombe @ 2009-01-04 20:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Karl Chen, Miklos Vajna, David Aguilar, Git mailing list
In-Reply-To: <7v63kuyibi.fsf@gitster.siamese.dyndns.org>

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

Hi,

On Sun, Jan 4, 2009 at 2:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Karl Chen <quarl@cs.berkeley.edu> writes:
>
>> ... you really think "branchfoo" instead of
>> "refs/heads/branchfoo" is a narrow special case?
>
> Of course it is narrower.  There are namespaces other than "heads" under
> refs, and not everybody is interested in branches.
>
>> obviously all those people posting on blogs don't know about it :)
>
> Yes, and that won't be helped by any new option to the plumbing.
>
> The above two does not necessarily mean that it is useless to add a new
> option to help a narrow special case that is common, though.
>
You'll find hereafter two patches which implements this in
git-symbolic-ref and git-rev-parse. Feel free to choose the one you
find the best. If you choose to integrate one of these, tells me and
I'll do a proper documentation bits and patch submission.

Sample output:

~/git/% ./git-rev-parse --symbolic-short-name HEAD
master
~/git/% ./git-symbolic-ref -a HEAD
master
~/git/% git checkout v1.6.1
~/git/% ./git-rev-parse --symbolic-short-name HEAD
HEAD
~/git/% ./git-symbolic-ref -a HEAD
fatal: ref HEAD is not a symbolic ref
~/git/% ./git-symbolic-ref -qa HEAD
~/git/%

Thanks in advance,

 - Arnaud

ps: I choose --symbolic-short-name as the opposite of
--symbolic-full-name for consistency.
ps2: sorry for the bogus mime-type

[-- Attachment #2: git-rev-parse_symbolic-short-name.diff --]
[-- Type: application/octet-stream, Size: 1507 bytes --]

diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 81d5a6f..70f4a33 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -24,6 +24,7 @@ static int show_type = NORMAL;
 
 #define SHOW_SYMBOLIC_ASIS 1
 #define SHOW_SYMBOLIC_FULL 2
+#define SHOW_SYMBOLIC_SHORT 3
 static int symbolic;
 static int abbrev;
 static int output_sq;
@@ -110,7 +111,10 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
 	def = NULL;
 
 	if (symbolic && name) {
-		if (symbolic == SHOW_SYMBOLIC_FULL) {
+		switch (symbolic) {
+		case SHOW_SYMBOLIC_FULL:
+		case SHOW_SYMBOLIC_SHORT:
+			{
 			unsigned char discard[20];
 			char *full;
 
@@ -125,13 +129,20 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
 				 */
 				break;
 			case 1: /* happy */
+				if (symbolic == SHOW_SYMBOLIC_SHORT) {
+					char *p;
+					p = strrchr(full, (int)'/');
+					if (p != NULL)
+						full = p + 1;
+				}
 				show_with_type(type, full);
 				break;
 			default: /* ambiguous */
 				error("refname '%s' is ambiguous", name);
-				break;
 			}
-		} else {
+			break;
+			}
+		default:
 			show_with_type(type, name);
 		}
 	}
@@ -506,6 +517,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				symbolic = SHOW_SYMBOLIC_FULL;
 				continue;
 			}
+			if (!strcmp(arg, "--symbolic-short-name")) {
+				symbolic = SHOW_SYMBOLIC_SHORT;
+				continue;
+			}
 			if (!strcmp(arg, "--all")) {
 				for_each_ref(show_reference, NULL);
 				continue;

[-- Attachment #3: git-symbolic-refs_abbrev-name.diff --]
[-- Type: application/octet-stream, Size: 1300 bytes --]

diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index bfc78bb..ff9ff46 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -8,7 +8,7 @@ static const char * const git_symbolic_ref_usage[] = {
 	NULL
 };
 
-static void check_symref(const char *HEAD, int quiet)
+static void check_symref(const char *HEAD, int quiet, int abbrev)
 {
 	unsigned char sha1[20];
 	int flag;
@@ -22,15 +22,21 @@ static void check_symref(const char *HEAD, int quiet)
 		else
 			exit(1);
 	}
+	if (abbrev) {
+		char *p = strrchr(refs_heads_master, (int)'/');
+		if (p != NULL)
+			refs_heads_master = p + 1;
+	}
 	puts(refs_heads_master);
 }
 
 int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 {
-	int quiet = 0;
+	int abbrev = 0, quiet = 0;
 	const char *msg = NULL;
 	struct option options[] = {
 		OPT__QUIET(&quiet),
+		OPT_BOOLEAN('a', NULL, &abbrev, "show only branch name"),
 		OPT_STRING('m', NULL, &msg, "reason", "reason of the update"),
 		OPT_END(),
 	};
@@ -41,7 +47,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 		die("Refusing to perform update with empty message");
 	switch (argc) {
 	case 1:
-		check_symref(argv[0], quiet);
+		check_symref(argv[0], quiet, abbrev);
 		break;
 	case 2:
 		create_symref(argv[0], argv[1], msg);

^ permalink raw reply related

* Re: [PATCH 2/3] unpack-trees: fix path search bug in verify_absent
From: Clemens Buchacher @ 2009-01-04 20:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git
In-Reply-To: <7vtz8fz8yd.fsf@gitster.siamese.dyndns.org>

Hi,

On Sun, Jan 04, 2009 at 02:01:14AM -0800, Junio C Hamano wrote:
>     The function's purpose is ....  Before entering the loop to count the
>     number of entries to skip, this check to detect if we do not even have
>     to count appears.  When this check triggers, we know we do not want to
>     skip anything, and returning constant 0 is much clearer than returning
>     a variable cnt that was initialized to 0 near the beginning of the
>     function; we haven't even started using it to count yet.
> 
> But the point is, if that is the reason the author thinks it is an
> improvement, that probably needs to be stated.

If you want to check the validity of the patch you have to view it in
context anyways. Compared to understanding the change to the code, it takes
much longer to parse and understand the above paragraph _plus_ verify its
agreement with the code. I think you will agree that there is a limit to the
amount of documentation that's still useful.

My estimate of this limit is apparently much lower than what is expected by
the main contributors to this project. I respect that and I will try not to
waste your time any further.

What's sad, however, is that we are now discussing style and commenting
issues of a line of code, which, as by my analysis of [PATCH 3/3] never
actually gets executed in the first place. I would have been much more
curious about your comments on that.

Best regards,
Clemens

^ permalink raw reply

* Re: Git-1.6.0.2-preview20080923
From: Sebastian Schuberth @ 2009-01-04 19:55 UTC (permalink / raw)
  To: Peter Krefting; +Cc: msysgit, Steffen Prohaska, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0809261026000.10516@ds9.cixit.se>

> > I updated the installer to Git-1.6.0.2-preview20080923.
>
> One issue that I see is that the installer does not seem to clean up
> the previously installed version on upgrade. I installed over the
> previous version to C:\Git, and I now have two git-add.exe files:
>
>  Directory of c:\git\bin
>
> 2008-06-22  18:41           925 184 git-add.exe
>
>  Directory of c:\git\libexec\git-core
>
> 2008-09-23  07:55           881 664 git-add.exe

I'm currently testing a patch that fixes this.

--
Sebastian

^ permalink raw reply

* Re: git-rev-parse --symbolic-abbrev-name
From: Junio C Hamano @ 2009-01-04 19:36 UTC (permalink / raw)
  To: Karl Chen; +Cc: Miklos Vajna, David Aguilar, Git mailing list
In-Reply-To: <quack.20090104T0434.lthfxjz1c8x_-_@roar.cs.berkeley.edu>

Karl Chen <quarl@cs.berkeley.edu> writes:

> ... you really think "branchfoo" instead of
> "refs/heads/branchfoo" is a narrow special case?

Of course it is narrower.  There are namespaces other than "heads" under
refs, and not everybody is interested in branches.

> obviously all those people posting on blogs don't know about it :)

Yes, and that won't be helped by any new option to the plumbing.

The above two does not necessarily mean that it is useless to add a new
option to help a narrow special case that is common, though.

^ 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