Re: [PATCH v3 4/4] for-each-ref: avoid filtering on empty pattern
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 6, 2024, 15:30 UTC
- Message-ID
- <CAOLa=ZRLuy2H-r3A0BE-mS4Zm=ebhLR+SemZ3nAghEnRB5dR_A@mail.gmail.com>
- In-Reply-To
- <92ba680d-0b48-49f0-aafc-f503e5a5e0ea@gmail.com>
Hello,
On Tue, Feb 6, 2024 at 2:55 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 30 quoted lines
>
> Hi Karthik
>
> On 06/02/2024 08:52, Karthik Nayak wrote:
> > On Mon, Feb 5, 2024 at 7:48 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
> >> On 29/01/2024 11:35, Karthik Nayak wrote:
> >>> When the user uses an empty string pattern (""), we don't match any refs
> >>> in git-for-each-ref(1). This is because in git-for-each-ref(1), we use
> >>> path based matching and an empty string doesn't match any path.
> >>>
> >>> In this commit we change this behavior by making empty string pattern
> >>> match all references. This is done by introducing a new flag
> >>> `FILTER_REFS_NO_FILTER` in `ref-filter.c`, which uses the newly
> >>> introduced `refs_for_each_all_refs()` function to iterate over all the
> >>> refs in the repository.
> >>
> >> It actually iterates over all the refs in the current worktree, not all
> >> the refs in the repository. I have to say that I find it extremely
> >> unintuitive that "" behaves differently to not giving a pattern. I
> >> wonder if we can find a better UI here - perhaps a command line option
> >> to include pseudorefs?
> >>
> >
> > As Patrick mentioned, this was discussed a while ago and we decided to
> > move forward with the `git for-each-ref ""` syntax.
>
> Thanks I'd missed that discussion. I see that at the end of that
> discussion Junio was concerned that the proposed "" did not account for
> "refs/worktrees/$worktree/*" [1] - how has that been resolved?
>The current implementation (merged to next) prints all the refs from the current worktree and doesn't support printing from other worktrees.
$ git worktree add ../wt-files @~10
Preparing worktree (detached HEAD 559d5138bc)
HEAD is now at 559d5138bc Merge branch 'jc/make-libpath-template' into next $ cd ../wt-files/
direnv: unloading $ git for-each-ref "" | grep -v "refs"
559d5138bc8b81354fd1bc3421ace614076e66de commit HEAD
559d5138bc8b81354fd1bc3421ace614076e66de commit ORIG_HEAD $ git rebase -i @~3
Stopped at be65f9ef88... t/Makefile: get UNIT_TESTS list from C sources
You can amend the commit now, withgit commit --amend '-S'
Once you are satisfied with your changes, run
git rebase --continue
$ git for-each-ref "" | grep -v "refs"
be65f9ef88ff741454dcf10a0af6e384d0bf26cf commit HEAD
43f081b9c7dfb9c23e547ffee1778af0f30c5c4e commit ORIG_HEAD
be65f9ef88ff741454dcf10a0af6e384d0bf26cf commit REBASE_HEAD