Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339246 - Implement git describe
Summary: Implement git describe
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: 3.2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-08 11:35 EST by Shawn Pearce CLA
Modified: 2014-06-27 05:51 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Pearce CLA 2011-03-08 11:35:26 EST
`git describe HEAD` produces output such as v0.11.3-100-gbbcf552.

The basic algorithm is to search backwards from HEAD until an annotated tag is found (here v0.11.3), and then counts up the number of commits that are not part of the annotated tag, but are part of HEAD (here 100), then suffixes the whole thing with a unique abbreviation of HEAD (bbcf552).

I actually wrote most of the current C Git describe code, so I should be able to port it over fairly quickly... assuming I can find the time to write the Java implementation of it.  There are some gotchas with the tag matching logic to prevent a maintenance fix release from causing the revision numbering to jump backwards.  I fixed this in C Git as part of:

  commit 80dbae03b010b1e5c6e0e4f475578d6cadaadecf
  Author: Shawn O. Pearce <spearce@spearce.org>
  Date:   Wed Jan 10 06:39:47 2007 -0500

    Chose better tag names in git-describe after merges.
Comment 1 Matthias Sohn CLA 2013-09-27 06:56:12 EDT
Koshuke has implemented this, here's the review
https://git.eclipse.org/r/#/c/14871/
Comment 2 Max Hohenegger CLA 2014-06-18 08:45:33 EDT
I am using JGit 3.3.2.201404171909-r from http://download.eclipse.org/egit/updates. Describe is implmented and it seems to work.

Example:
Git.wrap(repository).describe().setTarget(ObjectId.fromString("hash")).call()

Is there a reason this bug is still open?

Thanks
Max
Comment 3 Matthias Sohn CLA 2014-06-18 09:07:03 EDT
we missed to close this bug

the implementation was merged as f045a68a78f251af836c6b0a18a22a6d9e5f55a0 on Oct 2, 2013
Comment 4 Max Hohenegger CLA 2014-06-27 05:51:43 EDT
In that case, thanks for the patch!

As nobody seems to mind, I'll go ahead and mark this as resolved.