Re: Handling merge conflicts a bit more gracefully..
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:59
quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
quoted
# Modified in both, but differently. + merge -p "$src1" "$orig" "$src2" > "$4" Again, make sure "$4" is not a directory before redirecting into it from merge, so that you can tell merge failures from it?
LT> Hmm.. What's the cleanest way to check for redirection errors, but still
LT> be able to distinguish those cleanly from "merge" itself returning an
LT> error?
I do not think you can, unless you are willing to parse shell
error messages, which I do not want you to be willing to ;-).
: siamese; ls -dlF junk j.py
---------- 1 junio junio 845 May 7 2004 j.py
drwxrwxr-x 2 junio junio 4096 May 4 22:31 junk/
: siamese; echo foo >j.py ; echo $?
bash: j.py: Permission denied
1
: siamese; echo foo >junk ; echo $?
bash: junk: Is a directory
1
I think you have a bigger problem of leading paths, BTW.
Since we would want to have the merge result file at that path,
and not being able to create such is an error, how about doing
dumb and simple, like:
d=`dirname "$4"` &&
mkdir -p "$d" &&
rm -f -- "$4" &&
: >"$4" || {
echo "barf"
exit 1
}
merge -p "$src1" "$orig" "$src2" >"$4"
ret=$?