]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/convert-grafts-to-replace-refs.sh
Sync with 2.16.6
[thirdparty/git.git] / contrib / convert-grafts-to-replace-refs.sh
CommitLineData
b0ab2b71
CC
1#!/bin/sh
2
3# You should execute this script in the repository where you
4# want to convert grafts to replace refs.
5
6GRAFTS_FILE="${GIT_DIR:-.git}/info/grafts"
7
8. $(git --exec-path)/git-sh-setup
9
10test -f "$GRAFTS_FILE" || die "Could not find graft file: '$GRAFTS_FILE'"
11
12grep '^[^# ]' "$GRAFTS_FILE" |
13while read definition
14do
15 if test -n "$definition"
16 then
17 echo "Converting: $definition"
18 git replace --graft $definition ||
19 die "Conversion failed for: $definition"
20 fi
21done
22
23mv "$GRAFTS_FILE" "$GRAFTS_FILE.bak" ||
24 die "Could not rename '$GRAFTS_FILE' to '$GRAFTS_FILE.bak'"
25
26echo "Success!"
27echo "All the grafts in '$GRAFTS_FILE' have been converted to replace refs!"
28echo "The grafts file '$GRAFTS_FILE' has been renamed: '$GRAFTS_FILE.bak'"