gitweb: check given hash before trying to create snapshot
Makes things nicer in cases when you hand craft the snapshot URL but make a typo in defining the hash variable (e.g. netx instead of next); you will now get an error message instead of a broken tarball. Tests for t9501 are included to demonstrate added functionality. Signed-off-by: Mark Rada <marada@uwaterloo.ca> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
committed by
Shawn O. Pearce
parent
1be224ba6e
commit
fdb0c36e90
@ -5196,8 +5196,11 @@ sub git_snapshot {
|
||||
die_error(403, "Unsupported snapshot format");
|
||||
}
|
||||
|
||||
if (!defined $hash) {
|
||||
$hash = git_get_head_hash($project);
|
||||
my $type = git_get_type("$hash^{}");
|
||||
if (!$type) {
|
||||
die_error(404, 'Object does not exist');
|
||||
} elsif ($type eq 'blob') {
|
||||
die_error(400, 'Object is not a tree-ish');
|
||||
}
|
||||
|
||||
my $name = $project;
|
||||
|
||||
Reference in New Issue
Block a user