import pathlib,subprocess,json,sys
root=pathlib.Path(sys.argv[1])
def git(p,*args):return subprocess.check_output(['git','-C',str(p),*args],text=True).strip()
for name in ['a','b']:
 p=root/name
 print(name,'parent='+git(p,'branch','--show-current'),'default='+git(p,'symbolic-ref','--short','refs/remotes/origin/HEAD'))
 for line in git(p,'worktree','list','--porcelain').splitlines():
  if line.startswith('worktree ') and line[9:] != str(p):
   child=pathlib.Path(line[9:]);print(' child',name,git(child,'log','-1','--format=%h %s'))
   print(' created:',git(child,'reflog','show','--format=%gs',git(child,'branch','--show-current')).splitlines()[-1])
