All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR
@ 2026-03-20 19:57 ` Dave Marquardt via B4 Relay
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Marquardt @ 2026-03-20 19:57 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Dave Marquardt



---
The `b4 prep --edit-cover` code calls git-filter-repo to update the
cover letter. When using a Git worktree, the user may get a confusing
message like

    Invoking git-filter-repo to update the cover letter.
    The previous run is older than a day (/home/davemarq/linux/linux/.git/worktrees/ibmvfc-fpin-bis/filter-repo/already_ran already exists).
    See "Already Ran" section in the manual for more information.
    Treat this run as a continuation of filtering in the previous run (Y/N)? n

There's code in run_frf() that removes
<top-level>/.git/filter-repo/already_ran, which may have been left
behind by git-filter-repo. This doesn't work for Git worktrees, where
the file is $GIT_DIR/filter-repo/already_ran. GIT_DIR is set to a
worktree-unique directory under the repository top level directory in
the worktree case. This update uses $GIT_DIR, which works for both
repositories and worktrees.

Signed-off-by: Dave Marquardt <davemarq@linux.ibm.com>
---
 src/b4/__init__.py | 10 ++++++++++
 src/b4/ez.py       |  8 ++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 46f3598..5a3c249 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -4029,6 +4029,16 @@ def git_get_toplevel(path: Optional[str] = None) -> Optional[str]:
         topdir = lines[0]
     return topdir
 
+def git_get_gitdir(path: Optional[str] = None) -> Optional[str]:
+    topdir = None
+    # Are we in a git tree and if so, what is our git-dir?
+    gitargs = ['rev-parse', '--git-dir']
+    lines = git_get_command_lines(path, gitargs)
+    if len(lines) == 1:
+        topdir = lines[0]
+        if not pathlib.PurePath(topdir).is_absolute():
+            topdir = Path.cwd().joinpath(topdir)
+    return topdir
 
 def git_get_common_dir(path: Optional[str] = None) -> Optional[str]:
     gitargs = ['rev-parse', '--git-common-dir']
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 9b0e010..b7afab5 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -156,10 +156,10 @@ def run_frf(frf: fr.RepoFilter) -> None:
     logger.debug('Running git-filter-repo...')
     frf.run()
     logger.debug('git-filter-repo complete')
-    gtl = b4.git_get_toplevel()
-    if isinstance(gtl, str):
-        # Remove .git/filter-repo/already_ran
-        already_ran = os.path.join(gtl, '.git', 'filter-repo', 'already_ran')
+    gitdir = b4.git_get_gitdir()
+    if isinstance(gitdir, str):
+        # Remove $GIT_DIR/filter-repo/already_ran
+        already_ran = os.path.join(gitdir, 'filter-repo', 'already_ran')
         if os.path.exists(already_ran):
             logger.debug('Removing %s', already_ran)
             os.remove(already_ran)

---
base-commit: bc6c4d853c7eace3b7f325cbd17dfe2d67760fb7
change-id: 20260320-fix-edit-cover-with-workspace-cb08c238d6b7

Best regards,
--  
Dave Marquardt <davemarq@linux.ibm.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR
@ 2026-03-20 19:57 ` Dave Marquardt via B4 Relay
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Marquardt via B4 Relay @ 2026-03-20 19:57 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Dave Marquardt

From: Dave Marquardt <davemarq@linux.ibm.com>



---
The `b4 prep --edit-cover` code calls git-filter-repo to update the
cover letter. When using a Git worktree, the user may get a confusing
message like

    Invoking git-filter-repo to update the cover letter.
    The previous run is older than a day (/home/davemarq/linux/linux/.git/worktrees/ibmvfc-fpin-bis/filter-repo/already_ran already exists).
    See "Already Ran" section in the manual for more information.
    Treat this run as a continuation of filtering in the previous run (Y/N)? n

There's code in run_frf() that removes
<top-level>/.git/filter-repo/already_ran, which may have been left
behind by git-filter-repo. This doesn't work for Git worktrees, where
the file is $GIT_DIR/filter-repo/already_ran. GIT_DIR is set to a
worktree-unique directory under the repository top level directory in
the worktree case. This update uses $GIT_DIR, which works for both
repositories and worktrees.

Signed-off-by: Dave Marquardt <davemarq@linux.ibm.com>
---
 src/b4/__init__.py | 10 ++++++++++
 src/b4/ez.py       |  8 ++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 46f3598..5a3c249 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -4029,6 +4029,16 @@ def git_get_toplevel(path: Optional[str] = None) -> Optional[str]:
         topdir = lines[0]
     return topdir
 
+def git_get_gitdir(path: Optional[str] = None) -> Optional[str]:
+    topdir = None
+    # Are we in a git tree and if so, what is our git-dir?
+    gitargs = ['rev-parse', '--git-dir']
+    lines = git_get_command_lines(path, gitargs)
+    if len(lines) == 1:
+        topdir = lines[0]
+        if not pathlib.PurePath(topdir).is_absolute():
+            topdir = Path.cwd().joinpath(topdir)
+    return topdir
 
 def git_get_common_dir(path: Optional[str] = None) -> Optional[str]:
     gitargs = ['rev-parse', '--git-common-dir']
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 9b0e010..b7afab5 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -156,10 +156,10 @@ def run_frf(frf: fr.RepoFilter) -> None:
     logger.debug('Running git-filter-repo...')
     frf.run()
     logger.debug('git-filter-repo complete')
-    gtl = b4.git_get_toplevel()
-    if isinstance(gtl, str):
-        # Remove .git/filter-repo/already_ran
-        already_ran = os.path.join(gtl, '.git', 'filter-repo', 'already_ran')
+    gitdir = b4.git_get_gitdir()
+    if isinstance(gitdir, str):
+        # Remove $GIT_DIR/filter-repo/already_ran
+        already_ran = os.path.join(gitdir, 'filter-repo', 'already_ran')
         if os.path.exists(already_ran):
             logger.debug('Removing %s', already_ran)
             os.remove(already_ran)

---
base-commit: bc6c4d853c7eace3b7f325cbd17dfe2d67760fb7
change-id: 20260320-fix-edit-cover-with-workspace-cb08c238d6b7

Best regards,
--  
Dave Marquardt <davemarq@linux.ibm.com>



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR
  2026-03-20 19:57 ` Dave Marquardt via B4 Relay
  (?)
@ 2026-03-20 20:05 ` Konstantin Ryabitsev
  2026-03-20 20:16   ` Dave Marquardt
  -1 siblings, 1 reply; 5+ messages in thread
From: Konstantin Ryabitsev @ 2026-03-20 20:05 UTC (permalink / raw)
  To: davemarq; +Cc: Kernel.org Tools

On Fri, Mar 20, 2026 at 02:57:24PM -0500, Dave Marquardt via B4 Relay wrote:
> From: Dave Marquardt <davemarq@linux.ibm.com>
> 
> 
> 
> ---
> The `b4 prep --edit-cover` code calls git-filter-repo to update the
> cover letter. When using a Git worktree, the user may get a confusing
> message like

(Unrelated to the patch contents.)

I wonder how this happened? Is the content below '---' just the cover letter
and the commit itself is without any message?

>     Invoking git-filter-repo to update the cover letter.
>     The previous run is older than a day (/home/davemarq/linux/linux/.git/worktrees/ibmvfc-fpin-bis/filter-repo/already_ran already exists).
>     See "Already Ran" section in the manual for more information.
>     Treat this run as a continuation of filtering in the previous run (Y/N)? n
> 
> There's code in run_frf() that removes
> <top-level>/.git/filter-repo/already_ran, which may have been left
> behind by git-filter-repo. This doesn't work for Git worktrees, where
> the file is $GIT_DIR/filter-repo/already_ran. GIT_DIR is set to a
> worktree-unique directory under the repository top level directory in
> the worktree case. This update uses $GIT_DIR, which works for both
> repositories and worktrees.
> 
> Signed-off-by: Dave Marquardt <davemarq@linux.ibm.com>
> ---
>  src/b4/__init__.py | 10 ++++++++++
>  src/b4/ez.py       |  8 ++++----
>  2 files changed, 14 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR
  2026-03-20 20:05 ` Konstantin Ryabitsev
@ 2026-03-20 20:16   ` Dave Marquardt
  2026-03-20 20:21     ` Konstantin Ryabitsev
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Marquardt @ 2026-03-20 20:16 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Kernel.org Tools

Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:

> On Fri, Mar 20, 2026 at 02:57:24PM -0500, Dave Marquardt via B4 Relay wrote:
>> From: Dave Marquardt <davemarq@linux.ibm.com>
>> 
>> 
>> 
>> ---
>> The `b4 prep --edit-cover` code calls git-filter-repo to update the
>> cover letter. When using a Git worktree, the user may get a confusing
>> message like
>
> (Unrelated to the patch contents.)
>
> I wonder how this happened? Is the content below '---' just the cover letter
> and the commit itself is without any message?

I feel like we've had this conversation a previous time I submitted a
patch, several months ago. Yes, I think you're correct, the actual
commit doesn't have a message. I also recall you looking at this before
and I thought you had attempted to fix it.

>>     Invoking git-filter-repo to update the cover letter.
>>     The previous run is older than a day (/home/davemarq/linux/linux/.git/worktrees/ibmvfc-fpin-bis/filter-repo/already_ran already exists).
>>     See "Already Ran" section in the manual for more information.
>>     Treat this run as a continuation of filtering in the previous run (Y/N)? n
>> 
>> There's code in run_frf() that removes
>> <top-level>/.git/filter-repo/already_ran, which may have been left
>> behind by git-filter-repo. This doesn't work for Git worktrees, where
>> the file is $GIT_DIR/filter-repo/already_ran. GIT_DIR is set to a
>> worktree-unique directory under the repository top level directory in
>> the worktree case. This update uses $GIT_DIR, which works for both
>> repositories and worktrees.
>> 
>> Signed-off-by: Dave Marquardt <davemarq@linux.ibm.com>
>> ---
>>  src/b4/__init__.py | 10 ++++++++++
>>  src/b4/ez.py       |  8 ++++----
>>  2 files changed, 14 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR
  2026-03-20 20:16   ` Dave Marquardt
@ 2026-03-20 20:21     ` Konstantin Ryabitsev
  0 siblings, 0 replies; 5+ messages in thread
From: Konstantin Ryabitsev @ 2026-03-20 20:21 UTC (permalink / raw)
  To: Dave Marquardt; +Cc: Kernel.org Tools

On Fri, Mar 20, 2026 at 03:16:49PM -0500, Dave Marquardt wrote:
> > I wonder how this happened? Is the content below '---' just the cover letter
> > and the commit itself is without any message?
> 
> I feel like we've had this conversation a previous time I submitted a
> patch, several months ago. Yes, I think you're correct, the actual
> commit doesn't have a message. I also recall you looking at this before
> and I thought you had attempted to fix it.

Yeah, clearly not. :) I'll add it to my plan.otl

No worries -- I've taken this patch with minor changes (one test started
failing). No need to send a follow-up revision.

Thanks!
-- 
KR

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-20 20:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 19:57 [PATCH b4] prep: Make `b4 prep --edit-cover` remove already_ran file under $GIT_DIR Dave Marquardt
2026-03-20 19:57 ` Dave Marquardt via B4 Relay
2026-03-20 20:05 ` Konstantin Ryabitsev
2026-03-20 20:16   ` Dave Marquardt
2026-03-20 20:21     ` Konstantin Ryabitsev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.