From: Felipe Contreras <felipe.contreras@gmail.com>
To: "Antoine Beaupré" <anarcat@debian.org>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] hooks--pre-push.sample: identify branch point
Date: Thu, 9 Mar 2023 17:22:55 -0600 [thread overview]
Message-ID: <CAMP44s2=qzmF1Odc_auCaKQmTBYD53YYtaJv_LGwvoFDmTxPSA@mail.gmail.com> (raw)
In-Reply-To: <20230309220405.219212-1-anarcat@debian.org>
Hi Antoine,
On Thu, Mar 9, 2023 at 4:34 PM Antoine Beaupré <anarcat@debian.org> 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@mail.gmail.com/
[2] https://lore.kernel.org/git/1398047016-21643-1-git-send-email-felipe.contreras@gmail.com/
[3] https://github.com/felipec/git-send-series
--
Felipe Contreras
next prev parent reply other threads:[~2023-03-09 23:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 22:04 [RFC PATCH] hooks--pre-push.sample: identify branch point Antoine Beaupré
2023-03-09 23:22 ` Felipe Contreras [this message]
2023-03-10 16:28 ` Antoine Beaupré
2023-03-10 22:09 ` Felipe Contreras
2023-03-12 18:14 ` Antoine Beaupré
2023-03-16 17:32 ` Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMP44s2=qzmF1Odc_auCaKQmTBYD53YYtaJv_LGwvoFDmTxPSA@mail.gmail.com' \
--to=felipe.contreras@gmail.com \
--cc=anarcat@debian.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).