The correct quote is from an interview with Grant and a newspaper, I believe it was the Chicago Times, mid-war. It is often misquoted, due to the internet.
"The sole objective of this war is to restore the Union. Should I be convinced it has any other object, or that the government designs using its soldiers to execute the wishes of the Abolitionists, I pledge to you my honor as a man and a soldier, I would resign my commission and carry my sword to the other side."
__________________________
David Upton