add--interactive: compute the empty tree value

The interactive add script hard-codes the object ID of the empty tree. To avoid any problems when changing hashes, compute this value when used and cache it for any future uses. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 2, 2018 at 00:26 UTC 23ec4c51d53f6976bdb54e92487d378f9abd1ed3
1 file changed +9 -2
git-add--interactive.perl
+9 -2
@@ -205,8 +205,15 @@ my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'))
205 }
206 }
207
208 -sub get_empty_tree {
209 - return '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
208 +{
209 + my $empty_tree;
210 + sub get_empty_tree {
211 + return $empty_tree if defined $empty_tree;
212 +
213 + $empty_tree = run_cmd_pipe(qw(git hash-object -t tree /dev/null));
214 + chomp $empty_tree;
215 + return $empty_tree;
216 + }
217 }
218
219 sub get_diff_reference {