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

Re: [Qgit RFC] commit --amend

From
JHJan Hudec <bulb@ucw.cz>
Date
Jul 5, 2007, 18:54 UTC
Message-ID
<20070705185426.GB3991@efreet.light.src>
In-Reply-To
<e5bfff550706102245p27aea579w65ee96161630a624@mail.gmail.com>
Hello,
On Mon, Jun 11, 2007 at 07:45:51 +0200, Marco Costalba wrote:
Show 27 quoted lines
> On 6/11/07, Jan Hudec <bulb@ucw.cz> wrote:
>> I think I mostly understood it now. Thank you.
>
> Anyhow I think this could be useful to you:
>
> 	/*
> 	   getAllRefSha() returns the list of sha of a given
> 	   type, where type is a mask of Git::RefType flags
> 	   see src/git.h.
> 	   In this case we want the sha of the current branch
> 	*/
> 	QStringList revs = getAllRefSha(CUR_BRANCH);
> 	
> 	if (!revs.isEmpty()) {
>
> 		// all the sha info is stored in this QGit::Rev
> 		// class defined in src/common.h
> 		const Rev* r = revLookup(revs.first());
>
> 		// short log (title) is
> 		r->shortLog();
>
> 		// message body is
> 		r->longLog();
>
> 		// etc....
> 	}

I thought I should be using something more explicit. Like getRefSha("HEAD", ANY_REF, false) -- only to find that it wouldn't work. That means that this code would not work either. Why? Well, because HEAD does not have to be a symbolic ref. If you check out anything else than branch (which you can), HEAD will be set to the SHA1 directly and if you commit in such state (which you also can), the HEAD will be different from anything in refs/.

Therefore I'll either have to always ask git via run("git-rev-parse HEAD", head), add HEAD into the map, or store HEAD somewhere in the Git object. Which do you think makes most sense?

(Note: Yes, I noted that getRefSha("HEAD", ANY_REF, true) should work, but of course that is the run("git-rev-parse HEAD") case.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Marco CostalbaNext: Marco Costalba
Message 14 of 17 in “[Qgit RFC] commit --amend”
  1. Jan HudecJun 10, 2007
  2. Marco CostalbaJun 10, 2007
  3. Jan HudecJun 11, 2007
  4. Marco CostalbaJun 11, 2007
  5. Marco CostalbaJun 11, 2007
  6. Jan HudecJul 1, 2007
  7. Marco CostalbaJul 1, 2007
  8. Jan HudecJul 2, 2007
  9. Junio C HamanoJul 4, 2007
  10. Marco CostalbaJul 4, 2007
  11. Jan HudecJul 4, 2007
  12. Junio C HamanoJul 4, 2007
  13. Marco CostalbaJul 6, 2007
  14. Jan HudecJul 5, 2007
  15. Marco CostalbaJul 6, 2007
  16. Jan HudecJul 8, 2007
  17. Marco CostalbaJul 8, 2007

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.