Skip to content

Commit 23ec4c5

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 03a7f38 commit 23ec4c5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

git-add--interactive.perl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ sub list_untracked {
205205
}
206206
}
207207

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+
}
210217
}
211218

212219
sub get_diff_reference {

0 commit comments

Comments
 (0)