[PATCH] scripts: add helper for generating Origin-URL references

Sascha Hauer s.hauer at pengutronix.de
Thu Dec 18 00:04:29 PST 2025


On Wed, Dec 17, 2025 at 11:59:43AM +0100, Jonas Rebmann wrote:
> > +# Optional second argument to allow e.g. !git origin-url $remote_file % im vim
> > +# In cases where local file has different extension then the original
> > +dstbasename="$(basename ${2:-$1})"
> > +
> > +[ -e "$1" ] || err "File not found"
> > +
> > +filepath="$(realpath "$1")"
> > +
> > +repo_root="$(git -C "$(dirname "$filepath")" rev-parse --show-toplevel 2>/dev/null \
> > +    || err "Not inside a Git repository: $filepath")"
> > +
> > +rel_path="$(realpath --relative-to="$repo_root" "$filepath")"
> > +
> > +# newest commit that touched this file
> > +file_commit="$(git -C "$repo_root" log -n1 --format=%H -- "$rel_path")"
> 
> So the idea is that the Origin-URL is generated for the commit to which
> <path-to-file> is checked out at the time? Maybe you could state that
> more clearly e.g. in the top of the script or in the usage message.
> 
> We don't want people to add Origin-URLs referencing just any commit.

Ah, should have read that before writing a mail ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list