Re: [PATCH] commit: Add commit_list prefix to reduce_heads function.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thiago Farina <tfransosi@xxxxxxxxx> writes:

> Also I thought that as Junio already picked up the other patch. It's
> was a hint that the other functions that has "struct commit_list *l"
> as its parameters could be renamed as well.

You took a wrong hint and I think that is because you didn't think about
what naming is for.

"insert-by-date" does not say _why_ you want things to be inserted by date
(neither "sort-by-date").  They are pretty generic looking names for any
function that deal with a list of elements that record date.  It makes
sense to anticipate there will be many other such functions that deal with
different kinds of lists that hold date-recording things, and naming one
of them "this deals with list of COMMITS" by saying "commit_list_foo"
makes quite a lot of sense, as "insert-by-date" does not give sufficient
information to the reader.

On the other hand, "reduce-heads" is with quite a higher level of
semantics than "insert-by-date" and friends.  The caller has a set of
commits and wants to remove the ones that can be reached by other commits
in that set, typically because it wants to come up with a list of commits
to be used as parents of a merge commit across them.  It has much stronger
"why" associated with it; unlike "insert-by-date" and friends, there can't
be many other such functions that deal with different datastructures that
hold commits to reduce the heads the same way.

A related tangent.  There are two ways to name functions with richer "why"
component.  Some people name them after what the caller expects them to do
(e.g. they would name "compute merge parents" the function in question),
and others names them after what they themselves do (e.g. it is about
reducing the set of heads by removing redundant parents, and it does not
question for what purpose the caller wants to do so).  In general, it is
preferrable to name them after what they do, not why the caller wants them
to do so, especially when the semantics is clear.  It will allow easier
reuse of the function by new callers that do not create a new merge commit
but wants the same head reduction.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]