All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <stefanbeller@gmail.com>
Cc: Johannes.Schindelin@gmx.de, barkalow@iabervon.org, git@vger.kernel.org
Subject: Re: [PATCH] unpack-tree.c: remove dead code
Date: Tue, 12 Aug 2014 15:24:42 -0700	[thread overview]
Message-ID: <xmqqmwb94a8l.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1407878107-22850-1-git-send-email-stefanbeller@gmail.com> (Stefan Beller's message of "Tue, 12 Aug 2014 23:15:07 +0200")

Stefan Beller <stefanbeller@gmail.com> writes:

> In line 1763 of unpack-tree.c we have a condition on the current tree
> 	if (current) {
> 		...
> Within this block of code we can assume current to be non NULL, hence
> the code after the statement in line 1796:
> 	if (current)
> 		return ...
>
> cannot be reached.
>
> current/newtree/oldtree are used in the
> call to reject_merge() *only* for their path aka ce->name, and they
> all point at the same name (there is no rename funkies here); hence
> "all other failures" code path should just rely on current always
> being present.
>
> All referenced lines have been introduced in the same commit
> 076b0adc (2006-07-30, read-tree: move merge functions to the library),
> which was just moving the code around.
> The outer condition on the current tree (now in line 1763) was introduced
> in c859600954df4c292e, June 2005, [PATCH] read-tree: save more user hassles during fast-forward.
> The inner condition on the current tree was introduced in
> ee6566e8d70da682ac4926d, Sept. 2005, [PATCH] Rewrite read-tree
>
> This issue was found by coverity, Id:290002
>
> Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> ---
>  unpack-trees.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> Did I understand you right, when changing to this one?

Something like that.  I've already pushed out the original with a
tentative "SQUASH???" on top for today's integration; I'll try to
remember replacing them with this version.

Thanks.

>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index c6aa8fb..42ee84e 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1789,15 +1789,11 @@ int twoway_merge(const struct cache_entry * const *src,
>  			/* 20 or 21 */
>  			return merged_entry(newtree, current, o);
>  		}
> +		else if (o->gently) {
> +			return  -1 ;
> +		}
>  		else {
> -			/* all other failures */
> -			if (oldtree)
> -				return o->gently ? -1 : reject_merge(oldtree, o);
> -			if (current)
> -				return o->gently ? -1 : reject_merge(current, o);
> -			if (newtree)
> -				return o->gently ? -1 : reject_merge(newtree, o);
> -			return -1;
> +			reject_merge(current, o);
>  		}
>  	}
>  	else if (newtree) {

  reply	other threads:[~2014-08-12 22:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11 19:44 [PATCH] unpack-tree.c: remove dead code Stefan Beller
2014-08-12 18:13 ` Junio C Hamano
2014-08-12 21:15   ` Stefan Beller
2014-08-12 22:24     ` Junio C Hamano [this message]
2014-08-12 23:57     ` [PATCH 0/3] " Jonathan Nieder
2014-08-12 23:59       ` [PATCH 1/3] unpack-trees: simplify 'all other failures' case Jonathan Nieder
2014-08-13  0:00       ` [PATCH 2/3] unpack-trees: use 'cuddled' style for if-else cascade Jonathan Nieder
2014-08-13 14:52         ` Ronnie Sahlberg
2014-08-13  0:03       ` [PATCH 3/3] checkout -m: attempt merge when deletion of path was staged Jonathan Nieder
2014-08-13  0:38         ` Junio C Hamano
2014-08-13 17:48         ` Junio C Hamano
2014-08-13 18:59           ` Junio C Hamano
2014-08-13 19:30             ` Johannes Sixt
2014-08-13 20:02               ` Junio C Hamano
2014-08-13  6:41       ` [PATCH 0/3] Re: [PATCH] unpack-tree.c: remove dead code Stefan Beller

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=xmqqmwb94a8l.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=stefanbeller@gmail.com \
    /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.