Re: [RFC/PATCH v4 1/2] gitweb: check given hash before trying to create snapshot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Rada <marada@xxxxxxxxxxxx> writes:

> 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.
>
> To maintain backwards compatibility, git_get_head_hash is now a wrapper
> for git_get_full_hash, as suggested by Jakub Narebski.
>
> Tests for t9501 are included to demonstrate added functionality.
>
> Signed-off-by: Mark Rada <marada@xxxxxxxxxxxx>
> ---
>
> 	This is just a re-send based on getting torn a new one by Junio.
> 	Changes since v3:
> 		- variables have been renamed for readability

Much nicer to read.  Thanks.

> @@ -5196,8 +5202,9 @@ sub git_snapshot {
>  		die_error(403, "Unsupported snapshot format");
>  	}
>  
> -	if (!defined $hash) {
> -		$hash = git_get_head_hash($project);
> +	my $full_hash = git_get_full_hash($project, $hash);
> +	if (!$full_hash) {
> +		die_error(404, 'Hash id was not valid');
>  	}

This is in the context of "snapshot", so obviously you care more about
just "such an object exists", don't you?  You also want it to be a
tree-ish.  Try giving it $hash = 'junio-gpg-pub' and see how it breaks.

> @@ -5210,7 +5217,7 @@ sub git_snapshot {
>  	$cmd = quote_command(
>  		git_cmd(), 'archive',
>  		"--format=$known_snapshot_formats{$format}{'format'}",
> -		"--prefix=$name/", $hash);
> +		"--prefix=$name/", $full_hash);

Why?  There was no justification as to why this change is necessary in the
commit log message.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]