tl;dr There really isn't a sustainability argument for switching either way between them: there is only an argument for switching away from both. It's akin to asking whether we should switch from coal to gas: the answer is that that's not a meaningful question: we absolutely have to stop using both.
So although the question is in the same sort of rhetorical terrain as asking whether it's better to suffer a premature death by gun or knife, when the answer is obviously that it's better to not suffer a premature death, let's look at lifecycle analysis of their relative unsustainability.
On specific pollutants, on a well-to-wheel basis, per unit distance driven, diesel tends to be worse for particulates and NOx; petrol (gasoline) is worse for CO2 and hydrocarbons.
The system boundary for sustainability analysis
When looking at sustainability, one has to draw a system boundary somewhere, to set out what will be included in the study, and what will be excluded.
Where one draws a system boundary is a judgement call: if it goes beyond our galaxy or beyond a billion years, you're system boundary is too large. If, however, it does not include consumption of the product and its direct consequences, then your system boundary is too small.
For transport, we typically use a well-to-wheel basis. That's a generic description that applies even when the fuel doesn't come from a well (and even if the transport doesn't have wheels), and relates to the supply chain from initial extraction to the transport itself and the direct consequences, but not the indirect consequences such as changes in land use.
Is the question meaningful?
Neither petrol (gasoline) nor diesel are at all sustainable. Both score zero for sustainability. And there is little to choose between their unsustainability: the trade-offs being some increase in NOx and particulates, for some decrease in CO2 and hydrocarbons.
Both release carbon dioxide (and other pollutants) during combustion; and that is leading us to catastrophic climate change.
Both come from crude oil, which is a finite, depletable resource.
The extraction of crude oil itself is environmentally destructive.
All this means that the refining of each is environmentally unsustainable too: the production of each is unsustainable, along the entire supply chain.
So the question, as posed, is not meaningful: it does not make any sense to ask about the sustainability of just the refining part of petrol (gasoline) or diesel.
And given that the entire supply chain for each is unsustainable, it does not make any sense to talk about the relative sustainability of one part of that supply chain: sustainability by its very nature is an issue that concerns the whole system, not just one component.
But which is worse?
According to the Life Cycle Assessment of
Vehicle Fuels and Technologies (2006, London Borough of Camden), diesel CO2 emissions are 16% lower than petrol on a life cycle basis (p36). However, particulate and NOx emissions from diesel are significantly worse (p37), with petrol NOx being only 60% of diesel NOx. Petrol has worse hydrocarbon emissions (p38). Those are on a unit-distance basis. Conversely, the unit-energy basis is used in the UK DTI report from 2003, Life Cycle Assessment of Vehicle Fuels and Technologies, which gives total GHG emissions of 87gCO2e/MJ for ultra low sulphur diesel, and 81gCO2e/MJ for unleaded petrol (gasoline) (Table II).
In summary: there's really not much too choose between them. They're both completely unsustainable, in only slightly different ways.