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

Re: [RFC] new subcommand: git sync

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 26, 2021, 15:25 UTC
Message-ID
<87tupy7sx6.fsf@evledraar.gmail.com>
In-Reply-To
<CAAdc0hwmR7BF53_66LNaceLrkFPDphU-y2sLEGB_1YoR5ErQsg@mail.gmail.com>
On Fri, Feb 26 2021, Jean-Marie Lemetayer wrote:
Show 18 quoted lines
> Hi folks,
>
> I created a new "git sync" sub-command a few months ago to deal with the pull
> request workflow.
>
> Its goals are to:
>  - keep all configured branches synchronized with the remotes (--set-upstream)
>  - do not touch your wip feature branches (which has diverged from upstream)
>  - prune the remotes
>
> As I use it on a daily basis, to synchronize the remotes and then be able to
> quickly rebase my pull requests. I think it's worth sharing. What do you think?
>
> For now it is a simple shell script available here:
> https://github.com/jmlemetayer/one-time-setup/blob/main/git-sync
>
> If you think it's a good idea, I'll propose a series of patches with the new
> sub-command, the manual page and the associated tests.

Have you seen 'git branch -v' and 'git branch -v --format=*'? There seems to be a high amount of overlap between this wrapper you've written and it.

I suspect most of what you have here could be turned into an %(if:*) directive where you emit the pull/push command as appropriate.

If you search the internet for "git-sync" there's dozens of such command (and I've personally observed at least two of them being written by co-workers in real time, not sure if either of those is in the Google results).

So I think there's probably a worthwhile problem to be solved here that could be turned into patches to git.git, something between "git [clone|push] --mirror" and "git branch -v".

I don't think there's any interest in getting new shellscript built-ins in the future. We've been actively migrating away from those.

But most of the logic in your script is just calling the ref-filter.c API behind the scenes.

B.t.w. you can probably speed up & simplify your script a lot by making use of IFS="" in the shell and not calling N for-each-ref commands when it seems to me that one invocation would do. Just dump the N fields you need split on some token, and split on that token in your loop.

Previous: Jean-Marie LemetayerNext: Randall S. Becker
Message 2 of 7 in “[RFC] new subcommand: git sync”
  1. Jean-Marie LemetayerFeb 26, 2021
  2. Ævar Arnfjörð BjarmasonFeb 26, 2021
  3. Randall S. BeckerFeb 26, 2021
  4. Jean-Marie LemetayerMar 1, 2021
  5. Randall S. BeckerMar 1, 2021
  6. Junio C HamanoFeb 26, 2021
  7. Junio C HamanoFeb 26, 2021

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.