Re: Handling merge conflicts a bit more gracefully..
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jun 9, 2005, 00:03 UTC
- Message-ID
- <7vzmu01jmc.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.58.0506081629370.2286@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
Show 5 quoted lines
>> # 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
1I 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=$?