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

Re: What's cooking in git.git (Jun 2011, #02; Sat, 11)

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 13, 2011, 13:16 UTC
Message-ID
<7vd3ihrhvf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<BANLkTinHCX0vmAdk+su-_Y0th9vLQ6qsnw@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Have you seen my "libify reset" patch [1]?  I thought it was an easy candidate.

The reset-index-file part might be (but I agree with Jonathan that we can wait until we need it), but the other one does not deserve to be called a "libified" function if you look at it as an API function.

There are many places we show abbreviated commit object name and its title with different frills around that message, but that particular function does not help them unless the other callers want the same "HEAD is now at" frill. Try this:

 $ git checkout HEAD^
 HEAD is now at 2cbd969... Git 1.7.6-rc1
 $ git checkout master
 Previous HEAD position was 2cbd969... Git 1.7.6-rc1
 Switched to branch 'master'

Your helper cannot even help produce "Previous HEAD position was", even though I am reasonably sure they share the same logic.

A helper whose signature is something like
    void pretty_print_commit(FILE *f, const char *fmt, struct commit *commit);
so that the caller can say
    pretty_print_commit(stdout, "HEAD is now at %h... %s\n", commit)

instead of "print_new_head(commit)", might be a good addition to the "libified" helper set, but I suspect it is not worth it.

Look at how clearly and succinctly describe_detached_head() is implemented in builtin/checkout.c

Previous: Jonathan NiederNext: Sverre Rabbelier
Message 4 of 9 in “What's cooking in git.git (Jun 2011, #02; Sat, 11)”
  1. Junio C HamanoJun 12, 2011
  2. Ramkumar RamachandraJun 12, 2011
  3. "libify part of reset" mini-series (Re: What's cooking in git.git (Jun 2011, #02; Sat, 11))Jonathan Nieder, Jun 13, 2011
  4. Junio C HamanoJun 13, 2011
  5. Sverre RabbelierJun 12, 2011
  6. Junio C HamanoJun 13, 2011
  7. Sverre RabbelierJun 13, 2011
  8. Elijah NewrenJun 14, 2011
  9. Jeff KingJun 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.