From 5f7dd9217acd08d3e8ba95660c5219c4587c37da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 12:41:25 +0100 Subject: [PATCH 1/7] Mini test shell script to see if git-geo works at all --- tests/geogit.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 tests/geogit.sh diff --git a/tests/geogit.sh b/tests/geogit.sh new file mode 100755 index 0000000..f80c271 --- /dev/null +++ b/tests/geogit.sh @@ -0,0 +1,25 @@ +rm -rf foo +rm -rf bar + +mkdir foo +cd foo +git init +git geo setup +touch file1 +git add file1 +git commit -m "Add file1" +git checkout -b not-master +cd ../ + +git clone foo bar +cd bar +git geo setup +echo "content" > file1 +git commit -a -m "Write content to file1" +git geo push origin master:master +cd .. + +cd foo +git remote add bar ../bar +git checkout master +git log --show-notes=geocommit From aaca72964c3355160f7cb39ad62e6940ebaaa196 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 13:19:53 +0100 Subject: [PATCH 2/7] Switch notes merging code to git notes merge. Git >= 1.7.3.3 required. This works much more reliably because it does not check any notes out into the working directory. --- src/geocommit/__init__.py | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index 17ac339..25ddec5 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -108,31 +108,9 @@ def fetch_and_merge_notes(self, remote): remote_changes = system("git rev-list --max-count=1 refs/notes/geocommit..FETCH_HEAD").strip('\n\r ') if remote_changes: - - stash = "\"geocommit temporary stash\"" - code, output = system_exit_code("git stash save " + stash) - - if code != 0: - print output - - else: - current_rev = system("git symbolic-ref -q HEAD").strip('\n\r ') - - if not current_rev: - current_rev = system("git rev-parse HEAD").strip('\n\r ') - elif current_rev.find("refs/heads/") == 0: - current_rev = current_rev[len("refs/heads/"):] - - system_exit_code("git checkout refs/notes/geocommit") - print "Merging geocommit notes" - system_exit_code("git merge --strategy=recursive -Xtheirs -Xrename-threshold=100% FETCH_HEAD") - rev = system("git rev-parse HEAD").strip('\n\r ') - system_exit_code("git update-ref refs/notes/geocommit " + rev) - - print "Restoring working diretory" - system_exit_code("git checkout " + current_rev) - system_exit_code("git stash apply") - system_exit_code("git stash drop " + stash) + print "Merging geocommit notes" + system_exit_code("git update-ref refs/notes/geocommit-remote FETCH_HEAD") + system_exit_code("git notes --ref geocommit merge --strategy=theirs geocommit-remote") else: print "Already up-to-date." From 922310c3ffcf4e0bc15a1e49d48f45d329a9a996 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 13:26:31 +0100 Subject: [PATCH 3/7] Add output indicating that a location is being searched, to explain commit delays --- src/geocommit/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index 25ddec5..148c412 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -140,7 +140,9 @@ def get_remote(self): return None def cmd_note(self, argv): + print "Retrieving location ...", note = self.get_note() + print "found." git_rev = self.git_rev From 069523230d7ce8698d06be2e6a81a9c634c4f7f3 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 13:34:33 +0100 Subject: [PATCH 4/7] Speed up git geo push, by pushing geocommit notes together with the rest --- src/geocommit/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index 148c412..ba6944c 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -196,7 +196,7 @@ def cmd_pull(self, argv): self.fetch_and_merge_notes(argv[0]) - def cmd_sync(self, argv): + def cmd_sync(self, argv, push=True): if len(argv) == 0: remote = self.get_remote() if remote: @@ -209,8 +209,9 @@ def cmd_sync(self, argv): self.fetch_and_merge_notes(argv[0]) - print "Syncing geocommit notes" - forward_system("git push " + argv[0] + " refs/notes/geocommit") + if push: + print "Syncing geocommit notes" + forward_system("git push " + argv[0] + " refs/notes/geocommit") def cmd_push(self, argv): opt_definition = { @@ -244,9 +245,9 @@ def cmd_push(self, argv): print >> sys.stderr, "Cannot push geo data: No remote specified" usage("push") - self.cmd_sync([arguments[0]]) + self.cmd_sync([arguments[0]], False) - forward_system(["git", "push"] + argv) + forward_system(["git", "push"] + argv + ["refs/notes/geocommit"]) def cmd_version(self, argv): print "version: " + version From 6b3fb2040331889642eb35f708c3c2e56dbc1ea5 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 13:35:18 +0100 Subject: [PATCH 5/7] Flush output after first part of retrieving location message not ending in newline --- src/geocommit/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index ba6944c..0a69cd2 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -141,6 +141,7 @@ def get_remote(self): def cmd_note(self, argv): print "Retrieving location ...", + sys.stdout.flush() note = self.get_note() print "found." From 8b66817de64bea338726a1d479f42e28957bd337 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 12 Mar 2011 15:25:14 +0100 Subject: [PATCH 6/7] Allow git geo push without specifying a branch to push --- src/geocommit/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index 0a69cd2..9e3e493 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -242,13 +242,19 @@ def cmd_push(self, argv): remote = self.get_remote() if remote: arguments = [remote] + argv += [remote] else: print >> sys.stderr, "Cannot push geo data: No remote specified" usage("push") + if len(arguments) == 1: + arguments += [":"] + argv += [":"] + + argv += ["refs/notes/geocommit"] self.cmd_sync([arguments[0]], False) - forward_system(["git", "push"] + argv + ["refs/notes/geocommit"]) + forward_system(["git", "push"] + argv) def cmd_version(self, argv): print "version: " + version From 2e29db4ad341a6fdced3ece9a58217668ea13e40 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 24 Mar 2011 21:28:44 +0100 Subject: [PATCH 7/7] Complete git push option parsing: --no-thin --- src/geocommit/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/geocommit/__init__.py b/src/geocommit/__init__.py index 9e3e493..25b2e5f 100755 --- a/src/geocommit/__init__.py +++ b/src/geocommit/__init__.py @@ -229,6 +229,7 @@ def cmd_push(self, argv): "-f": "bool", "--force": "bool", "--thin": "bool", + "--no-thin": "bool", "--receive-pack": "string", "--exec": "string", "-u": "bool",