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

2 messages from 2006-04-29 to 2006-04-29. Participants: colin@horizon.com, Junio C Hamano.
Thread: https://gitlist.dev/t/3997

## colin@horizon.com, 2006-04-29 13:23

Subject: Re: fatal: git-write-tree: not able to write tree
Message-ID: <20060429132324.31638.qmail@science.horizon.com>
URL: https://gitlist.dev/e/20060429132324.31638.qmail%40science.horizon.com

```
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

Er... it's very non-obvious to me why you'd want to stick a workaround
here when you could instead fix git-write-tree to do it.  That seems
like The Right Thing.
(It would also be helpful to mention at least one unmerged file by name.)

```

## Junio C Hamano, 2006-04-29 18:34

Subject: Re: fatal: git-write-tree: not able to write tree
Message-ID: <7v1wvg8c3x.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v1wvg8c3x.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060429132324.31638.qmail@science.horizon.com>

```
colin@horizon.com writes:

> 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
>
> Er... it's very non-obvious to me why you'd want to stick a workaround
> here when you could instead fix git-write-tree to do it.  That seems
> like The Right Thing.

As I said in an earlier message in the thread, I've considered
it, but that is a very risky thing to do, and write-tree is
definitely a wrong place to do it.  If we wanted to, the right
way would be to update-index using the output of "ls-files -u".

However, it would invite the user to mistakenly say --resolved
before resolving all paths.

> (It would also be helpful to mention at least one unmerged file by name.)

That is true.

```
