From: brian m. carlson Date: Wed, 2 May 2018 00:26:09 +0000 (+0000) Subject: add--interactive: compute the empty tree value X-Git-Tag: v2.18.0-rc0~17^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/23ec4c51d53f6976bdb54e92487d378f9abd1ed3?ds=inline;hp=--cc 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 Signed-off-by: Junio C Hamano --- 23ec4c51d53f6976bdb54e92487d378f9abd1ed3 diff --git a/git-add--interactive.perl b/git-add--interactive.perl index c1f52e457f..36f38ced90 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -205,8 +205,15 @@ sub list_untracked { } } -sub get_empty_tree { - return '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; +{ + my $empty_tree; + sub get_empty_tree { + return $empty_tree if defined $empty_tree; + + $empty_tree = run_cmd_pipe(qw(git hash-object -t tree /dev/null)); + chomp $empty_tree; + return $empty_tree; + } } sub get_diff_reference {