Patriotism or civil piety is itself something that is relatively rarely given serious sustained analysis. In the ancient and medieval world, it is seen as an obvious extension of devotion to parents; if one takes devotion to family as being devotion to parents at first remove, then civil piety is devotion to parents at second and third remove. This does not mean that it was regarded as unimportant -- such a suggestion would have been completely foreign to Cicero -- but that it's really part of a larger virtue concerned with familial duty and respect. Patriotism tends to be detached more from filial piety in the modern world, but rarely with the result of being extensively analyzed on its own. There has in recent times been more discussion, largely deriving from Alasdair MacIntyre's "Is Patriotism a Virtue?", which argues that it is and that it is not a virtue modern liberalism can encompass. Both of these have been discussed at length, and one of the major philosophical debates currently running is whether patriotism should be seen as a virtue or a vice. In my opinion, this debate has been largely of definitely inferior quality, in which participants have largely attempted to address the question without regard for obvious virtue ethical questions or, at times, even the history of the idea. Perhaps the best argument for the claim that patriotism is a vice is that in Simon Keller's "Patriotism as Bad Faith". But there are a number of obvious defects in Keller's argument, not least of which that, despite Keller's attempt to argue against the analogy between love of country and love of parents, it really boils down to stipulation and a double standard; one can, despite Keller's claims otherwise, run parallel arguments against there being a virtue concerned with one's parents. Other arguments, for and against, are often even more egregious, often relying on verbal sleights of hand.
One of the nice things about the Aristotelian doctrine of the mean, in which every virtue is seen as a geometrical mean between at least one vice of defect and at least one vice of excess, is that it frees study of the virtues from the tyranny of vocabulary. Aristotle himself recognized this, pointing out that the doctrine of mean shows that there are virtues and vices for which we do not even have words, usually because they don't come up enough as major and obvious problems in our society. But they are still part of the moral terrain, despite being easily overlooked through a lack of vocabulary. The doctrine of the mean makes them identifiable even under conditions where we have no available words for describing them. Another aspect, relevant here, is that because our vocabulary is necessarily more limited than the full richness of moral character, it will often be the case that we will end up falling back on using the same word to describe both virtues and vices. Since the doctrine of the mean doesn't imply that virtues are equal distances from their vices of defect and vices of excess, one of the vices is usually much closer to the virtue than the others. When it's close enough, the vice can easily be confused with the virtue. The doctrine of the mean makes it easier to determine when this is actually happening. And it is clear enough that this has come to be the case with patriotism. The point is put quite nicely by G. K. Chesterton in his essay, "A Defence of Patriotism":
The decay of patriotism in England during the last year or two is a serious and distressing matter. Only in consequence of such a decay could the current lust of territory be confounded with the ancient love of country. We may imagine that if there were no such thing as a pair of lovers left in the world, all the vocabulary of love might without rebuke be transferred to the lowest and most automatic desire. If no type of chivalrous and purifying passion remained, there would be no one left to say that lust bore none of the marks of love, that lust was rapacious and love pitiful, that lust was blind and love vigilant, that lust sated itself and love was insatiable. So it is with the 'love of the city,' that high and ancient intellectual passion which has been written in red blood on the same table with the primal passions of our being. On all sides we hear to-day of the love of our country, and yet anyone who has literally such a love must be bewildered at the talk, like a man hearing all men say that the moon shines by day and the sun by night.
This is put in the usual indirect Chesterton way, but the point is quite important: when people don't have a very good acquaintance with a virtue, the words to describe it end up being used to describe the vice that most closely mimics it.
This is why the proper way to approach the virtue that sometimes is known as patriotism is by looking at the relevant vice of defect. If you look at all the recent debates about whether patriotism is a virtue, you find that this is precisely what tends to be left out. It shows one way in which the manner of formulating a question may dangerously interfere with answering it. "Is patriotism a virtue or a vice?" seems quite straightforward, but in this case, the relevant virtue, assuming there is such a virtue, pretty much has to be much closer to some vice of excess than to a vice of defect, because patriotism is universally recognized as a quite active and passionate thing with lots of consequences, whether one regards it as a virtue or as a vice. But to draw the distinction between a virtue and a vice that closely mimics it, one must already know what the virtue and the vice are. So if patriotism is a virtue, trying to take on the question "Is patriotism a virtue?" directly is almost certainly not the best way to discover that fact. What one should do is look for the vice that is least like what a virtue associated with the word 'patriotism' would have to be. In this case, it is the vice of defect, civil impiety as I've called it, and one should begin with the question: "Is there a vicious form of deficiency in matters of the sort that are usually associated with patriotism?" It is this question that people should really have asked. It could be that when we look at the kinds of moral deficiency one can have in these matters that the non-deficiencies are not actually the kinds of things we ever ordinarily call 'patriotism'. It's pretty obvious that this is not true in the case of patriotism; not being a traitor to one's country or not being indifferent to the moral life of one's citizenry as a whole are clearly the kinds of things people usually count as falling under the term. One then can go on to ask whether these are traceable to the same virtues or different ones, what kinds of vices of excess there would be, and other relevant questions, thus making actual progress in the discussion.