# RE: fatal: git-write-tree: not able to write tree

2 messages from 2006-04-28 to 2006-04-28. Participants: Brown, Len, Junio C Hamano.
Thread: https://gitlist.dev/t/3983

## Brown, Len, 2006-04-28 08:43

Subject: RE: fatal: git-write-tree: not able to write tree
Message-ID: <CFF307C98FEABE47A452B27C06B85BB64A432C@hdsmsx411.amr.corp.intel.com>
URL: https://gitlist.dev/e/CFF307C98FEABE47A452B27C06B85BB64A432C%40hdsmsx411.amr.corp.intel.com

```
 
>> git am --3way --interactive --signoff --utf8 --resolved

>Please say "--resolved" after you have actually resolved them,
>eh, meaning, (1) edit the working tree file into a desired
>shape, and (2) git-update-index drivers/acpi/thermal.c.

Thanks Junio, once again, for your help, we're up and running!

I'm okay with git being conservative and not doing the update-index
for me.  Perhaps the thing to do here is to make the failure message
more useful?

"fatal: git-write-tree: not able to write tree"

everything after "fatal" here is effectively a string
of random characters to the hapless user.

thanks,
-Len

```

## Junio C Hamano, 2006-04-28 09:01

Subject: Re: fatal: git-write-tree: not able to write tree
Message-ID: <7v7j5adqf0.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v7j5adqf0.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <CFF307C98FEABE47A452B27C06B85BB64A432C@hdsmsx411.amr.corp.intel.com>

```
"Brown, Len" <len.brown@intel.com> writes about the command "git
am -3 --resolved", after hand merging _but_ without update-index
to actually mark the paths that have been resolved, results in
"write-tree" failure.

> I'm okay with git being conservative and not doing the update-index
> for me.  Perhaps the thing to do here is to make the failure message
> more useful?
>
> "fatal: git-write-tree: not able to write tree"
>
> everything after "fatal" here is effectively a string
> of random characters to the hapless user.

That's very true.  Perhaps something like this?

-- >8 --
git-am --resolved: more usable error message.

After doing the hard work of hand resolving the conflicts in the
working tree, if the user forgets to run update-index to mark
the paths that have been resolved, the command gave an
unfriendly "fatal: git-write-tree: not able to write tree" error
message.  Catch the situation early and give more meaningful
message and suggestion.

Noticed and suggested by Len Brown.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-am.sh b/git-am.sh
index eab4aa8..872145b 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -376,6 +376,13 @@ do
 			echo "No changes - did you forget update-index?"
 			stop_here $this
 		fi
+		unmerged=$(git-ls-files -u)
+		if test -n "$unmerged"
+		then
+			echo "You still have unmerged paths in your index"
+			echo "did you forget update-index?"
+			stop_here $this
+		fi
 		apply_status=0
 		;;
 	esac

```
