Re: What's cooking in git.git (Jun 2011, #02; Sat, 11)
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:28
Ramkumar Ramachandra [off-list ref] 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