pq-rpm: support patch-export up to an arbitrary tree-ish
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 8 May 2013 17:42:45 +0000 (20:42 +0300)
committerJun Wang <junbill.wang@samsung.com>
Wed, 27 Jan 2016 11:47:15 +0000 (19:47 +0800)
If the end of the export range is not a commit "normal" patches are
generated up to HEAD and finally a raw diff between HEAD and the
end-tree-is generated.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Conflicts:
gbp/scripts/pq_rpm.py

gbp/scripts/pq_rpm.py

index f0e7574..09ee9bc 100755 (executable)
@@ -149,6 +149,19 @@ def generate_patches(repo, start, squash, end, outdir, options):
             start = merge_sha1
             print start
 
+    try:
+        end_commit = end
+        end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+    except GitRepositoryError:
+        # In case of plain tree-ish objects, assume current branch head is the
+        # last commit
+        end_commit = "HEAD"
+        end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+
+    start_sha1 = repo.rev_parse("%s^0" % start)
+    if repo.get_merge_base(start_sha1, end_commit_sha1) != start_sha1:
+        raise GbpError("Start commit '%s' not an ancestor of end commit "
+                       "'%s'" % (start, end_commit))
     # Generate patches
     for commit in reversed(repo.get_commits(start, end_commit)):
         info = repo.get_commit_info(commit)