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

Re: [PATCH 1/1] rebase: teach `--exec` about `GIT_REBASE_BRANCH`

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Mar 7, 2024, 15:18 UTC
Message-ID
<b2555c2c-0725-4d33-853b-e17022689977@app.fastmail.com>
In-Reply-To
<xmqqo7buuce7.fsf@gitster.g>
On Mon, Mar 4, 2024, at 00:24, Junio C Hamano wrote:
Show 37 quoted lines
> Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
>
>> The command fed to `--exec` might need some contextual information from
>> the branch name. But there is no convenient access to the branch name
>> that we were on before starting the rebase; rebase operates in detached
>> HEAD mode so we cannot ask for it directly. This means that we need to
>> parse something like this from the first line of `git branch --list`:
>>
>>     (no branch, rebasing <branch>)
>>
>> This is a moderate amount of effort for something that git-rebase(1) can
>> store for us.
>>
>> To that end, teach `--exec` about an env. variable which stores the
>> branch name for the rebase-in-progress, if applicable.
>
> You seem to be saying that `git branch --list` output already
> contains the necessary information but it is shown in a hard to use
> format.  Is the information given at least always accurate and
> reliable?
>
> Assuming it is, do you know where "git branch --list" gets that
> information when it says "(no branch, rebasing <branch>)"?
>
> git-rebase(1) is already storing information sufficient to let "git
> branch --list" to produce that information, and there are other ways
> to inspect that state ("git status" gives the same information but
> it also is in a "meant for humans" format).
>
> So, isn't it just the matter of surfacing the information that we
> are already recording and is already available in a fashion that is
> easier to use?  For example, if "git status --porcelain=[version]"
> does not give the information, perhaps you can add a line or two to
> it, instead of duplicating the same information in two places?
>
> It comes from wt-status.c:wt_status_check_rebase() where state->branch
> is assigned to, by reading "$GIT_DIR/rebase-{apply,merge}/head-name".

Okay, thanks for the code directions and input (both). I’ll try to get back to a rewrite on this topic in a while.

Cheers
-- 
Kristoffer Haugsbakk
Previous: Phillip Wood
Message 5 of 5 in “rebase: teach `--exec` about `GIT_REBASE_BRANCH`”
  1. 0/1 rebase: teach `--exec` about `GIT_REBASE_BRANCH`Kristoffer Haugsbakk, Mar 3, 2024
  2. 1/1 rebase: teach `--exec` about `GIT_REBASE_BRANCH`Kristoffer Haugsbakk, Mar 3, 2024
  3. Junio C HamanoMar 3, 2024
  4. Phillip WoodMar 4, 2024
  5. Kristoffer HaugsbakkMar 7, 2024

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.