From: Stefan Beller <stefanbeller@gmail.com>
To: gitster@pobox.com, Johannes.Schindelin@gmx.de,
barkalow@iabervon.org, git@vger.kernel.org
Cc: Stefan Beller <stefanbeller@gmail.com>
Subject: [PATCH] unpack-tree.c: remove dead code
Date: Mon, 11 Aug 2014 21:44:28 +0200 [thread overview]
Message-ID: <1407786268-15249-1-git-send-email-stefanbeller@gmail.com> (raw)
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.
The proposed patch here changes the order of the current tree and the
newtree part. I'm not sure if that's the right way to handle it.
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>
---
unpack-trees.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index c6aa8fb..e6d37ff 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1793,11 +1793,10 @@ int twoway_merge(const struct cache_entry * const *src,
/* 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;
+ /* current is definitely exists here */
+ return o->gently ? -1 : reject_merge(current, o);
}
}
else if (newtree) {
--
2.1.0.rc2
next reply other threads:[~2014-08-11 19:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-11 19:44 Stefan Beller [this message]
2014-08-12 18:13 ` [PATCH] unpack-tree.c: remove dead code Junio C Hamano
2014-08-12 21:15 ` Stefan Beller
2014-08-12 22:24 ` Junio C Hamano
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=1407786268-15249-1-git-send-email-stefanbeller@gmail.com \
--to=stefanbeller@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).