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

Re: [PATCH] git-gui: give more advice when detaching HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2011, 08:42 UTC
Message-ID
<7voc6hy771.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vzkq1y8dv.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> You only need to dig until you hit a merge base, no?
> ...
> And merge-base has an interface to compute exactly that, I think.

Ah, forget "merge-base". In the kernel repository, the very old "v2.6.12" will participate in the (imaginary) merge across all the refs, and computing merge-base means we need to traverse down to it.

We only need to prime a "struct revisions" with the detached HEAD as the sole positive, and the refs as negatives (i.e. UNINTERESTING), and walk the history the usual way, until we either

 (1) see HEAD painted uninteresting; or
 (2) the queue becomes all uninteresting.

As soon as (1) happens, we know the HEAD is reachable from some ref, and we can immediately stop. When (2) happens, we inspect the HEAD again and if it is painted uninteresting then we know HEAD is reachable from some ref. Otherwise HEAD will become dangling when you leave it.

That way, the traversal will terminate much sooner than computing the true merge base.

Previous: Junio C HamanoNext: Sverre Rabbelier
Message 7 of 19 in “git-gui: give more advice when detaching HEAD”
  1. git-gui: give more advice when detaching HEADJeff King, Feb 12, 2011
  2. Junio C HamanoFeb 12, 2011
  3. Jeff KingFeb 12, 2011
  4. Junio C HamanoFeb 12, 2011
  5. Jeff KingFeb 12, 2011
  6. Junio C HamanoFeb 17, 2011
  7. Junio C HamanoFeb 12, 2011
  8. Sverre RabbelierFeb 13, 2011
  9. Johannes SixtFeb 13, 2011
  10. Junio C HamanoFeb 13, 2011
  11. Heiko VoigtFeb 13, 2011
  12. Jeff KingFeb 15, 2011
  13. Heiko VoigtFeb 15, 2011
  14. Pat ThoytsFeb 15, 2011
  15. Jeff KingFeb 16, 2011
  16. Heiko VoigtFeb 17, 2011
  17. Jeff KingFeb 16, 2011
  18. Heiko VoigtFeb 17, 2011
  19. Victor EngmarkFeb 16, 2011

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.