[PATCH 2/3] Allow for creating patch series

John Keeping john at keeping.me.uk
Thu Aug 15 23:04:41 CEST 2013


On Thu, Aug 15, 2013 at 07:06:35PM +0200, Lukas Fleischer wrote:
> This allows for specifying a revision range using the id2 parameter of
> /patch/. The output that is produced is similar to
> 
>     $ git format-patch --stdout id2..id
> 
> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> ---
>  cmd.c      | 2 +-
>  ui-patch.c | 6 ++++--
>  ui-patch.h | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/cmd.c b/cmd.c
> index 9893710..0202917 100644
> --- a/cmd.c
> +++ b/cmd.c
> @@ -98,7 +98,7 @@ static void repolist_fn(struct cgit_context *ctx)
>  
>  static void patch_fn(struct cgit_context *ctx)
>  {
> -	cgit_print_patch(ctx->qry.sha1, ctx->qry.path);
> +	cgit_print_patch(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
>  }
>  
>  static void plain_fn(struct cgit_context *ctx)
> diff --git a/ui-patch.c b/ui-patch.c
> index 429b74c..a93ba45 100644
> --- a/ui-patch.c
> +++ b/ui-patch.c
> @@ -11,7 +11,7 @@
>  #include "html.h"
>  #include "ui-shared.h"
>  
> -void cgit_print_patch(char *hex, const char *prefix)
> +void cgit_print_patch(char *hex, const char *old_rev, const char *prefix)
>  {
>  	struct rev_info rev;
>  	struct commit *commit;
> @@ -33,7 +33,9 @@ void cgit_print_patch(char *hex, const char *prefix)
>  		return;
>  	}
>  
> -	if (commit->parents && commit->parents->item)
> +	if (old_rev)
> +		get_sha1(old_rev, old_sha1);

Should we check the return value of get_sha1() here?  A few lines above
we print an error message if 'hex' isn't found.

> +	else if (commit->parents && commit->parents->item)
>  		hashcpy(old_sha1, commit->parents->item->object.sha1);
>  	else
>  		hashclr(old_sha1);
> diff --git a/ui-patch.h b/ui-patch.h
> index 1641cea..acd37fd 100644
> --- a/ui-patch.h
> +++ b/ui-patch.h
> @@ -1,6 +1,6 @@
>  #ifndef UI_PATCH_H
>  #define UI_PATCH_H
>  
> -extern void cgit_print_patch(char *hex, const char *prefix);
> +extern void cgit_print_patch(char *hex, const char *old_rev, const char *prefix);
>  
>  #endif /* UI_PATCH_H */
> -- 
> 1.8.4.rc2.477.g1da3ebd


More information about the CGit mailing list