From 51225b326310af23e5ceda0c6cd6cc563901ccab Mon Sep 17 00:00:00 2001
From: Chantry Xavier <xav@chantry.homelinux.org>
Date: Sun, 20 May 2007 01:20:07 -0500
Subject: Add -Qee option for the original behavior of -Qe

-Qee now lists "orphans" the way pacman used to - that
is, -Qe lists packages required by nothing that were
installed as a dependency, but -Qee lists all packages
not required by something else.

Also, I snuck in a compile fix for my real_path cleanup earlier, heh

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
---
 src/pacman/pacman.c | 2 +-
 src/pacman/query.c  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index fe70ea10..58e85b22 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -386,7 +386,7 @@ static int parseargs(int argc, char *argv[])
 				break;
 			case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; break;
 			case 'e':
-				config->op_q_orphans = 1;
+				config->op_q_orphans++;
 				config->flags |= PM_TRANS_FLAG_DEPENDSONLY;
 				break;
 			case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break;
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 06d111b0..4abb674d 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -51,7 +51,7 @@ static char *resolve_path(const char* file)
 		return(NULL);
 	}
 
-	if(!realpath(copy, str)) {
+	if(!realpath(file, str)) {
 		return(NULL);
 	}
 
@@ -289,7 +289,8 @@ int pacman_query(alpm_list_t *targets)
 					dump_pkg_files(info);
 				} else if(config->op_q_orphans) {
 					if(alpm_pkg_get_requiredby(info) == NULL
-						 && (long)alpm_pkg_get_reason(info) == PM_PKG_REASON_DEPEND) {
+						 && ((long)alpm_pkg_get_reason(info) == PM_PKG_REASON_DEPEND
+								 || config->op_q_orphans > 1)) {
 						printf("%s %s\n", pkgname, pkgver);
 					}
 				} else {
-- 
cgit v1.2.3-2-g168b