git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH QGit RFC] Fix "Save patch..." on a commit range

From
MCMarco Costalba <mcostalba@gmail.com>
Date
Jun 15, 2009, 22:07 UTC
Message-ID
<e5bfff550906151507t3f6ccf39j177f7c39d8495f5a@mail.gmail.com>
In-Reply-To
<e5bfff550906151445m2f38c3fw964e01251d9568b9@mail.gmail.com>
On Mon, Jun 15, 2009 at 22:45, Marco Costalba<mcostalba@gmail.com> wrote:
Show 5 quoted lines
> On Mon, Jun 15, 2009 at 22:25, Marco Costalba<mcostalba@gmail.com> wrote:
>>
>> This is really strange !
>>
>

I have prepared a possible patch, could you please test if fixes the problem for you.

Patch is in attachment.

Thanks Marco

From 8e4ac4bf9b6c04b09e16a2a49b96f6bf4c75d2e7 Mon Sep 17 00:00:00 2001
From: Marco Costalba <mcostalba@gmail.com>
Date: Mon, 15 Jun 2009 23:01:42 +0100
Subject: [PATCH] Fix format patch bad selected revision order

We cannot trust the order of selected items returned by QItemSelectionModel::selectedRows() that is used to call git format-patch.

It is not documented and could change with a new version of Qt libraries.

So manually reorder the selected revisions before to feed git format-patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 src/git.cpp |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/git.cpp b/src/git.cpp
index 8546f6f..d55d1c2 100644
--- a/src/git.cpp
+++ b/src/git.cpp
@@ -1577,9 +1577,18 @@ bool Git::formatPatch(SCList shaList, SCRef dirPath, SCRef remoteDir) {
 	if (remote)
 		workDir = remoteDir; // run() uses workDir value
 
-	// shaList is ordered by newest to oldest
-	runCmd.append(" " + shaList.last());
-	runCmd.append(QString::fromLatin1("^..") + shaList.first());
+	// Don't trust shaList order but reorder from newest to oldest
+	QStringList orderedShaList;
+	FOREACH_SL (it, shaList)
+		appendNamesWithId(orderedShaList, *it, QStringList(*it), true);
+
+	orderedShaList.sort();
+	QStringList::iterator itN(orderedShaList.begin());
+	for ( ; itN != orderedShaList.end(); ++itN) // strip 'idx'
+		(*itN) = (*itN).section(' ', -1, -1);
+
+	runCmd.append(" " + orderedShaList.last());
+	runCmd.append(QString::fromLatin1("^..") + orderedShaList.first());
 	bool ret = run(runCmd);
 	workDir = tmp;
 	return ret;
-- 
1.6.1.9.g97c34
Previous: Marco CostalbaNext: Markus Heidelberg
Message 11 of 15 in “Fix "Save patch..." on a commit range”
  1. Fix "Save patch..." on a commit rangeMarkus Heidelberg, Jun 12, 2009
  2. Marco CostalbaJun 13, 2009
  3. Markus HeidelbergJun 13, 2009
  4. Markus HeidelbergJun 13, 2009
  5. Marco CostalbaJun 13, 2009
  6. Markus HeidelbergJun 13, 2009
  7. Marco CostalbaJun 13, 2009
  8. Markus HeidelbergJun 15, 2009
  9. Marco CostalbaJun 15, 2009
  10. Marco CostalbaJun 15, 2009
  11. Marco CostalbaJun 15, 2009
  12. Markus HeidelbergJun 15, 2009
  13. Marco CostalbaJun 16, 2009
  14. Markus HeidelbergJun 16, 2009
  15. Markus HeidelbergJun 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.