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

Re: [JGIT PATCH 2/3] Cleanup of Branch command ready for verbose mode

From
MZMarek Zawirski <marek.zawirski@gmail.com>
Date
Aug 18, 2008, 13:41 UTC
Message-ID
<48A97C23.8030103@gmail.com>
In-Reply-To
<1219057305-9284-3-git-send-email-charleso@charleso.org>
Charles O'Farrell wrote:
> diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Branch.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Branch.java
(...)
Show 11 quoted lines
> @@ -87,17 +91,27 @@ private void list() {
>  		if (head != null) {
>  			String current = head.getName();
>  			if (current.equals(Constants.HEAD))
> -				printHead("(no branch)", true);
> -			for (String ref : new TreeSet<String>(refs.keySet())) {
> -				if (isHead(ref))
> -					printHead(ref, current.equals(ref));
> +				addRef("(no branch)", head);
> +			addRefs(refs, Constants.HEADS_PREFIX, !remote);
> +			addRefs(refs, Constants.REMOTES_PREFIX, remote);

We used to use (Constants.HEADS_PREFIX + '/') or (Constants.REMOTES_PREFIX + '/') in such places, probably to handle correctly jokes like refs named "refs/remotes_will_broke_your_code".

I've seen this expression so many times that I think it's right moment to create another Constants.HEADS_PREFIX_SLASHED (same for tags, remotes) or similar as this piece of this code is redundant in many places. But wait, does anybody use pure ones without slashes? Maybe we can just change existing constants.

Beside of that detail, me (being just jgit developer) says that the series looks good. Oh, and it's probably good to follow convention of marking variables as final when they are final.

-- 
Marek Zawirski [zawir]
marek.zawirski@gmail.com
Previous: Charles O'FarrellNext: Shawn O. Pearce
Message 5 of 6 in “jgit: Verbase branch command”
  1. 0/3 jgit: Verbase branch commandCharles O'Farrell, Aug 18, 2008
  2. 1/3 Extract RefComparator to sort collection of RefsCharles O'Farrell, Aug 18, 2008
  3. 2/3 Cleanup of Branch command ready for verbose modeCharles O'Farrell, Aug 18, 2008
  4. 3/3 Verbose branch commandCharles O'Farrell, Aug 18, 2008
  5. Marek ZawirskiAug 18, 2008
  6. Shawn O. PearceAug 18, 2008

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.