- else if (!DIFF_FILE_VALID(p->two)) {
- if (contains(p->one, needle, len))
+ if (has_changes)
+ return; /* not munge the queue */
+
+ /* otherwise we will clear the whole queue
+ * by copying the empty outq at the end of this
+ * function, but first clear the current entries
+ * in the queue.
+ */
+ for (i = 0; i < q->nr; i++)
+ diff_free_filepair(q->queue[i]);
+ }
+ else
+ /* Showing only the filepairs that has the needle */
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ has_changes = 0;
+ if (!DIFF_FILE_VALID(p->one)) {
+ if (!DIFF_FILE_VALID(p->two))
+ ; /* ignore unmerged */
+ /* created */
+ else if (contains(p->two, needle, len))
+ has_changes = 1;
+ }
+ else if (!DIFF_FILE_VALID(p->two)) {
+ if (contains(p->one, needle, len))
+ has_changes = 1;
+ }
+ else if (!diff_unmodified_pair(p) &&
+ contains(p->one, needle, len) !=
+ contains(p->two, needle, len))
+ has_changes = 1;
+
+ if (has_changes)