git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH JGIT] Equals method should not assume anything about the type of its argument

From
Shawn O. Pearce <spearce@spearce.org>
Date
Apr 29, 2009, 15:02 UTC
Message-ID
<20090429150240.GB23604@spearce.org>
In-Reply-To
<366BBB1215D0AB4B8A153AF047A287800302A6F9@dewdfe18.wdf.sap.corp>
"Sohn, Matthias" <matthias.sohn@sap.com> wrote:
> The equals(Object o) method shouldn't make any assumptions about the type of o. It should simply return false if o is not the same type as this.
True.
Please line wrap your commit message at ~70 columns wide.
 
> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>

FWIW, your From header in the emails comes out "Sohn, Matthias" while your Signed-off-By is as above. This means that when I slam your patch through git-am I get an author name of "Sohn, Matthias", which looks damn funny. I have to remember to edit the patch after the fact to make it come out correct.

Any change you can get your MUA to behave better? Or is this Exchange enforcing a nice uniform standard... *sigh*

Show 15 quoted lines
> 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 2e3a43e..0bd2288 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
> @@ -253,7 +253,11 @@ public boolean equals(final AnyObjectId other) {
>  	}
>  
>  	public boolean equals(final Object o) {
> -		return equals((AnyObjectId) o);
> +		if (o instanceof AnyObjectId) {
> +			return equals((AnyObjectId) o);
> +		} else {
> +			return false;
> +		}
>  	}
Style nit: We avoid unnecessary braces around clauses.
-- 
Shawn.
Previous: Sohn, Matthias
Message 2 of 2 in “Equals method should not assume anything about the type of its argument”
  1. Equals method should not assume anything about the type of its argumentSohn, Matthias, Apr 29, 2009
  2. Shawn O. PearceApr 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.