All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Kirill Smelkov <kirr@mns.spb.ru>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 02/11] tree-diff: consolidate code for emitting diffs and recursion in one place
Date: Thu, 13 Feb 2014 09:43:27 -0800	[thread overview]
Message-ID: <xmqqob2alxhc.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: f0616720dfff7fedbd148e67909fe669834d8e6a.1391794688.git.kirr@mns.spb.ru

Kirill Smelkov <kirr@mns.spb.ru> writes:

> +static void show_path(struct strbuf *base, struct diff_options *opt,
> +		      struct tree_desc *t1, struct tree_desc *t2)
>  {
>  	unsigned mode;
>  	const char *path;
> -	const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
> -	int pathlen = tree_entry_len(&desc->entry);
> +	const unsigned char *sha1;
> +	int pathlen;
>  	int old_baselen = base->len;
> +	int isdir, recurse = 0, emitthis = 1;
> +
> +	/* at least something has to be valid */
> +	assert(t1 || t2);
> +
> +	if (t2) {
> +		/* path present in resulting tree */
> +		sha1 = tree_entry_extract(t2, &path, &mode);
> +		pathlen = tree_entry_len(&t2->entry);
> +		isdir = S_ISDIR(mode);
> +	}
> +	else {
> +		/* a path was removed - take path from parent. Also take
> +		 * mode from parent, to decide on recursion.
> +		 */
> +		tree_entry_extract(t1, &path, &mode);
> +		pathlen = tree_entry_len(&t1->entry);
> +
> +		isdir = S_ISDIR(mode);
> +		sha1 = NULL;
> +		mode = 0;
> +	}
> +
> +	if (DIFF_OPT_TST(opt, RECURSIVE) && isdir) {
> +		recurse = 1;
> +		emitthis = DIFF_OPT_TST(opt, TREE_IN_RECURSIVE);
> +	}
>  
>  	strbuf_add(base, path, pathlen);
> -	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
> -		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))
> -			opt->add_remove(opt, *prefix, mode, sha1, 1, base->buf, 0);
>  
> +	if (emitthis)
> +		emit_diff(opt, base, t1, t2);
> +
> +	if (recurse) {
>  		strbuf_addch(base, '/');
> -		diff_tree_sha1(*prefix == '-' ? sha1 : NULL,
> -			       *prefix == '+' ? sha1 : NULL, base->buf, opt);
> -	} else
> -		opt->add_remove(opt, prefix[0], mode, sha1, 1, base->buf, 0);
> +		diff_tree_sha1(t1 ? t1->entry.sha1 : NULL,
> +			       t2 ? t2->entry.sha1 : NULL, base->buf, opt);
> +	}


After this step, "sha1" is assigned but never gets used.  Please
double-check the fix-up I queued in the series before merging it to
'pu'.

Thanks.

  reply	other threads:[~2014-02-13 17:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 17:48 [PATCH 00/11] More preparatory work for multiparent tree-walker Kirill Smelkov
2014-02-07 17:48 ` [PATCH 01/11] tree-diff: show_tree() is not needed Kirill Smelkov
2014-02-07 17:48 ` [PATCH 02/11] tree-diff: consolidate code for emitting diffs and recursion in one place Kirill Smelkov
2014-02-13 17:43   ` Junio C Hamano [this message]
2014-02-13 17:52     ` Kirill Smelkov
2014-02-07 17:48 ` [PATCH 03/11] tree-diff: don't assume compare_tree_entry() returns -1,0,1 Kirill Smelkov
2014-02-07 17:48 ` [PATCH 04/11] tree-diff: move all action-taking code out of compare_tree_entry() Kirill Smelkov
2014-02-07 17:48 ` [PATCH 05/11] tree-diff: rename compare_tree_entry -> tree_entry_pathcmp Kirill Smelkov
2014-02-07 17:48 ` [PATCH 06/11] tree-diff: show_path prototype is not needed anymore Kirill Smelkov
2014-02-07 17:48 ` [PATCH 07/11] tree-diff: simplify tree_entry_pathcmp Kirill Smelkov
2014-02-07 17:48 ` [PATCH 08/11] tree-diff: remove special-case diff-emitting code for empty-tree cases Kirill Smelkov
2014-02-07 17:48 ` [PATCH 09/11] tree-diff: rework diff_tree interface to be sha1 based Kirill Smelkov
2014-02-07 17:48 ` [PATCH 10/11] tree-diff: no need to call "full" diff_tree_sha1 from show_path() Kirill Smelkov
2014-02-07 17:48 ` [PATCH 11/11] tree-diff: reuse base str(buf) memory on sub-tree recursion Kirill Smelkov
2014-02-13 13:25   ` Kirill Smelkov
2014-02-11  0:28 ` [PATCH 00/11] More preparatory work for multiparent tree-walker Junio C Hamano
2014-02-11  8:17   ` Kirill Smelkov
2014-02-11 19:59     ` Junio C Hamano
2014-02-12  9:30       ` Kirill Smelkov
2014-02-12 17:25       ` Junio C Hamano
2014-02-13 14:05         ` Kirill Smelkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqob2alxhc.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kirr@mns.spb.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.