Re: [PATCH v6 07/13] notes: implement 'git notes copy --stdin'

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

 



On Wednesday 10 March 2010, Thomas Rast wrote:
> This implements a mass-copy command that takes a sequence of lines in
> the format
> 
>   <from-sha1> SP <to-sha1> [ SP <rest> ] LF
> 
> on stdin, and copies each <from-sha1>'s notes to the <to-sha1>.  The
> <rest> is ignored.  The intent, of course, is that this can read the
> same input that the 'post-rewrite' hook gets.
> 
> The copy_note() function is exposed for everyone's and in particular
> the next commit's use.
> 
> Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>

Acked-by: Johan Herland <johan@xxxxxxxxxxx>

> ---
> 
> Changes since v5
> * don't remove note we know doesn't exist

[...]

> diff --git a/notes.c b/notes.c
> index 0d4b892..b1b15e9 100644
> --- a/notes.c
> +++ b/notes.c
> @@ -1189,3 +1189,22 @@ void format_display_notes(const unsigned char
> *object_sha1, format_note(display_notes_trees[i], object_sha1, sb,
>  			    output_encoding, flags);
>  }
> +
> +int copy_note(struct notes_tree *t,
> +	      const unsigned char *from_obj, const unsigned char *to_obj,
> +	      int force, combine_notes_fn combine_fn)
> +{
> +	const unsigned char *note = get_note(t, from_obj);
> +	const unsigned char *existing_note = get_note(t, to_obj);
> +
> +	if (!force && existing_note)
> +		return 1;
> +
> +	if (note)
> +		add_note(t, to_obj, note, combine_fn);
> +	else if (existing_note) {
> +		add_note(t, to_obj, null_sha1, combine_fn);
> +	}

You might want to lose the braces around the second add_note().


...Johan

-- 
Johan Herland, <johan@xxxxxxxxxxx>
www.herland.net
--
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]