tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix shazam for multiple git worktrees
@ 2021-10-19 14:46 Rob Herring
  2021-10-19 21:33 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2021-10-19 14:46 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: tools

The shazam command makes assumptions that '.git' is a directory which is
not the case with multiple worktree. Use 'git rev-parse' instead to
retrieve the correct paths.

Signed-off-by: Rob Herring <robh@kernel.org>
---
Maybe $GIT_DIR/b4-cover is not the best location given it depends on 
worktree details. Perhaps a .b4/ directory instead? 

 b4/mbox.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/b4/mbox.py b/b4/mbox.py
index 50dd2c36bb49..1b35623c2880 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -307,9 +307,13 @@ def make_am(msgs, cmdargs, msgid):
                 logger.critical('Unable to fetch from the worktree')
                 logger.critical(out.strip())
                 sys.exit(ecode)
-            # Edit the FETCH_HEAD to give a better default merge message
-            fhf = os.path.join(topdir, '.git', 'FETCH_HEAD')
-            with open(fhf, 'r') as fhh:
+            gitargs = ['rev-parse', '--git-path', 'FETCH_HEAD']
+            ecode, fhf = b4.git_run_command(topdir, gitargs, logstderr=True)
+            if ecode > 0:
+                logger.critical('Unable to find FETCH_HEAD')
+                logger.critical(out.strip())
+                sys.exit(ecode)
+            with open(fhf.rstrip(), 'r') as fhh:
                 contents = fhh.read()
             linkurl = config['linkmask'] % top_msgid
             if len(am_msgs) > 1:
@@ -321,7 +325,13 @@ def make_am(msgs, cmdargs, msgid):
                 with open(fhf, 'w') as fhh:
                     fhh.write(new_contents)
 
-            mmf = os.path.join(topdir, '.git', 'b4-cover')
+            gitargs = ['rev-parse', '--git-dir']
+            ecode, fhf = b4.git_run_command(topdir, gitargs, logstderr=True)
+            if ecode > 0:
+                logger.critical('Unable to find git directory')
+                logger.critical(out.strip())
+                sys.exit(ecode)
+            mmf = os.path.join(fhf.rstrip(), 'b4-cover')
             if lser.has_cover:
                 merge_template = DEFAULT_MERGE_TEMPLATE
                 if config.get('shazam-merge-template'):
@@ -358,7 +368,7 @@ def make_am(msgs, cmdargs, msgid):
 
         logger.info('You can now merge or checkout FETCH_HEAD')
         if lser.has_cover:
-            logger.info('  e.g.: git merge -F .git/b4-cover --signoff --edit FETCH_HEAD')
+            logger.info('  e.g.: git merge -F $(git rev-parse --git-dir)/b4-cover --signoff --edit FETCH_HEAD')
         thanks_record_am(lser, cherrypick=cherrypick)
         return
 
-- 
2.32.0


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

* Re: [PATCH] Fix shazam for multiple git worktrees
  2021-10-19 14:46 [PATCH] Fix shazam for multiple git worktrees Rob Herring
@ 2021-10-19 21:33 ` Konstantin Ryabitsev
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Ryabitsev @ 2021-10-19 21:33 UTC (permalink / raw)
  To: Rob Herring; +Cc: tools

On Tue, 19 Oct 2021 09:46:00 -0500, Rob Herring wrote:
> The shazam command makes assumptions that '.git' is a directory which is
> not the case with multiple worktree. Use 'git rev-parse' instead to
> retrieve the correct paths.
> 
> 

Applied, thanks!

[1/1] Fix shazam for multiple git worktrees
      commit: a57ec40ef6d57b5aea62fbd1c814175d1da3fd23

Best regards,
-- 
Konstantin Ryabitsev <konstantin@linuxfoundation.org>

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

end of thread, other threads:[~2021-10-19 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 14:46 [PATCH] Fix shazam for multiple git worktrees Rob Herring
2021-10-19 21:33 ` Konstantin Ryabitsev

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 NNTP newsgroup(s).