blob: a57b78a41d345a164368a8fa3803115ae0a8e73c [file] [log] [blame]
Sumit Gargde31e602024-02-22 15:06:02 +05301#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Copyright 2024 Linaro Ltd.
5#
6# Usage: from the top level U-Boot source tree, run:
7# $ ./dts/update-dts-subtree.sh pull <release-tag>
8# $ ./dts/update-dts-subtree.sh pick <commit-id>
9#
10# The script will pull changes from devicetree-rebasing repo into U-Boot
11# as a subtree located as <U-Boot>/dts/upstream sub-directory. It will
12# automatically create a squash/merge commit listing the commits imported.
13
14set -e
15
16merge_commit_msg=$(cat << EOF
17Subtree merge tag '$2' of devicetree-rebasing repo [1] into dts/upstream
18
19[1] https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git/
20EOF
21)
22
23remote_add_and_fetch() {
24 if ! git remote get-url devicetree-rebasing 2>/dev/null
25 then
26 echo "Warning: Script automatically adds new git remote via:"
27 echo " git remote add devicetree-rebasing \\"
28 echo " https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git"
29 git remote add devicetree-rebasing \
30 https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git
31 fi
32 git fetch devicetree-rebasing master
33}
34
35if [ "$1" = "pull" ]
36then
37 remote_add_and_fetch
38 git subtree pull --prefix dts/upstream devicetree-rebasing \
39 "$2" --squash -m "${merge_commit_msg}"
40elif [ "$1" = "pick" ]
41then
42 remote_add_and_fetch
43 git cherry-pick -x --strategy=subtree -Xsubtree=dts/upstream/ "$2"
44else
45 echo "usage: $0 <op> <ref>"
46 echo " <op> pull or pick"
47 echo " <ref> release tag [pull] or commit id [pick]"
48fi