[Bug 56839] New: Grep tool searchs source control directories

Bill Davenport bdavnpt2002 at yahoo.com
Fri Apr 4 18:09:03 UTC 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=56839     
           Summary: Grep tool searchs source control directories
           Product: kdevelop
           Version: unspecified
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: wishlist
          Priority: NOR
         Component: general
        AssignedTo: kdevelop-devel at kdevelop.org
        ReportedBy: bdavnpt2002 at yahoo.com


Version:           gideon cvs snapshot of 20030331 (using KDE KDE 3.1)
Installed from:    Compiled From Sources
Compiler:          gcc 3.2 
OS:          Linux

It would be nice to have the grep tool skip source control directories when performing a recursive search for files containing a string.

Here is a small patch I wrote against kdevelop20030331.tar.gz that adds a check box the the grep tool dialog box to skip over source control directories (CVS and SCCS):

diff -Naur kdevelop/parts/grepview/grepdlg.cpp kdevelop-modified/parts/grepview/grepdlg.cpp
--- kdevelop/parts/grepview/grepdlg.cpp	2002-11-13 15:25:08.000000000 -0500
+++ kdevelop-modified/parts/grepview/grepdlg.cpp	2003-04-04 11:04:40.000000000 -0500
@@ -131,6 +131,13 @@
     dir_layout->addSpacing(10);
     dir_layout->addWidget(recursive_box);
 
+#ifdef IGNORE_SCM_DIRS
+    ignore_scm_box = new QCheckBox(i18n("&Skip SCM dirs"), this);
+    ignore_scm_box->setChecked(true);
+    dir_layout->addSpacing(10);
+    dir_layout->addWidget(ignore_scm_box);
+#endif
+
     QBoxLayout *button_layout = new QHBoxLayout(4);
     layout->addLayout(button_layout, 5, 1);
     QPushButton *search_button = new QPushButton(i18n("&Search"), this);
diff -Naur kdevelop/parts/grepview/grepdlg.h kdevelop-modified/parts/grepview/grepdlg.h
--- kdevelop/parts/grepview/grepdlg.h	2001-08-09 17:39:55.000000000 -0400
+++ kdevelop-modified/parts/grepview/grepdlg.h	2003-04-04 11:04:40.000000000 -0500
@@ -12,6 +12,8 @@
 #ifndef _GREPDLG_H_
 #define _GREPDLG_H_
 
+#define IGNORE_SCM_DIRS
+
 #include <qdialog.h>
 #include <qlineedit.h>
 #include <qcombobox.h>
@@ -42,6 +44,10 @@
 	{ return dir_combo->currentText(); }
     bool recursiveFlag() const
 	{ return recursive_box->isChecked(); }
+#ifdef IGNORE_SCM_DIRS
+    bool ignoreSCMDirsFlag() const
+	{ return ignore_scm_box->isChecked(); }
+#endif
 
 signals:
     void searchClicked();
@@ -55,6 +61,9 @@
     QLineEdit *template_edit;
     QComboBox *dir_combo, *pattern_combo, *files_combo;
     QCheckBox *recursive_box;
+#ifdef IGNORE_SCM_DIRS
+    QCheckBox *ignore_scm_box;
+#endif
     KConfig* config;
 };
 
diff -Naur kdevelop/parts/grepview/grepviewwidget.cpp kdevelop-modified/parts/grepview/grepviewwidget.cpp
--- kdevelop/parts/grepview/grepviewwidget.cpp	2003-03-12 21:55:31.000000000 -0500
+++ kdevelop-modified/parts/grepview/grepviewwidget.cpp	2003-04-04 11:04:41.000000000 -0500
@@ -181,7 +181,16 @@
     filepattern += files;
     filepattern += " \\) -print";
 
+#ifdef IGNORE_SCM_DIRS
+    QString command = filepattern + " " ;
+    if (grepdlg->ignoreSCMDirsFlag()) {
+      command += "| grep -v \"SCCS/\" ";
+      command += "| grep -v \"CVS/\" ";
+    }
+    command += "| xargs " ;
+#else
     QString command = filepattern + " | xargs " ;
+#endif
     command += "egrep -n -e ";
     command += KShellProcess::quote(pattern);
     startJob("", command);




More information about the KDevelop-devel mailing list