Re: Handling merge conflicts a bit more gracefully..

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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=$?

Re: Handling merge conflicts a bit more gracefully..

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:41:59


On Wed, 8 Jun 2005, Junio C Hamano wrote:
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 ;-).
Yeah, no. 
I think you have a bigger problem of leading paths, BTW.
Gotcha. I committed a largely untested fix that hopefully does this all 
right.

I'm currently using your suggested thing (inside a function), but I think 
I'll instead make it do

	git-update-cache --add --cacheinfo ... &&
		git-checkout-cache -u -f "$4"

which seems even simpler.

		Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help