chiark / gitweb /
git-debrebase: get_tree: Support '' for nonexistent objects
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 16:47:39 +0000 (17:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 16:47:39 +0000 (17:47 +0100)
This is going to be convenient in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 8fa5adb73b34f29054f4bd043551e3143f1a724a..57bfa9829ee3e1e5878d3c160756dced551cb281 100755 (executable)
@@ -187,8 +187,12 @@ sub get_tree ($) {
     # tree object name => ([ $name, $info ], ...)
     # where $name is the sort key, ie has / at end for subtrees
     # $info is the LHS from git-ls-tree (<mode> <type> <hash>)
-    # will crash if $x does not exist, so don't do that
+    # will crash if $x does not exist, so don't do that;
+    # instead pass '' to get ().
     my ($x) = @_;
+
+    return () if !length $x;
+
     our (@get_tree_memo, %get_tree_memo);
     my $memo = $get_tree_memo{$x};
     return @$memo if $memo;