File: master_revert.sh

package info (click to toggle)
cppad 2026.00.00.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,588 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (32 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /bin/bash -e
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------
if [ "$0" != 'bin/master_revert.sh' ]
then
   echo "bin/master_revert.sh: must be executed from its parent directory"
   exit 1
fi
# -----------------------------------------------------------------------------
branch=$(git branch | sed -n '/^[*]/p' | sed -e 's/[*] *//')
list=$(
   git diff master $branch | \
   sed -n -e '/^diff --git/p' | \
   sed -e 's|^diff --git a/||' -e 's| b/|@|'
)
for pair in $list
do
   master_file=$(echo $pair | sed -e 's|@.*||')
   branch_file=$(echo $pair | sed -e 's|[^@]*@||')
   if [ "$master_file" == "$branch_file" ]
   then
      echo "reverting $master_file"
      git show master:$master_file > $branch_file
   else
      echo 'skipping move of'
      echo "$master_file -> $branch_file"
   fi
done
echo 'master_revert.sh: OK'
exit 0