summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Linus Torvalds <torvalds@ppc970.osdl.org>2005-06-08 17:36:47 -0700
committerLibravatar Linus Torvalds <torvalds@ppc970.osdl.org>2005-06-08 17:36:47 -0700
commite0226add28e53a35ce91cdbebb1919519f02b291 (patch)
tree162a7930fe8651b77fb544afba4a3a636aa8a55e
parentMerge my and Petr's git-merge-one-file-script modifications (diff)
downloadtgif-e0226add28e53a35ce91cdbebb1919519f02b291.tar.xz
Fix up git-merge-one-file-script
Junio points out that we may need to create the path leading up the the file we merge. And we need to be more careful with the "exec"s we've done to exit on success - only do the on the last command in the pipeline, not the first one ;)
-rwxr-xr-xgit-merge-one-file-script25
1 files changed, 18 insertions, 7 deletions
diff --git a/git-merge-one-file-script b/git-merge-one-file-script
index f0353c14b4..004c2bd446 100755
--- a/git-merge-one-file-script
+++ b/git-merge-one-file-script
@@ -16,6 +16,14 @@
# been handled already by git-read-tree, but that one doesn't
# do any merges that might change the tree layout.
+verify_path() {
+ file="$1"
+ dir=`dirname "$file"` &&
+ mkdir -p "$dir" &&
+ rm -f -- "$file" &&
+ : >"$file"
+}
+
case "${1:-.}${2:-.}${3:-.}" in
#
# Deleted in both.
@@ -32,8 +40,8 @@ case "${1:-.}${2:-.}${3:-.}" in
#
"$1.$1" | "$1$1.")
echo "Removing $4"
- exec rm -f -- "$4" &&
- git-update-cache --remove -- "$4"
+ rm -f -- "$4" &&
+ exec git-update-cache --remove -- "$4"
;;
#
@@ -42,9 +50,10 @@ case "${1:-.}${2:-.}${3:-.}" in
".$2." | "..$3" )
case "$6$7" in *7??) mode=+x;; *) mode=-x;; esac
echo "Adding $4 with perm $mode."
- exec git-cat-file blob "$2$3" >"$4" &&
+ verify_path "$4" &&
+ git-cat-file blob "$2$3" >"$4" &&
chmod $mode -- "$4" &&
- git-update-cache --add -- "$4"
+ exec git-update-cache --add -- "$4"
;;
#
@@ -58,9 +67,10 @@ case "${1:-.}${2:-.}${3:-.}" in
fi
case "$6" in *7??) mode=+x;; *) mode=-x;; esac
echo "Adding $4 with perm $mode"
- exec git-cat-file blob "$2" >"$4" &&
+ verify_path "$4" &&
+ git-cat-file blob "$2" >"$4" &&
chmod $mode -- "$4" &&
- git-update-cache --add -- "$4"
+ exec git-update-cache --add -- "$4"
;;
#
@@ -72,7 +82,8 @@ case "${1:-.}${2:-.}${3:-.}" in
src1=`git-unpack-file $2`
src2=`git-unpack-file $3`
- merge -p "$src1" "$orig" "$src2" > "$4"
+ verify_path "$4" &&
+ merge -p "$src1" "$orig" "$src2" > "$4"
ret=$?
rm -f -- "$orig" "$src1" "$src2"