~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-security

« back to all changes in this revision

Viewing changes to git-merge-one-file.sh

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-10-04 08:27:01 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20071004082701-rsd058ontoqz4i30
Tags: 1:1.5.3.4-1
new upstream point release (closes: #445188).

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#   $7 - file in branch2 mode (or empty)
14
14
#
15
15
# Handle some trivial cases.. The _really_ trivial cases have
16
 
# been handled already by git-read-tree, but that one doesn't
 
16
# been handled already by git read-tree, but that one doesn't
17
17
# do any merges that might change the tree layout.
18
18
 
19
19
case "${1:-.}${2:-.}${3:-.}" in
27
27
                # read-tree checked that index matches HEAD already,
28
28
                # so we know we do not have this path tracked.
29
29
                # there may be an unrelated working tree file here,
30
 
                # which we should just leave unmolested.
31
 
                exit 0
 
30
                # which we should just leave unmolested.  Make sure
 
31
                # we do not have it in the index, though.
 
32
                exec git update-index --remove -- "$4"
32
33
        fi
33
34
        if test -f "$4"; then
34
35
                rm -f -- "$4" &&
35
36
                rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || :
36
37
        fi &&
37
 
                exec git-update-index --remove -- "$4"
 
38
                exec git update-index --remove -- "$4"
38
39
        ;;
39
40
 
40
41
#
42
43
#
43
44
".$2.")
44
45
        # the other side did not add and we added so there is nothing
45
 
        # to be done.
 
46
        # to be done, except making the path merged.
 
47
        exec git update-index --add --cacheinfo "$6" "$2" "$4"
46
48
        ;;
47
49
"..$3")
48
50
        echo "Adding $4"
50
52
                echo "ERROR: untracked $4 is overwritten by the merge."
51
53
                exit 1
52
54
        }
53
 
        git-update-index --add --cacheinfo "$6$7" "$2$3" "$4" &&
54
 
                exec git-checkout-index -u -f -- "$4"
 
55
        git update-index --add --cacheinfo "$7" "$3" "$4" &&
 
56
                exec git checkout-index -u -f -- "$4"
55
57
        ;;
56
58
 
57
59
#
64
66
                exit 1
65
67
        fi
66
68
        echo "Adding $4"
67
 
        git-update-index --add --cacheinfo "$6" "$2" "$4" &&
68
 
                exec git-checkout-index -u -f -- "$4"
 
69
        git update-index --add --cacheinfo "$6" "$2" "$4" &&
 
70
                exec git checkout-index -u -f -- "$4"
69
71
        ;;
70
72
 
71
73
#
84
86
        case "$1" in
85
87
        '')
86
88
                echo "Added $4 in both, but differently."
87
 
                # This extracts OUR file in $orig, and uses git-apply to
 
89
                # This extracts OUR file in $orig, and uses git apply to
88
90
                # remove lines that are unique to ours.
89
91
                orig=`git-unpack-file $2`
90
92
                sz0=`wc -c <"$orig"`
91
 
                diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add 
 
93
                diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
92
94
                sz1=`wc -c <"$orig"`
93
95
 
94
96
                # If we do not have enough common material, it is not
104
106
        # Be careful for funny filename such as "-L" in "$4", which
105
107
        # would confuse "merge" greatly.
106
108
        src1=`git-unpack-file $2`
107
 
        git-merge-file "$src1" "$orig" "$src2"
 
109
        git merge-file "$src1" "$orig" "$src2"
108
110
        ret=$?
109
111
 
110
112
        # Create the working tree file, using "our tree" version from the
111
113
        # index, and then store the result of the merge.
112
 
        git-checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
 
114
        git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
113
115
        rm -f -- "$orig" "$src1" "$src2"
114
116
 
115
117
        if [ "$6" != "$7" ]; then
124
126
                echo "ERROR: Merge conflict in $4"
125
127
                exit 1
126
128
        fi
127
 
        exec git-update-index -- "$4"
 
129
        exec git update-index -- "$4"
128
130
        ;;
129
131
 
130
132
*)