Re: [PATCH v3] contrib git-resurrect: find traces of a branch name and resurrect it
Thomas Rast <trast@student.ethz.ch> writes:
Show 18 quoted lines
>> Reading everything down to the root commit sounds like fun. rev-list
>> gives you the output from newer to older so you may want to break out once
>> you have found enough candidates.
>>
>> Anyway, if I were doing this script, I'd write this part like this without
>> a shell loop:
>>
>> _x40="[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"
>> _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
>>
>> git rev-list --all --grep="Merge branch '$1'" \
>> --pretty=tformat:"%H %P %s" |
>> sed -ne "s/^$_x40 $_x40 \($_x40\) Merge .*/\1/p"
>
> Nice trick. The same also works for scan_merge_targets() and gives it
> a nice speed boost too. Unfortunately my sed-fu is not good enough to
> figure out how to only print the first line (for resurrections from
> pu, we expect there to be a single match).
Do you mean something like this?
sed -n -e "/^$_x40 $_x40 \($_x40\) Merge .*/ {
s//\1/p
q
}"