git-merge-octopus.shon commit i18n: rebase: fix marked string to use eval_gettext variant (24a6df4)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5# Resolve two or more trees.
   6#
   7
   8. git-sh-setup
   9. git-sh-i18n
  10
  11LF='
  12'
  13
  14# The first parameters up to -- are merge bases; the rest are heads.
  15bases= head= remotes= sep_seen=
  16for arg
  17do
  18        case ",$sep_seen,$head,$arg," in
  19        *,--,)
  20                sep_seen=yes
  21                ;;
  22        ,yes,,*)
  23                head=$arg
  24                ;;
  25        ,yes,*)
  26                remotes="$remotes$arg "
  27                ;;
  28        *)
  29                bases="$bases$arg "
  30                ;;
  31        esac
  32done
  33
  34# Reject if this is not an Octopus -- resolve should be used instead.
  35case "$remotes" in
  36?*' '?*)
  37        ;;
  38*)
  39        exit 2 ;;
  40esac
  41
  42# MRC is the current "merge reference commit"
  43# MRT is the current "merge result tree"
  44
  45if ! git diff-index --quiet --cached HEAD --
  46then
  47    gettextln "Error: Your local changes to the following files would be overwritten by merge"
  48    git diff-index --cached --name-only HEAD -- | sed -e 's/^/    /'
  49    exit 2
  50fi
  51MRC=$(git rev-parse --verify -q $head)
  52MRT=$(git write-tree)
  53NON_FF_MERGE=0
  54OCTOPUS_FAILURE=0
  55for SHA1 in $remotes
  56do
  57        case "$OCTOPUS_FAILURE" in
  58        1)
  59                # We allow only last one to have a hand-resolvable
  60                # conflicts.  Last round failed and we still had
  61                # a head to merge.
  62                gettextln "Automated merge did not work."
  63                gettextln "Should not be doing an Octopus."
  64                exit 2
  65        esac
  66
  67        eval pretty_name=\${GITHEAD_$SHA1:-$SHA1}
  68        if test "$SHA1" = "$pretty_name"
  69        then
  70                SHA1_UP="$(echo "$SHA1" | tr a-z A-Z)"
  71                eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name}
  72        fi
  73        common=$(git merge-base --all $SHA1 $MRC) ||
  74                die "$(eval_gettext "Unable to find common commit with \$pretty_name")"
  75
  76        case "$LF$common$LF" in
  77        *"$LF$SHA1$LF"*)
  78                eval_gettextln "Already up-to-date with \$pretty_name"
  79                continue
  80                ;;
  81        esac
  82
  83        if test "$common,$NON_FF_MERGE" = "$MRC,0"
  84        then
  85                # The first head being merged was a fast-forward.
  86                # Advance MRC to the head being merged, and use that
  87                # tree as the intermediate result of the merge.
  88                # We still need to count this as part of the parent set.
  89
  90                eval_gettextln "Fast-forwarding to: \$pretty_name"
  91                git read-tree -u -m $head $SHA1 || exit
  92                MRC=$SHA1 MRT=$(git write-tree)
  93                continue
  94        fi
  95
  96        NON_FF_MERGE=1
  97
  98        eval_gettextln "Trying simple merge with \$pretty_name"
  99        git read-tree -u -m --aggressive  $common $MRT $SHA1 || exit 2
 100        next=$(git write-tree 2>/dev/null)
 101        if test $? -ne 0
 102        then
 103                gettextln "Simple merge did not work, trying automatic merge."
 104                git-merge-index -o git-merge-one-file -a ||
 105                OCTOPUS_FAILURE=1
 106                next=$(git write-tree 2>/dev/null)
 107        fi
 108
 109        MRC="$MRC $SHA1"
 110        MRT=$next
 111done
 112
 113exit "$OCTOPUS_FAILURE"