Thread (1 message) 1 message, 1 author, 2021-02-26

Re: [RFC] new subcommand: git sync

From: Junio C Hamano <hidden>
Date: 2021-02-26 22:32:24

Ævar Arnfjörð Bjarmason [off-list ref] writes:
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.
A hidden gem in for-each-ref is its ability to quote the placeholder
values in a language specific way, and that is to allow the --format
to generate a script that can be eval'ed.  E.g.

  $ git for-each-ref --shell \
    --format='doit %(authorname) %(subject)' refs/heads/ab/\* |
    head -n 3
  doit 'Ævar Arnfjörð Bjarmason' 'branch: show "HEAD detached" first ...'
  doit 'Ævar Arnfjörð Bjarmason' 'CoC: update to version 2.0 + local ...'
  doit 'Ævar Arnfjörð Bjarmason' 'config.mak.uname: remove unused NEE...'

so that you can prepare

	doit () {
		person=$1 subject=$2
		... do things on the branch data ...
	}

beforehand and then eval the output from the script you wrote with
"git for-each-ref".

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help