1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
From 584005f2e26149282aa12c4a0367d250caaf3918 Mon Sep 17 00:00:00 2001
From: Jehan Bing <nahor.j@gmail.com>
Date: Thu, 10 Mar 2011 10:54:52 -0800
Subject: [PATCH] Create backup reference before deletion of the original branch
Ensure that the backup reference is created before deleting the original
branch. As it was, the deletion was executed earlier causing the backup
reference to point to a non-existing branch so was not created.
---
src/repository.cpp | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/repository.cpp b/src/repository.cpp
index 7de840f..2c70bf3 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -349,11 +349,12 @@ int Repository::resetBranch(const QString &branch, int revnum, int mark, const Q
branchRef.prepend("refs/heads/");
Branch &br = branches[branch];
+ QByteArray backupCmd;
if (br.created && br.created != revnum && !br.marks.isEmpty() && br.marks.last()) {
QByteArray backupBranch = "refs/backups/r" + QByteArray::number(revnum) + branchRef.mid(4);
qWarning() << "WARN: backing up branch" << branch << "to" << backupBranch;
- resetBranches.append("reset " + backupBranch + "\nfrom " + branchRef + "\n\n");
+ backupCmd = "reset " + backupBranch + "\nfrom " + branchRef + "\n\n";
}
br.created = revnum;
@@ -365,9 +366,9 @@ int Repository::resetBranch(const QString &branch, int revnum, int mark, const Q
+ " branch " + branch.toUtf8() + " = :" + QByteArray::number(mark)
+ " # " + comment + "\n\n";
if(comment == "delete")
- deletedBranches.append(cmd);
+ deletedBranches.append(backupCmd).append(cmd);
else
- resetBranches.append(cmd);
+ resetBranches.append(backupCmd).append(cmd);
return EXIT_SUCCESS;
}
--
1.7.4.1
|