Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=e94188f01b4578d0ce2772f65d7d91bc9f3439bc

commit e94188f01b4578d0ce2772f65d7d91bc9f3439bc
Author: Michel Hermier <herm...@frugalware.org>
Date:   Thu May 15 13:33:51 2014 +0200

libpacman: Initialise pkg_new and pkg_local in a single place.

diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp
index 1cdd9cf..3266a93 100644
--- a/lib/libpacman/trans.cpp
+++ b/lib/libpacman/trans.cpp
@@ -1805,12 +1805,14 @@ int __pmtrans_t::commit(pmtranstype_t type, pmlist_t 
**data)
}

if(type & PM_TRANS_TYPE_ADD) {
-               pkg_new = (Package *)targ->data;
-
-               type = this->type;
+                       pkg_new = (Package *)targ->data;
+                       type = this->type;
+               } else {
+                       pkg_local = (Package *)targ->data;
+               }

/* see if this is an upgrade.  if so, remove the old package first */
-               if(type == PM_TRANS_TYPE_UPGRADE) {
+               if(pkg_local == NULL) {
pkg_local = _pacman_db_get_pkgfromcache(db_local, pkg_new->name());
if(pkg_local == NULL) {
/* no previous package version is installed, so this is actually
@@ -1818,6 +1820,8 @@ int __pmtrans_t::commit(pmtranstype_t type, pmlist_t 
**data)
type &= ~PM_TRANS_TYPE_REMOVE;
}
}
+
+               if(type & PM_TRANS_TYPE_ADD) {
EVENT(this, trans_event_table[type].pre.event, pkg_new, NULL);
if(type == PM_TRANS_TYPE_UPGRADE)
{
@@ -1965,7 +1969,6 @@ int __pmtrans_t::commit(pmtranstype_t type, pmlist_t 
**data)
}
}
if(type == PM_TRANS_TYPE_REMOVE) {
-               pkg_local = (Package*)targ->data;
if(this->type != PM_TRANS_TYPE_UPGRADE) {
EVENT(this, PM_TRANS_EVT_REMOVE_START, pkg_local, NULL);
_pacman_log(PM_LOG_FLOW1, _("removing package %s-%s"), pkg_local->name(), 
pkg_local->version());
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to