Package: topgit
Version: 0.5-1
Severity: important
Tags: patch

This report has three parts.  The first part is a short description of my 
problem
without a precise way to recreate it.  The second part is a complete shell 
session
with all the commands needed to recreate the problem together with their 
output.
In the third part I explain what I think is wrong in the source code and 
include a patch to fix it.

Short description of problem
----------------------------

I try to megre three independent topic branches by the command

$ tg create t/merge t/a t/b t/2

There is a conflict merging t/a and t/b.  I resolve it and type

$ tg create

After this the topic branch is seemingly set up but the base of the new branch 
is at t/2.  This is also where t/merge points to and the working directory
(apart from .topdeps and .topmsg) is also in this state.
I would expect alll this to be the merge of my resolution commit (the merge of 
t/a and t/b) and t/2.

Recreation of problem
---------------------

Here is a compete shell session producing the problem.
All commands are shown from the creation of the git repository.

ga...@gabor ~/tmp/topgit$ git init
Initialized empty Git repository in /home/gabor/tmp/topgit/.git/
ga...@gabor ~/tmp/topgit$ echo 0 >file
ga...@gabor ~/tmp/topgit$ git add file
ga...@gabor ~/tmp/topgit$ git commit -m 'Created file with content 0.'
Created initial commit 294b3f1: Created file with content 0.
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file
ga...@gabor ~/tmp/topgit$ tg create t/a
tg: Automatically marking dependency on master
tg: Creating t/a base from master...
Switched to a new branch "t/a"
tg: Topic branch t/a set up. Please fill .topmsg now and make initial commit.
tg: To abort: git rm -f .top* && git checkout master && tg delete t/a
ga...@gabor ~/tmp/topgit$ echo a >file
ga...@gabor ~/tmp/topgit$ git commit -a -m 'Changed content of file to a.'
Created commit 22ad7e0: Changed content of file to a.
 3 files changed, 8 insertions(+), 1 deletions(-)
 create mode 100644 .topdeps
 create mode 100644 .topmsg
ga...@gabor ~/tmp/topgit$ tg create t/b master
tg: Creating t/b base from master...
Switched to a new branch "t/b"
tg: Topic branch t/b set up. Please fill .topmsg now and make initial commit.
tg: To abort: git rm -f .top* && git checkout master && tg delete t/b
ga...@gabor ~/tmp/topgit$ echo b >file
ga...@gabor ~/tmp/topgit$ echo 1 >file1
ga...@gabor ~/tmp/topgit$ git add file file1
ga...@gabor ~/tmp/topgit$ git commit -m 'Changed content of file to b & added 
file1.'
Created commit 4645b70: Changed content of file to b & added file1.
 4 files changed, 9 insertions(+), 1 deletions(-)
 create mode 100644 .topdeps
 create mode 100644 .topmsg
 create mode 100644 file1
ga...@gabor ~/tmp/topgit$ tg create t/2 master
tg: Creating t/2 base from master...
Switched to a new branch "t/2"
tg: Topic branch t/2 set up. Please fill .topmsg now and make initial commit.
tg: To abort: git rm -f .top* && git checkout master && tg delete t/2
ga...@gabor ~/tmp/topgit$ echo 2 >file2
ga...@gabor ~/tmp/topgit$ git add file2
ga...@gabor ~/tmp/topgit$ git commit -m 'Added file2.'
Created commit 5e9af0b: Added file2.
 3 files changed, 8 insertions(+), 0 deletions(-)
 create mode 100644 .topdeps
 create mode 100644 .topmsg
 create mode 100644 file2
ga...@gabor ~/tmp/topgit$ tg create t/merge t/a t/b t/2
tg: Creating t/merge base from t/a...
tg: Merging t/merge base with t/b...
Auto-merged .topmsg
Auto-merged file
CONFLICT (content): Merge conflict in file
Recorded preimage for 'file'
Automatic merge failed; fix conflicts and then commit the result.
tg: Please commit merge resolution and call: tg create
tg: It is also safe to abort this operation using:
tg: git reset --hard some_branch
tg: (You are on a detached HEAD now.)
ga...@gabor ~/tmp/topgit$ echo c >file
ga...@gabor ~/tmp/topgit$ git add file
ga...@gabor ~/tmp/topgit$ git commit -m 'Resolved conflict: changed content of 
file to c.'
fatal: ref HEAD is not a symbolic ref
Recorded resolution for 'file'.
Created commit 7f7221d: Resolved conflict: changed content of file to c.
ga...@gabor ~/tmp/topgit$ tg create
tg: Resuming t/merge setup...
tg: Creating t/merge base from t/2...
Switched to a new branch "t/merge"
tg: Topic branch t/merge set up. Please fill .topmsg now and make initial 
commit.
tg: To abort: git rm -f .top* && git checkout t/a && tg delete t/merge
ga...@gabor ~/tmp/topgit$ ls
file  file2
ga...@gabor ~/tmp/topgit$ cat file
0
ga...@gabor ~/tmp/topgit$ cat file2
2


The last few commands are for examining the working tree.
Further examination reveals that HEAD is t/merge, which is the same as t/2.

Solution to the problem
-----------------------

I think the key to the solution is the following excerpt from the above 
session:

ga...@gabor ~/tmp/topgit$ tg create
tg: Resuming t/merge setup...
tg: Creating t/merge base from t/2...

Ooops! HEAD should be chosen as t/merge base and then t/2 should be merged in.

So I think the problem is that on resume, when there are still dependency 
branches to merge in,
tg create uses the first such dependency to merge the rest in instead of using 
HEAD to merge in
all of them.

The patch to fix this:

--- /usr/share/topgit/tg-create 2008-11-19 17:51:47.000000000 +0100
+++ /usr/share/topgit/tg-create 2009-01-24 16:45:06.000000000 +0100
@@ -80,7 +80,7 @@
 
 ## Create base
 
-if [ -n "$merge" ]; then
+if [ -n "$merge" -a -z "$restarted" ]; then
        # Unshift the first item from the to-merge list
        branch="${merge%% *}"
        merge="${merge#* }"


Best wishes,

   Gábor Braun

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (990, 'stable'), (650, 'testing'), (600, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.24-etchnhalf.1-686
Locale: LANG=hu_HU.UTF-8, LC_CTYPE=hu_HU.UTF-8 (charmap=UTF-8)

Versions of packages topgit depends on:
ii  git-core                     1:1.5.6.5-2 fast, scalable, distributed revisi

topgit recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to