Re: [RFC PATCH] hooks--pre-push.sample: identify branch point

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

 



Hi Antoine,

On Thu, Mar 9, 2023 at 4:34 PM Antoine Beaupré <anarcat@xxxxxxxxxx> wrote:

> https://stackoverflow.com/a/71193866/1174784
>
> There are currently a whopping twenty-five answers to that question in
> that thread, and I'm hoping the community here will have a more
> definitive answer to this question. I have picked the answer that uses
> the least possible external commands, but it still uses a `tail -1`
> which I'm somewhat unhappy about. I have thought of using
> `--max-count` for this instead, but I understand that probably does
> the equivalent of a `head -n` *and* it's applied before `--reverse`,
> so there's not other way to do this.

I spent an inordinate amount of time trying to answer that question a
decade ago, and my conclusion after trying every possible combination
is that it's simply not possible. Every solution at the end of the day
will be a hack that can be broken with a corner case. It has already
been discussed in this mailing list [1], and nobody found a solution.

That's why I wrote a patch to implement a branch@{tail} helper to show
an auxiliary ref to the beginning of the branch. I don't think I ever
sent it to the mailing list, as my patches are rarely merged, but I'm
sure I have it somewhere.

The other solution I thought of was adding an update-branch hook that
could be run every time a branch is updated, and then the hook would
update the branch tail reference [2]. As expected, that patch wasn't
merged either.

It's interesting how we keep coming back to the same problems; right
now there's a discussion in the git-users mailing list precisely about
the same topic: how to find the branch point, in particular so `git
name-rev` shows the correct branch a commit belongs to (which is
otherwise just a bad guess).

FWIW my motivation at the time was to prove Mercurial users wrong
regarding features that they have and Git doesn't, I contended that
Mercurial named branches (aka commit labels) were not necessary, and
everything they achieved could be achieved in Git through different
means. That turned out to be untrue, as there is one thing Mercurial
can do that Git can't: show the precise point a branch started from.

I abandoned my efforts back then, but the topic seems inescapable, as
that is also needed by new tools like `git range-diff`, so in my own
tool to keep track of patch series (`git send-series`[2])I end up
creating a ton of refs just to properly keep track of the branch
points of my different patch series.

If only Git developers acknowledged the current very real limitation,
something could be done about it.

Cheers.

[1] https://lore.kernel.org/git/CAMP44s0f7AJPQSTDgvy0U7vx8nxzq2a3vMhSr2Tcc61fetFkJA@xxxxxxxxxxxxxx/
[2] https://lore.kernel.org/git/1398047016-21643-1-git-send-email-felipe.contreras@xxxxxxxxx/
[3] https://github.com/felipec/git-send-series

-- 
Felipe Contreras




[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]

  Powered by Linux