* [PATCH v4 01/14] fast-export: avoid importing blob marks
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 02/14] remote-testgit: fix direction of marks Felipe Contreras
` (12 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
We want to be able to import, and then export, using the same marks, so
that we don't push things that the other side already received.
Unfortunately, fast-export doesn't store blobs in the marks, but
fast-import does. This creates a mismatch when fast export is reusing a
mark that were previously stored by fast-import.
There is no point in one tool saving blobs, and the other not, but for
now let's just check in fast-export that the objects are indeed commits.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 4 ++++
t/t9350-fast-export.sh | 14 ++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 12220ad..a06fe10 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -614,6 +614,10 @@ static void import_marks(char *input_file)
if (object->flags & SHOWN)
error("Object %s already has a mark", sha1_to_hex(sha1));
+ if (object->type != 1)
+ /* only commits */
+ continue;
+
mark_object(object, mark);
if (last_idnum < mark)
last_idnum = mark;
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 3e821f9..0c8d828 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -440,4 +440,18 @@ test_expect_success 'fast-export quotes pathnames' '
)
'
+test_expect_success 'test biridectionality' '
+ echo -n > marks-cur &&
+ echo -n > marks-new &&
+ git init marks-test &&
+ git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \
+ git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new &&
+ (cd marks-test &&
+ git reset --hard &&
+ echo Wohlauf > file &&
+ git commit -a -m "back in time") &&
+ git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \
+ git fast-import --export-marks=marks-cur --import-marks=marks-cur
+'
+
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 02/14] remote-testgit: fix direction of marks
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 01/14] fast-export: avoid importing blob marks Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 03/14] Rename git-remote-testgit to git-remote-testpy Felipe Contreras
` (11 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
Basically this is what we want:
== pull ==
testgit transport-helper
* export -> import
# testgit.marks git.marks
== push ==
testgit transport-helper
* import <- export
# testgit.marks git.marks
Each side should be agnostic of the other side. Because testgit.marks
(our helper marks) could be anything, not necesarily a format parsable
by fast-export or fast-import. In this test hey happen to be compatible,
because we use those tools, but in the real world it would be something
compelely different. For example, they might be mapping marks to
mercurial revisions (certainly not parsable by fast-import/export).
This is what we have:
== pull ==
testgit transport-helper
* export -> import
# testgit.marks git.marks
== push ==
testgit transport-helper
* import <- export
# git.marks testgit.marks
The only reason this is working is that git.marks and testgit.marks are
roughly the same.
This new behavior used to not be possible before due to a bug in
fast-export, but with the bug fixed, it works fine.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
git-remote-testgit.py | 2 +-
git_remote_helpers/git/importer.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-remote-testgit.py b/git-remote-testgit.py
index 5f3ebd2..ade797b 100644
--- a/git-remote-testgit.py
+++ b/git-remote-testgit.py
@@ -91,7 +91,7 @@ def do_capabilities(repo, args):
if not os.path.exists(dirname):
os.makedirs(dirname)
- path = os.path.join(dirname, 'testgit.marks')
+ path = os.path.join(dirname, 'git.marks')
print "*export-marks %s" % path
if os.path.exists(path):
diff --git a/git_remote_helpers/git/importer.py b/git_remote_helpers/git/importer.py
index 5c6b595..e28cc8f 100644
--- a/git_remote_helpers/git/importer.py
+++ b/git_remote_helpers/git/importer.py
@@ -39,7 +39,7 @@ class GitImporter(object):
gitdir = self.repo.gitpath
else:
gitdir = os.path.abspath(os.path.join(dirname, '.git'))
- path = os.path.abspath(os.path.join(dirname, 'git.marks'))
+ path = os.path.abspath(os.path.join(dirname, 'testgit.marks'))
if not os.path.exists(dirname):
os.makedirs(dirname)
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 03/14] Rename git-remote-testgit to git-remote-testpy
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 01/14] fast-export: avoid importing blob marks Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 02/14] remote-testgit: fix direction of marks Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 04/14] Add new simplified git-remote-testgit Felipe Contreras
` (10 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
This script is not really exercising the remote-helper functionality,
but more the python framework for remote helpers that live in
git_remote_helpers.
It's also not a good example of how to write remote-helpers, unless you
are planning to use python, and even then you might not want to use this
framework.
So let's use a more appropriate name: git-remote-testpy.
A patch that replaces git-remote-testgit with a simpler version is on
the way.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
.gitignore | 2 +-
Makefile | 2 +-
git-remote-testgit.py | 272 ----------------------------------------------
git-remote-testpy.py | 272 ++++++++++++++++++++++++++++++++++++++++++++++
t/t5800-remote-helpers.sh | 148 -------------------------
t/t5800-remote-testpy.sh | 148 +++++++++++++++++++++++++
6 files changed, 422 insertions(+), 422 deletions(-)
delete mode 100644 git-remote-testgit.py
create mode 100644 git-remote-testpy.py
delete mode 100755 t/t5800-remote-helpers.sh
create mode 100755 t/t5800-remote-testpy.sh
diff --git a/.gitignore b/.gitignore
index a188a82..48d1bbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -124,7 +124,7 @@
/git-remote-ftps
/git-remote-fd
/git-remote-ext
-/git-remote-testgit
+/git-remote-testpy
/git-repack
/git-replace
/git-repo-config
diff --git a/Makefile b/Makefile
index f69979e..e18ee48 100644
--- a/Makefile
+++ b/Makefile
@@ -470,7 +470,7 @@ SCRIPT_PERL += git-relink.perl
SCRIPT_PERL += git-send-email.perl
SCRIPT_PERL += git-svn.perl
-SCRIPT_PYTHON += git-remote-testgit.py
+SCRIPT_PYTHON += git-remote-testpy.py
SCRIPT_PYTHON += git-p4.py
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
diff --git a/git-remote-testgit.py b/git-remote-testgit.py
deleted file mode 100644
index ade797b..0000000
--- a/git-remote-testgit.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/env python
-
-# This command is a simple remote-helper, that is used both as a
-# testcase for the remote-helper functionality, and as an example to
-# show remote-helper authors one possible implementation.
-#
-# This is a Git <-> Git importer/exporter, that simply uses git
-# fast-import and git fast-export to consume and produce fast-import
-# streams.
-#
-# To understand better the way things work, one can activate debug
-# traces by setting (to any value) the environment variables
-# GIT_TRANSPORT_HELPER_DEBUG and GIT_DEBUG_TESTGIT, to see messages
-# from the transport-helper side, or from this example remote-helper.
-
-# hashlib is only available in python >= 2.5
-try:
- import hashlib
- _digest = hashlib.sha1
-except ImportError:
- import sha
- _digest = sha.new
-import sys
-import os
-import time
-sys.path.insert(0, os.getenv("GITPYTHONLIB","."))
-
-from git_remote_helpers.util import die, debug, warn
-from git_remote_helpers.git.repo import GitRepo
-from git_remote_helpers.git.exporter import GitExporter
-from git_remote_helpers.git.importer import GitImporter
-from git_remote_helpers.git.non_local import NonLocalGit
-
-def get_repo(alias, url):
- """Returns a git repository object initialized for usage.
- """
-
- repo = GitRepo(url)
- repo.get_revs()
- repo.get_head()
-
- hasher = _digest()
- hasher.update(repo.path)
- repo.hash = hasher.hexdigest()
-
- repo.get_base_path = lambda base: os.path.join(
- base, 'info', 'fast-import', repo.hash)
-
- prefix = 'refs/testgit/%s/' % alias
- debug("prefix: '%s'", prefix)
-
- repo.gitdir = os.environ["GIT_DIR"]
- repo.alias = alias
- repo.prefix = prefix
-
- repo.exporter = GitExporter(repo)
- repo.importer = GitImporter(repo)
- repo.non_local = NonLocalGit(repo)
-
- return repo
-
-
-def local_repo(repo, path):
- """Returns a git repository object initalized for usage.
- """
-
- local = GitRepo(path)
-
- local.non_local = None
- local.gitdir = repo.gitdir
- local.alias = repo.alias
- local.prefix = repo.prefix
- local.hash = repo.hash
- local.get_base_path = repo.get_base_path
- local.exporter = GitExporter(local)
- local.importer = GitImporter(local)
-
- return local
-
-
-def do_capabilities(repo, args):
- """Prints the supported capabilities.
- """
-
- print "import"
- print "export"
- print "refspec refs/heads/*:%s*" % repo.prefix
-
- dirname = repo.get_base_path(repo.gitdir)
-
- if not os.path.exists(dirname):
- os.makedirs(dirname)
-
- path = os.path.join(dirname, 'git.marks')
-
- print "*export-marks %s" % path
- if os.path.exists(path):
- print "*import-marks %s" % path
-
- print # end capabilities
-
-
-def do_list(repo, args):
- """Lists all known references.
-
- Bug: This will always set the remote head to master for non-local
- repositories, since we have no way of determining what the remote
- head is at clone time.
- """
-
- for ref in repo.revs:
- debug("? refs/heads/%s", ref)
- print "? refs/heads/%s" % ref
-
- if repo.head:
- debug("@refs/heads/%s HEAD" % repo.head)
- print "@refs/heads/%s HEAD" % repo.head
- else:
- debug("@refs/heads/master HEAD")
- print "@refs/heads/master HEAD"
-
- print # end list
-
-
-def update_local_repo(repo):
- """Updates (or clones) a local repo.
- """
-
- if repo.local:
- return repo
-
- path = repo.non_local.clone(repo.gitdir)
- repo.non_local.update(repo.gitdir)
- repo = local_repo(repo, path)
- return repo
-
-
-def do_import(repo, args):
- """Exports a fast-import stream from testgit for git to import.
- """
-
- if len(args) != 1:
- die("Import needs exactly one ref")
-
- if not repo.gitdir:
- die("Need gitdir to import")
-
- ref = args[0]
- refs = [ref]
-
- while True:
- line = sys.stdin.readline()
- if line == '\n':
- break
- if not line.startswith('import '):
- die("Expected import line.")
-
- # strip of leading 'import '
- ref = line[7:].strip()
- refs.append(ref)
-
- repo = update_local_repo(repo)
- repo.exporter.export_repo(repo.gitdir, refs)
-
- print "done"
-
-
-def do_export(repo, args):
- """Imports a fast-import stream from git to testgit.
- """
-
- if not repo.gitdir:
- die("Need gitdir to export")
-
- update_local_repo(repo)
- changed = repo.importer.do_import(repo.gitdir)
-
- if not repo.local:
- repo.non_local.push(repo.gitdir)
-
- for ref in changed:
- print "ok %s" % ref
- print
-
-
-COMMANDS = {
- 'capabilities': do_capabilities,
- 'list': do_list,
- 'import': do_import,
- 'export': do_export,
-}
-
-
-def sanitize(value):
- """Cleans up the url.
- """
-
- if value.startswith('testgit::'):
- value = value[9:]
-
- return value
-
-
-def read_one_line(repo):
- """Reads and processes one command.
- """
-
- sleepy = os.environ.get("GIT_REMOTE_TESTGIT_SLEEPY")
- if sleepy:
- debug("Sleeping %d sec before readline" % int(sleepy))
- time.sleep(int(sleepy))
-
- line = sys.stdin.readline()
-
- cmdline = line
-
- if not cmdline:
- warn("Unexpected EOF")
- return False
-
- cmdline = cmdline.strip().split()
- if not cmdline:
- # Blank line means we're about to quit
- return False
-
- cmd = cmdline.pop(0)
- debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))
-
- if cmd not in COMMANDS:
- die("Unknown command, %s", cmd)
-
- func = COMMANDS[cmd]
- func(repo, cmdline)
- sys.stdout.flush()
-
- return True
-
-
-def main(args):
- """Starts a new remote helper for the specified repository.
- """
-
- if len(args) != 3:
- die("Expecting exactly three arguments.")
- sys.exit(1)
-
- if os.getenv("GIT_DEBUG_TESTGIT"):
- import git_remote_helpers.util
- git_remote_helpers.util.DEBUG = True
-
- alias = sanitize(args[1])
- url = sanitize(args[2])
-
- if not alias.isalnum():
- warn("non-alnum alias '%s'", alias)
- alias = "tmp"
-
- args[1] = alias
- args[2] = url
-
- repo = get_repo(alias, url)
-
- debug("Got arguments %s", args[1:])
-
- more = True
-
- sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)
- while (more):
- more = read_one_line(repo)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/git-remote-testpy.py b/git-remote-testpy.py
new file mode 100644
index 0000000..ade797b
--- /dev/null
+++ b/git-remote-testpy.py
@@ -0,0 +1,272 @@
+#!/usr/bin/env python
+
+# This command is a simple remote-helper, that is used both as a
+# testcase for the remote-helper functionality, and as an example to
+# show remote-helper authors one possible implementation.
+#
+# This is a Git <-> Git importer/exporter, that simply uses git
+# fast-import and git fast-export to consume and produce fast-import
+# streams.
+#
+# To understand better the way things work, one can activate debug
+# traces by setting (to any value) the environment variables
+# GIT_TRANSPORT_HELPER_DEBUG and GIT_DEBUG_TESTGIT, to see messages
+# from the transport-helper side, or from this example remote-helper.
+
+# hashlib is only available in python >= 2.5
+try:
+ import hashlib
+ _digest = hashlib.sha1
+except ImportError:
+ import sha
+ _digest = sha.new
+import sys
+import os
+import time
+sys.path.insert(0, os.getenv("GITPYTHONLIB","."))
+
+from git_remote_helpers.util import die, debug, warn
+from git_remote_helpers.git.repo import GitRepo
+from git_remote_helpers.git.exporter import GitExporter
+from git_remote_helpers.git.importer import GitImporter
+from git_remote_helpers.git.non_local import NonLocalGit
+
+def get_repo(alias, url):
+ """Returns a git repository object initialized for usage.
+ """
+
+ repo = GitRepo(url)
+ repo.get_revs()
+ repo.get_head()
+
+ hasher = _digest()
+ hasher.update(repo.path)
+ repo.hash = hasher.hexdigest()
+
+ repo.get_base_path = lambda base: os.path.join(
+ base, 'info', 'fast-import', repo.hash)
+
+ prefix = 'refs/testgit/%s/' % alias
+ debug("prefix: '%s'", prefix)
+
+ repo.gitdir = os.environ["GIT_DIR"]
+ repo.alias = alias
+ repo.prefix = prefix
+
+ repo.exporter = GitExporter(repo)
+ repo.importer = GitImporter(repo)
+ repo.non_local = NonLocalGit(repo)
+
+ return repo
+
+
+def local_repo(repo, path):
+ """Returns a git repository object initalized for usage.
+ """
+
+ local = GitRepo(path)
+
+ local.non_local = None
+ local.gitdir = repo.gitdir
+ local.alias = repo.alias
+ local.prefix = repo.prefix
+ local.hash = repo.hash
+ local.get_base_path = repo.get_base_path
+ local.exporter = GitExporter(local)
+ local.importer = GitImporter(local)
+
+ return local
+
+
+def do_capabilities(repo, args):
+ """Prints the supported capabilities.
+ """
+
+ print "import"
+ print "export"
+ print "refspec refs/heads/*:%s*" % repo.prefix
+
+ dirname = repo.get_base_path(repo.gitdir)
+
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ path = os.path.join(dirname, 'git.marks')
+
+ print "*export-marks %s" % path
+ if os.path.exists(path):
+ print "*import-marks %s" % path
+
+ print # end capabilities
+
+
+def do_list(repo, args):
+ """Lists all known references.
+
+ Bug: This will always set the remote head to master for non-local
+ repositories, since we have no way of determining what the remote
+ head is at clone time.
+ """
+
+ for ref in repo.revs:
+ debug("? refs/heads/%s", ref)
+ print "? refs/heads/%s" % ref
+
+ if repo.head:
+ debug("@refs/heads/%s HEAD" % repo.head)
+ print "@refs/heads/%s HEAD" % repo.head
+ else:
+ debug("@refs/heads/master HEAD")
+ print "@refs/heads/master HEAD"
+
+ print # end list
+
+
+def update_local_repo(repo):
+ """Updates (or clones) a local repo.
+ """
+
+ if repo.local:
+ return repo
+
+ path = repo.non_local.clone(repo.gitdir)
+ repo.non_local.update(repo.gitdir)
+ repo = local_repo(repo, path)
+ return repo
+
+
+def do_import(repo, args):
+ """Exports a fast-import stream from testgit for git to import.
+ """
+
+ if len(args) != 1:
+ die("Import needs exactly one ref")
+
+ if not repo.gitdir:
+ die("Need gitdir to import")
+
+ ref = args[0]
+ refs = [ref]
+
+ while True:
+ line = sys.stdin.readline()
+ if line == '\n':
+ break
+ if not line.startswith('import '):
+ die("Expected import line.")
+
+ # strip of leading 'import '
+ ref = line[7:].strip()
+ refs.append(ref)
+
+ repo = update_local_repo(repo)
+ repo.exporter.export_repo(repo.gitdir, refs)
+
+ print "done"
+
+
+def do_export(repo, args):
+ """Imports a fast-import stream from git to testgit.
+ """
+
+ if not repo.gitdir:
+ die("Need gitdir to export")
+
+ update_local_repo(repo)
+ changed = repo.importer.do_import(repo.gitdir)
+
+ if not repo.local:
+ repo.non_local.push(repo.gitdir)
+
+ for ref in changed:
+ print "ok %s" % ref
+ print
+
+
+COMMANDS = {
+ 'capabilities': do_capabilities,
+ 'list': do_list,
+ 'import': do_import,
+ 'export': do_export,
+}
+
+
+def sanitize(value):
+ """Cleans up the url.
+ """
+
+ if value.startswith('testgit::'):
+ value = value[9:]
+
+ return value
+
+
+def read_one_line(repo):
+ """Reads and processes one command.
+ """
+
+ sleepy = os.environ.get("GIT_REMOTE_TESTGIT_SLEEPY")
+ if sleepy:
+ debug("Sleeping %d sec before readline" % int(sleepy))
+ time.sleep(int(sleepy))
+
+ line = sys.stdin.readline()
+
+ cmdline = line
+
+ if not cmdline:
+ warn("Unexpected EOF")
+ return False
+
+ cmdline = cmdline.strip().split()
+ if not cmdline:
+ # Blank line means we're about to quit
+ return False
+
+ cmd = cmdline.pop(0)
+ debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))
+
+ if cmd not in COMMANDS:
+ die("Unknown command, %s", cmd)
+
+ func = COMMANDS[cmd]
+ func(repo, cmdline)
+ sys.stdout.flush()
+
+ return True
+
+
+def main(args):
+ """Starts a new remote helper for the specified repository.
+ """
+
+ if len(args) != 3:
+ die("Expecting exactly three arguments.")
+ sys.exit(1)
+
+ if os.getenv("GIT_DEBUG_TESTGIT"):
+ import git_remote_helpers.util
+ git_remote_helpers.util.DEBUG = True
+
+ alias = sanitize(args[1])
+ url = sanitize(args[2])
+
+ if not alias.isalnum():
+ warn("non-alnum alias '%s'", alias)
+ alias = "tmp"
+
+ args[1] = alias
+ args[2] = url
+
+ repo = get_repo(alias, url)
+
+ debug("Got arguments %s", args[1:])
+
+ more = True
+
+ sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)
+ while (more):
+ more = read_one_line(repo)
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh
deleted file mode 100755
index e7dc668..0000000
--- a/t/t5800-remote-helpers.sh
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2010 Sverre Rabbelier
-#
-
-test_description='Test remote-helper import and export commands'
-
-. ./test-lib.sh
-
-if ! test_have_prereq PYTHON ; then
- skip_all='skipping git-remote-hg tests, python not available'
- test_done
-fi
-
-"$PYTHON_PATH" -c '
-import sys
-if sys.hexversion < 0x02040000:
- sys.exit(1)
-' || {
- skip_all='skipping git-remote-hg tests, python version < 2.4'
- test_done
-}
-
-compare_refs() {
- git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
- git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
- test_cmp expect actual
-}
-
-test_expect_success 'setup repository' '
- git init --bare server/.git &&
- git clone server public &&
- (cd public &&
- echo content >file &&
- git add file &&
- git commit -m one &&
- git push origin master)
-'
-
-test_expect_success 'cloning from local repo' '
- git clone "testgit::${PWD}/server" localclone &&
- test_cmp public/file localclone/file
-'
-
-test_expect_success 'cloning from remote repo' '
- git clone "testgit::file://${PWD}/server" clone &&
- test_cmp public/file clone/file
-'
-
-test_expect_success 'create new commit on remote' '
- (cd public &&
- echo content >>file &&
- git commit -a -m two &&
- git push)
-'
-
-test_expect_success 'pulling from local repo' '
- (cd localclone && git pull) &&
- test_cmp public/file localclone/file
-'
-
-test_expect_success 'pulling from remote remote' '
- (cd clone && git pull) &&
- test_cmp public/file clone/file
-'
-
-test_expect_success 'pushing to local repo' '
- (cd localclone &&
- echo content >>file &&
- git commit -a -m three &&
- git push) &&
- compare_refs localclone HEAD server HEAD
-'
-
-# Generally, skip this test. It demonstrates a now-fixed race in
-# git-remote-testgit, but is too slow to leave in for general use.
-: test_expect_success 'racily pushing to local repo' '
- test_when_finished "rm -rf server2 localclone2" &&
- cp -R server server2 &&
- git clone "testgit::${PWD}/server2" localclone2 &&
- (cd localclone2 &&
- echo content >>file &&
- git commit -a -m three &&
- GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
- compare_refs localclone2 HEAD server2 HEAD
-'
-
-test_expect_success 'synch with changes from localclone' '
- (cd clone &&
- git pull)
-'
-
-test_expect_success 'pushing remote local repo' '
- (cd clone &&
- echo content >>file &&
- git commit -a -m four &&
- git push) &&
- compare_refs clone HEAD server HEAD
-'
-
-test_expect_success 'fetch new branch' '
- (cd public &&
- git checkout -b new &&
- echo content >>file &&
- git commit -a -m five &&
- git push origin new
- ) &&
- (cd localclone &&
- git fetch origin new
- ) &&
- compare_refs public HEAD localclone FETCH_HEAD
-'
-
-test_expect_success 'fetch multiple branches' '
- (cd localclone &&
- git fetch
- ) &&
- compare_refs server master localclone refs/remotes/origin/master &&
- compare_refs server new localclone refs/remotes/origin/new
-'
-
-test_expect_success 'push when remote has extra refs' '
- (cd clone &&
- echo content >>file &&
- git commit -a -m six &&
- git push
- ) &&
- compare_refs clone master server master
-'
-
-test_expect_success 'push new branch by name' '
- (cd clone &&
- git checkout -b new-name &&
- echo content >>file &&
- git commit -a -m seven &&
- git push origin new-name
- ) &&
- compare_refs clone HEAD server refs/heads/new-name
-'
-
-test_expect_failure 'push new branch with old:new refspec' '
- (cd clone &&
- git push origin new-name:new-refspec
- ) &&
- compare_refs clone HEAD server refs/heads/new-refspec
-'
-
-test_done
diff --git a/t/t5800-remote-testpy.sh b/t/t5800-remote-testpy.sh
new file mode 100755
index 0000000..927eef1
--- /dev/null
+++ b/t/t5800-remote-testpy.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Sverre Rabbelier
+#
+
+test_description='Test python remote-helper framework'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON ; then
+ skip_all='skipping git-remote-hg tests, python not available'
+ test_done
+fi
+
+"$PYTHON_PATH" -c '
+import sys
+if sys.hexversion < 0x02040000:
+ sys.exit(1)
+' || {
+ skip_all='skipping git-remote-hg tests, python version < 2.4'
+ test_done
+}
+
+compare_refs() {
+ git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
+ git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success 'setup repository' '
+ git init --bare server/.git &&
+ git clone server public &&
+ (cd public &&
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+ git push origin master)
+'
+
+test_expect_success 'cloning from local repo' '
+ git clone "testpy::${PWD}/server" localclone &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'cloning from remote repo' '
+ git clone "testpy::file://${PWD}/server" clone &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'create new commit on remote' '
+ (cd public &&
+ echo content >>file &&
+ git commit -a -m two &&
+ git push)
+'
+
+test_expect_success 'pulling from local repo' '
+ (cd localclone && git pull) &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'pulling from remote remote' '
+ (cd clone && git pull) &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'pushing to local repo' '
+ (cd localclone &&
+ echo content >>file &&
+ git commit -a -m three &&
+ git push) &&
+ compare_refs localclone HEAD server HEAD
+'
+
+# Generally, skip this test. It demonstrates a now-fixed race in
+# git-remote-testpy, but is too slow to leave in for general use.
+: test_expect_success 'racily pushing to local repo' '
+ test_when_finished "rm -rf server2 localclone2" &&
+ cp -R server server2 &&
+ git clone "testpy::${PWD}/server2" localclone2 &&
+ (cd localclone2 &&
+ echo content >>file &&
+ git commit -a -m three &&
+ GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
+ compare_refs localclone2 HEAD server2 HEAD
+'
+
+test_expect_success 'synch with changes from localclone' '
+ (cd clone &&
+ git pull)
+'
+
+test_expect_success 'pushing remote local repo' '
+ (cd clone &&
+ echo content >>file &&
+ git commit -a -m four &&
+ git push) &&
+ compare_refs clone HEAD server HEAD
+'
+
+test_expect_success 'fetch new branch' '
+ (cd public &&
+ git checkout -b new &&
+ echo content >>file &&
+ git commit -a -m five &&
+ git push origin new
+ ) &&
+ (cd localclone &&
+ git fetch origin new
+ ) &&
+ compare_refs public HEAD localclone FETCH_HEAD
+'
+
+test_expect_success 'fetch multiple branches' '
+ (cd localclone &&
+ git fetch
+ ) &&
+ compare_refs server master localclone refs/remotes/origin/master &&
+ compare_refs server new localclone refs/remotes/origin/new
+'
+
+test_expect_success 'push when remote has extra refs' '
+ (cd clone &&
+ echo content >>file &&
+ git commit -a -m six &&
+ git push
+ ) &&
+ compare_refs clone master server master
+'
+
+test_expect_success 'push new branch by name' '
+ (cd clone &&
+ git checkout -b new-name &&
+ echo content >>file &&
+ git commit -a -m seven &&
+ git push origin new-name
+ ) &&
+ compare_refs clone HEAD server refs/heads/new-name
+'
+
+test_expect_failure 'push new branch with old:new refspec' '
+ (cd clone &&
+ git push origin new-name:new-refspec
+ ) &&
+ compare_refs clone HEAD server refs/heads/new-refspec
+'
+
+test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (2 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 03/14] Rename git-remote-testgit to git-remote-testpy Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 13:55 ` Stefano Lattarini
2012-11-02 2:02 ` [PATCH v4 05/14] remote-testgit: get rid of non-local functionality Felipe Contreras
` (9 subsequent siblings)
13 siblings, 1 reply; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
It's way simpler. It exerceises the same features of remote helpers.
It's easy to read and understand. It doesn't depend on python.
It does _not_ exercise the python remote helper framework; there's
another tool and another test for that.
For now let's just copy the old remote-helpers test script, although
some of those tests don't make sense for this testgit (they still pass).
In addition, this script would be able to test other features not
currently being tested.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-remote-testgit.txt | 2 +-
git-remote-testgit | 62 ++++++++++++++++
t/t5801-remote-helpers.sh | 134 +++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+), 1 deletion(-)
create mode 100755 git-remote-testgit
create mode 100755 t/t5801-remote-helpers.sh
diff --git a/Documentation/git-remote-testgit.txt b/Documentation/git-remote-testgit.txt
index 2a67d45..612a625 100644
--- a/Documentation/git-remote-testgit.txt
+++ b/Documentation/git-remote-testgit.txt
@@ -19,7 +19,7 @@ testcase for the remote-helper functionality, and as an example to
show remote-helper authors one possible implementation.
The best way to learn more is to read the comments and source code in
-'git-remote-testgit.py'.
+'git-remote-testgit'.
SEE ALSO
--------
diff --git a/git-remote-testgit b/git-remote-testgit
new file mode 100755
index 0000000..6650402
--- /dev/null
+++ b/git-remote-testgit
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright (c) 2012 Felipe Contreras
+
+alias="$1"
+url="$2"
+
+# huh?
+url="${url#file://}"
+
+dir="$GIT_DIR/testgit/$alias"
+prefix="refs/testgit/$alias"
+refspec="refs/heads/*:${prefix}/heads/*"
+
+gitmarks="$dir/git.marks"
+testgitmarks="$dir/testgit.marks"
+
+export GIT_DIR="$url/.git"
+
+mkdir -p "$dir"
+
+test -e "$gitmarks" || echo -n > "$gitmarks"
+test -e "$testgitmarks" || echo -n > "$testgitmarks"
+
+while read line; do
+ case "$line" in
+ capabilities)
+ echo 'import'
+ echo 'export'
+ echo "refspec $refspec"
+ echo "*import-marks $gitmarks"
+ echo "*export-marks $gitmarks"
+ echo
+ ;;
+ list)
+ git for-each-ref --format='? %(refname)' 'refs/heads/'
+ head=$(git symbolic-ref HEAD)
+ echo "@$head HEAD"
+ echo
+ ;;
+ import*)
+ # read all import lines
+ while true; do
+ ref="${line#* }"
+ refs="$refs $ref"
+ read line
+ test "${line%% *}" != "import" && break
+ done
+
+ echo "feature import-marks=$gitmarks"
+ echo "feature export-marks=$gitmarks"
+ git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
+ sed -e "s#refs/heads/#${prefix}/heads/#g"
+ ;;
+ export)
+ git fast-import --{import,export}-marks="$testgitmarks" --quiet
+ echo
+ ;;
+ '')
+ exit
+ ;;
+ esac
+done
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
new file mode 100755
index 0000000..67bc8eb
--- /dev/null
+++ b/t/t5801-remote-helpers.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Sverre Rabbelier
+#
+
+test_description='Test remote-helper import and export commands'
+
+. ./test-lib.sh
+
+compare_refs() {
+ git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
+ git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success 'setup repository' '
+ git init --bare server/.git &&
+ git clone server public &&
+ (cd public &&
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+ git push origin master)
+'
+
+test_expect_success 'cloning from local repo' '
+ git clone "testgit::${PWD}/server" localclone &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'cloning from remote repo' '
+ git clone "testgit::file://${PWD}/server" clone &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'create new commit on remote' '
+ (cd public &&
+ echo content >>file &&
+ git commit -a -m two &&
+ git push)
+'
+
+test_expect_success 'pulling from local repo' '
+ (cd localclone && git pull) &&
+ test_cmp public/file localclone/file
+'
+
+test_expect_success 'pulling from remote remote' '
+ (cd clone && git pull) &&
+ test_cmp public/file clone/file
+'
+
+test_expect_success 'pushing to local repo' '
+ (cd localclone &&
+ echo content >>file &&
+ git commit -a -m three &&
+ git push) &&
+ compare_refs localclone HEAD server HEAD
+'
+
+# Generally, skip this test. It demonstrates a now-fixed race in
+# git-remote-testgit, but is too slow to leave in for general use.
+: test_expect_success 'racily pushing to local repo' '
+ test_when_finished "rm -rf server2 localclone2" &&
+ cp -R server server2 &&
+ git clone "testgit::${PWD}/server2" localclone2 &&
+ (cd localclone2 &&
+ echo content >>file &&
+ git commit -a -m three &&
+ GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
+ compare_refs localclone2 HEAD server2 HEAD
+'
+
+test_expect_success 'synch with changes from localclone' '
+ (cd clone &&
+ git pull)
+'
+
+test_expect_success 'pushing remote local repo' '
+ (cd clone &&
+ echo content >>file &&
+ git commit -a -m four &&
+ git push) &&
+ compare_refs clone HEAD server HEAD
+'
+
+test_expect_success 'fetch new branch' '
+ (cd public &&
+ git checkout -b new &&
+ echo content >>file &&
+ git commit -a -m five &&
+ git push origin new
+ ) &&
+ (cd localclone &&
+ git fetch origin new
+ ) &&
+ compare_refs public HEAD localclone FETCH_HEAD
+'
+
+test_expect_success 'fetch multiple branches' '
+ (cd localclone &&
+ git fetch
+ ) &&
+ compare_refs server master localclone refs/remotes/origin/master &&
+ compare_refs server new localclone refs/remotes/origin/new
+'
+
+test_expect_success 'push when remote has extra refs' '
+ (cd clone &&
+ echo content >>file &&
+ git commit -a -m six &&
+ git push
+ ) &&
+ compare_refs clone master server master
+'
+
+test_expect_success 'push new branch by name' '
+ (cd clone &&
+ git checkout -b new-name &&
+ echo content >>file &&
+ git commit -a -m seven &&
+ git push origin new-name
+ ) &&
+ compare_refs clone HEAD server refs/heads/new-name
+'
+
+test_expect_failure 'push new branch with old:new refspec' '
+ (cd clone &&
+ git push origin new-name:new-refspec
+ ) &&
+ compare_refs clone HEAD server refs/heads/new-refspec
+'
+
+test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 2:02 ` [PATCH v4 04/14] Add new simplified git-remote-testgit Felipe Contreras
@ 2012-11-02 13:55 ` Stefano Lattarini
2012-11-02 14:00 ` Jeff King
2012-11-02 15:42 ` Felipe Contreras
0 siblings, 2 replies; 26+ messages in thread
From: Stefano Lattarini @ 2012-11-02 13:55 UTC (permalink / raw)
To: Felipe Contreras
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On 11/02/2012 03:02 AM, Felipe Contreras wrote:
> It's way simpler. It exerceises the same features of remote helpers.
> It's easy to read and understand. It doesn't depend on python.
>
> It does _not_ exercise the python remote helper framework; there's
> another tool and another test for that.
>
> For now let's just copy the old remote-helpers test script, although
> some of those tests don't make sense for this testgit (they still pass).
>
> In addition, this script would be able to test other features not
> currently being tested.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> Documentation/git-remote-testgit.txt | 2 +-
> git-remote-testgit | 62 ++++++++++++++++
> t/t5801-remote-helpers.sh | 134 +++++++++++++++++++++++++++++++++++
> 3 files changed, 197 insertions(+), 1 deletion(-)
> create mode 100755 git-remote-testgit
> create mode 100755 t/t5801-remote-helpers.sh
>
> diff --git a/git-remote-testgit b/git-remote-testgit
> new file mode 100755
> index 0000000..6650402
> --- /dev/null
> +++ b/git-remote-testgit
> @@ -0,0 +1,62 @@
> +#!/bin/bash
>
I think git can't assume the existence of bash unconditionally, neither
in its scripts, nor in its tests (the exception being the tests on
bash completion, of course). This script probably need to be re-written
to be a valid POSIX shell script.
It almost is, anyway, apart from the nits below ...
> +# Copyright (c) 2012 Felipe Contreras
> +
> +alias="$1"
>
Just FYI: the double quoting here (and in several variable assignments
below) is redundant. You can portably write it as:
alias=$1
and still be safe in the face of spaces and metacharacters in $1.
I'm not sure whether the Git coding guidelines suggest the use of
quoting in this situation though; if this is the case, feel free
to disregard my observation.
> +url="$2"
> +
> +# huh?
> +url="${url#file://}"
> +
> +dir="$GIT_DIR/testgit/$alias"
> +prefix="refs/testgit/$alias"
> +refspec="refs/heads/*:${prefix}/heads/*"
> +
> +gitmarks="$dir/git.marks"
> +testgitmarks="$dir/testgit.marks"
> +
> +export GIT_DIR="$url/.git"
> +
I believe this should be rewritten as:
GIT_DIR="$url/.git"; export GIT_DIR
in order to be portable to all the POSIX shells targeted by Git.
> +mkdir -p "$dir"
> +
> +test -e "$gitmarks" || echo -n > "$gitmarks"
> +test -e "$testgitmarks" || echo -n > "$testgitmarks"
> +
The '-n' option to echo is not portable. To create an empty
file, you can just use
: > file
or
true > file
> +while read line; do
> + case "$line" in
>
Useless double quoting (my previous observation about Git coding
guidelines applies here as well, of course).
> + capabilities)
> + echo 'import'
> + echo 'export'
> + echo "refspec $refspec"
> + echo "*import-marks $gitmarks"
> + echo "*export-marks $gitmarks"
> + echo
> + ;;
> + list)
> + git for-each-ref --format='? %(refname)' 'refs/heads/'
> + head=$(git symbolic-ref HEAD)
> + echo "@$head HEAD"
> + echo
> + ;;
> + import*)
> + # read all import lines
> + while true; do
> + ref="${line#* }"
> + refs="$refs $ref"
> + read line
> + test "${line%% *}" != "import" && break
> + done
> +
> + echo "feature import-marks=$gitmarks"
> + echo "feature export-marks=$gitmarks"
> + git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
>
Better avoid the tricky {foo,bar} bashism:
git fast-export --use-done-feature \
--import-marks="$testgitmarks" \
--export-marks="$testgitmarks" \
$refs | \
> + sed -e "s#refs/heads/#${prefix}/heads/#g"
> + ;;
> + export)
> + git fast-import --{import,export}-marks="$testgitmarks" --quiet
>
Here too.
> + echo
> + ;;
> + '')
> + exit
>
I'd put an explicit exit status here, for clarity (this is a matter
of personal preference, so feel free to disregard this nit).
> + ;;
> + esac
> +done
Regards,
Stefano
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 13:55 ` Stefano Lattarini
@ 2012-11-02 14:00 ` Jeff King
2012-11-02 15:42 ` Felipe Contreras
1 sibling, 0 replies; 26+ messages in thread
From: Jeff King @ 2012-11-02 14:00 UTC (permalink / raw)
To: Stefano Lattarini
Cc: Felipe Contreras, git, Junio C Hamano, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 02, 2012 at 02:55:41PM +0100, Stefano Lattarini wrote:
> > --- /dev/null
> > +++ b/git-remote-testgit
> > @@ -0,0 +1,62 @@
> > +#!/bin/bash
> >
> I think git can't assume the existence of bash unconditionally, neither
> in its scripts, nor in its tests (the exception being the tests on
> bash completion, of course). This script probably need to be re-written
> to be a valid POSIX shell script.
No, we can't assume bash. But this is replacing a script written in
python, which we also can't assume. So if it were optional, and skipped
gracefully when bash was not available, that would be OK. Of course if
it could be done in portable bourne shell, that would be even better (I
haven't looked closely, but your comments all seem reasonable).
-Peff
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 13:55 ` Stefano Lattarini
2012-11-02 14:00 ` Jeff King
@ 2012-11-02 15:42 ` Felipe Contreras
2012-11-02 16:03 ` Stefano Lattarini
1 sibling, 1 reply; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 15:42 UTC (permalink / raw)
To: Stefano Lattarini
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 2, 2012 at 2:55 PM, Stefano Lattarini
<stefano.lattarini@gmail.com> wrote:
>> +#!/bin/bash
>>
> I think git can't assume the existence of bash unconditionally, neither
> in its scripts, nor in its tests (the exception being the tests on
> bash completion, of course). This script probably need to be re-written
> to be a valid POSIX shell script.
Well, this is a _reference_ script, and that is used only for testing
purposes. The test itself can be like the bash completion tests, and
simply be skipped.
The reason I chose bash is because associative arrays, which you see
in a later patch.
> It almost is, anyway, apart from the nits below ...
>
>> +# Copyright (c) 2012 Felipe Contreras
>> +
>> +alias="$1"
>>
> Just FYI: the double quoting here (and in several variable assignments
> below) is redundant. You can portably write it as:
>
> alias=$1
>
> and still be safe in the face of spaces and metacharacters in $1.
> I'm not sure whether the Git coding guidelines suggest the use of
> quoting in this situation though; if this is the case, feel free
> to disregard my observation.
What happens when you call this with:
./script "alias with spaces"
>> +url="$2"
>> +
>> +# huh?
>> +url="${url#file://}"
>> +
>> +dir="$GIT_DIR/testgit/$alias"
>> +prefix="refs/testgit/$alias"
>> +refspec="refs/heads/*:${prefix}/heads/*"
>> +
>> +gitmarks="$dir/git.marks"
>> +testgitmarks="$dir/testgit.marks"
>> +
>> +export GIT_DIR="$url/.git"
>> +
> I believe this should be rewritten as:
>
> GIT_DIR="$url/.git"; export GIT_DIR
>
> in order to be portable to all the POSIX shells targeted by Git.
_If_ we want this as POSIX, yeah.
>> +mkdir -p "$dir"
>> +
>> +test -e "$gitmarks" || echo -n > "$gitmarks"
>> +test -e "$testgitmarks" || echo -n > "$testgitmarks"
>> +
> The '-n' option to echo is not portable. To create an empty
> file, you can just use
>
> : > file
>
> or
>
> true > file
All right, thanks.
>> +while read line; do
>> + case "$line" in
>>
> Useless double quoting (my previous observation about Git coding
> guidelines applies here as well, of course).
What if line has multiple spaces? To me it makes sense to quote it.
>> + echo "feature import-marks=$gitmarks"
>> + echo "feature export-marks=$gitmarks"
>> + git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
>>
> Better avoid the tricky {foo,bar} bashism:
>
> git fast-export --use-done-feature \
> --import-marks="$testgitmarks" \
> --export-marks="$testgitmarks" \
> $refs | \
If that's what we want, yeah.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 15:42 ` Felipe Contreras
@ 2012-11-02 16:03 ` Stefano Lattarini
2012-11-02 16:16 ` Felipe Contreras
0 siblings, 1 reply; 26+ messages in thread
From: Stefano Lattarini @ 2012-11-02 16:03 UTC (permalink / raw)
To: Felipe Contreras
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On 11/02/2012 04:42 PM, Felipe Contreras wrote:
> On Fri, Nov 2, 2012 at 2:55 PM, Stefano Lattarini
> <stefano.lattarini@gmail.com> wrote:
>
>>> +#!/bin/bash
>>>
>> I think git can't assume the existence of bash unconditionally, neither
>> in its scripts, nor in its tests (the exception being the tests on
>> bash completion, of course). This script probably need to be re-written
>> to be a valid POSIX shell script.
>
> Well, this is a _reference_ script, and that is used only for testing
> purposes. The test itself can be like the bash completion tests, and
> simply be skipped.
>
> The reason I chose bash is because associative arrays, which you see
> in a later patch.
>
>> It almost is, anyway, apart from the nits below ...
>>
>>> +# Copyright (c) 2012 Felipe Contreras
>>> +
>>> +alias="$1"
>>>
>> Just FYI: the double quoting here (and in several variable assignments
>> below) is redundant. You can portably write it as:
>>
>> alias=$1
>>
>> and still be safe in the face of spaces and metacharacters in $1.
>> I'm not sure whether the Git coding guidelines suggest the use of
>> quoting in this situation though; if this is the case, feel free
>> to disregard my observation.
>
> What happens when you call this with:
>
> ./script "alias with spaces"
>
'$alias' will correctly expand to "alias with spaces". Try out:
$ sh -c 'alias=$1; echo "$alias"' dummy '1 2*3'
1 2*3
This works consistently with every known shell (even non-POSIX
relics like Solaris /bin/sh).
>>> +url="$2"
>>> +
>>> +# huh?
>>> +url="${url#file://}"
>>> +
>>> +dir="$GIT_DIR/testgit/$alias"
>>> +prefix="refs/testgit/$alias"
>>> +refspec="refs/heads/*:${prefix}/heads/*"
>>> +
>>> +gitmarks="$dir/git.marks"
>>> +testgitmarks="$dir/testgit.marks"
>>> +
>>> +export GIT_DIR="$url/.git"
>>> +
>> I believe this should be rewritten as:
>>
>> GIT_DIR="$url/.git"; export GIT_DIR
>>
>> in order to be portable to all the POSIX shells targeted by Git.
>
> _If_ we want this as POSIX, yeah.
>
Why don't we? Why add an extra requirement for a test that
1. can be easily written in POSIX shell, and
2. tests a feature that doesn't require bash to work (unless
I'm sorely mistaken, that is)?
Honest question. But of course, if the Git active contributors
deem the extra requirement (which is not an invasive one, given
how often bash is installed even on non-Linux systems) acceptable
in order to have the test case simpler and clearer, feel free to
disregard all my observations in this thread.
>>> +mkdir -p "$dir"
>>> +
>>> +test -e "$gitmarks" || echo -n > "$gitmarks"
>>> +test -e "$testgitmarks" || echo -n > "$testgitmarks"
>>> +
>> The '-n' option to echo is not portable. To create an empty
>> file, you can just use
>>
>> : > file
>>
>> or
>>
>> true > file
>
> All right, thanks.
>
>>> +while read line; do
>>> + case "$line" in
>>>
>> Useless double quoting (my previous observation about Git coding
>> guidelines applies here as well, of course).
>
> What if line has multiple spaces?
>
Still no problem, as in the case of the 'alias=$1' assignment before:
$ sh -c 'case $1 in *x" "x*) echo ok;; *) exit 1;; esac' dummy 'x x'
ok
> To me it makes sense to quote it.
>
Surely it doesn't cause any problem to "over-quote" in this case;
it's better than risking to under-quote in other. I just pointed
out that the quoting it's not really necessary, in case you weren't
aware of that.
>>> + echo "feature import-marks=$gitmarks"
>>> + echo "feature export-marks=$gitmarks"
>>> + git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
>>>
>> Better avoid the tricky {foo,bar} bashism:
>>
>> git fast-export --use-done-feature \
>> --import-marks="$testgitmarks" \
>> --export-marks="$testgitmarks" \
>> $refs | \
>
> If that's what we want, yeah.
>
Honestly, I find my longer-and-more-explicit version clearer, even
if you can assume bash for your script. But that's a matter of
personal preference (sorry for not stating that right away), so
feel free to ignore it if you decide to keep the bash requirement
in the end.
Regards,
Stefano
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 04/14] Add new simplified git-remote-testgit
2012-11-02 16:03 ` Stefano Lattarini
@ 2012-11-02 16:16 ` Felipe Contreras
0 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 16:16 UTC (permalink / raw)
To: Stefano Lattarini
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 2, 2012 at 5:03 PM, Stefano Lattarini
<stefano.lattarini@gmail.com> wrote:
> On 11/02/2012 04:42 PM, Felipe Contreras wrote:
>> What happens when you call this with:
>>
>> ./script "alias with spaces"
>>
> '$alias' will correctly expand to "alias with spaces". Try out:
>
> $ sh -c 'alias=$1; echo "$alias"' dummy '1 2*3'
> 1 2*3
>
> This works consistently with every known shell (even non-POSIX
> relics like Solaris /bin/sh).
All right.
>> _If_ we want this as POSIX, yeah.
>>
> Why don't we? Why add an extra requirement for a test that
>
> 1. can be easily written in POSIX shell, and
> 2. tests a feature that doesn't require bash to work (unless
> I'm sorely mistaken, that is)?
>
> Honest question. But of course, if the Git active contributors
> deem the extra requirement (which is not an invasive one, given
> how often bash is installed even on non-Linux systems) acceptable
> in order to have the test case simpler and clearer, feel free to
> disregard all my observations in this thread.
Because the code will be more complicated. Most of the changes
required are relatively small, so it's not a big issue, but I would
like to see how you replace the code that uses associative arrays. I
don't know know of a clean, simple way to do it in POSIX. If you can
find one, I don't see any strong reason to use bash.
>>>> +while read line; do
>>>> + case "$line" in
>>>>
>>> Useless double quoting (my previous observation about Git coding
>>> guidelines applies here as well, of course).
>>
>> What if line has multiple spaces?
>>
> Still no problem, as in the case of the 'alias=$1' assignment before:
>
> $ sh -c 'case $1 in *x" "x*) echo ok;; *) exit 1;; esac' dummy 'x x'
> ok
All right.
>>>> + echo "feature import-marks=$gitmarks"
>>>> + echo "feature export-marks=$gitmarks"
>>>> + git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
>>>>
>>> Better avoid the tricky {foo,bar} bashism:
>>>
>>> git fast-export --use-done-feature \
>>> --import-marks="$testgitmarks" \
>>> --export-marks="$testgitmarks" \
>>> $refs | \
>>
>> If that's what we want, yeah.
>>
> Honestly, I find my longer-and-more-explicit version clearer, even
> if you can assume bash for your script. But that's a matter of
> personal preference (sorry for not stating that right away), so
> feel free to ignore it if you decide to keep the bash requirement
> in the end.
And I prefer the other form. I fact, I would prefer if both tools
simply had a --marks option set both, and didn't require the file to
be created beforehand. I've _never_ seen a situation where separate
marks for import and export made sense. But that's off-topic.
If you find a way to replace the associative arrays code, I have no
trouble in switching this to the POSIX version.
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v4 05/14] remote-testgit: get rid of non-local functionality
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (3 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 04/14] Add new simplified git-remote-testgit Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 06/14] remote-testgit: remove irrelevant test Felipe Contreras
` (8 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
This only makes sense for the python remote helpers framework.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
git-remote-testgit | 3 ---
t/t5801-remote-helpers.sh | 46 +++++++++++++++++-----------------------------
2 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/git-remote-testgit b/git-remote-testgit
index 6650402..b9810fd 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -4,9 +4,6 @@
alias="$1"
url="$2"
-# huh?
-url="${url#file://}"
-
dir="$GIT_DIR/testgit/$alias"
prefix="refs/testgit/$alias"
refspec="refs/heads/*:${prefix}/heads/*"
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 67bc8eb..2eca42e 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -28,11 +28,6 @@ test_expect_success 'cloning from local repo' '
test_cmp public/file localclone/file
'
-test_expect_success 'cloning from remote repo' '
- git clone "testgit::file://${PWD}/server" clone &&
- test_cmp public/file clone/file
-'
-
test_expect_success 'create new commit on remote' '
(cd public &&
echo content >>file &&
@@ -45,11 +40,6 @@ test_expect_success 'pulling from local repo' '
test_cmp public/file localclone/file
'
-test_expect_success 'pulling from remote remote' '
- (cd clone && git pull) &&
- test_cmp public/file clone/file
-'
-
test_expect_success 'pushing to local repo' '
(cd localclone &&
echo content >>file &&
@@ -71,19 +61,6 @@ test_expect_success 'pushing to local repo' '
compare_refs localclone2 HEAD server2 HEAD
'
-test_expect_success 'synch with changes from localclone' '
- (cd clone &&
- git pull)
-'
-
-test_expect_success 'pushing remote local repo' '
- (cd clone &&
- echo content >>file &&
- git commit -a -m four &&
- git push) &&
- compare_refs clone HEAD server HEAD
-'
-
test_expect_success 'fetch new branch' '
(cd public &&
git checkout -b new &&
@@ -97,6 +74,16 @@ test_expect_success 'fetch new branch' '
compare_refs public HEAD localclone FETCH_HEAD
'
+test_expect_success 'bump commit in public' '
+ (cd public &&
+ git checkout master &&
+ git pull &&
+ echo content >>file &&
+ git commit -a -m four &&
+ git push) &&
+ compare_refs public HEAD server HEAD
+'
+
test_expect_success 'fetch multiple branches' '
(cd localclone &&
git fetch
@@ -106,29 +93,30 @@ test_expect_success 'fetch multiple branches' '
'
test_expect_success 'push when remote has extra refs' '
- (cd clone &&
+ (cd localclone &&
+ git reset --hard origin/master &&
echo content >>file &&
git commit -a -m six &&
git push
) &&
- compare_refs clone master server master
+ compare_refs localclone master server master
'
test_expect_success 'push new branch by name' '
- (cd clone &&
+ (cd localclone &&
git checkout -b new-name &&
echo content >>file &&
git commit -a -m seven &&
git push origin new-name
) &&
- compare_refs clone HEAD server refs/heads/new-name
+ compare_refs localclone HEAD server refs/heads/new-name
'
test_expect_failure 'push new branch with old:new refspec' '
- (cd clone &&
+ (cd localclone &&
git push origin new-name:new-refspec
) &&
- compare_refs clone HEAD server refs/heads/new-refspec
+ compare_refs localclone HEAD server refs/heads/new-refspec
'
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 06/14] remote-testgit: remove irrelevant test
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (4 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 05/14] remote-testgit: get rid of non-local functionality Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 07/14] remote-testgit: cleanup tests Felipe Contreras
` (7 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
Only makes sense for remote-testpy.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 2eca42e..a03d087 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -48,19 +48,6 @@ test_expect_success 'pushing to local repo' '
compare_refs localclone HEAD server HEAD
'
-# Generally, skip this test. It demonstrates a now-fixed race in
-# git-remote-testgit, but is too slow to leave in for general use.
-: test_expect_success 'racily pushing to local repo' '
- test_when_finished "rm -rf server2 localclone2" &&
- cp -R server server2 &&
- git clone "testgit::${PWD}/server2" localclone2 &&
- (cd localclone2 &&
- echo content >>file &&
- git commit -a -m three &&
- GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
- compare_refs localclone2 HEAD server2 HEAD
-'
-
test_expect_success 'fetch new branch' '
(cd public &&
git checkout -b new &&
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 07/14] remote-testgit: cleanup tests
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (5 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 06/14] remote-testgit: remove irrelevant test Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 08/14] remote-testgit: exercise more features Felipe Contreras
` (6 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
We don't need a bare 'server' and an intermediary 'public'. The repos
can talk to each other directly; that's what we want to exercise.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 67 +++++++++++++++++++++++------------------------
1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index a03d087..3c4e09a 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -14,96 +14,95 @@ compare_refs() {
}
test_expect_success 'setup repository' '
- git init --bare server/.git &&
- git clone server public &&
- (cd public &&
+ git init server &&
+ (cd server &&
echo content >file &&
git add file &&
- git commit -m one &&
- git push origin master)
+ git commit -m one)
'
test_expect_success 'cloning from local repo' '
- git clone "testgit::${PWD}/server" localclone &&
- test_cmp public/file localclone/file
+ git clone "testgit::${PWD}/server" local &&
+ test_cmp server/file local/file
'
test_expect_success 'create new commit on remote' '
- (cd public &&
+ (cd server &&
echo content >>file &&
- git commit -a -m two &&
- git push)
+ git commit -a -m two)
'
test_expect_success 'pulling from local repo' '
- (cd localclone && git pull) &&
- test_cmp public/file localclone/file
+ (cd local && git pull) &&
+ test_cmp server/file local/file
'
test_expect_success 'pushing to local repo' '
- (cd localclone &&
+ (cd local &&
echo content >>file &&
git commit -a -m three &&
git push) &&
- compare_refs localclone HEAD server HEAD
+ compare_refs local HEAD server HEAD
'
test_expect_success 'fetch new branch' '
- (cd public &&
+ (cd server &&
+ git reset --hard &&
git checkout -b new &&
echo content >>file &&
- git commit -a -m five &&
- git push origin new
+ git commit -a -m five
) &&
- (cd localclone &&
+ (cd local &&
git fetch origin new
) &&
- compare_refs public HEAD localclone FETCH_HEAD
+ compare_refs server HEAD local FETCH_HEAD
'
-test_expect_success 'bump commit in public' '
- (cd public &&
+#
+# This is only needed because of a bug not detected by this script. It will be
+# fixed shortly, but for now lets not cause regressions.
+#
+test_expect_success 'bump commit in server' '
+ (cd server &&
git checkout master &&
- git pull &&
echo content >>file &&
- git commit -a -m four &&
- git push) &&
- compare_refs public HEAD server HEAD
+ git commit -a -m four) &&
+ compare_refs server HEAD server HEAD
'
test_expect_success 'fetch multiple branches' '
- (cd localclone &&
+ (cd local &&
git fetch
) &&
- compare_refs server master localclone refs/remotes/origin/master &&
- compare_refs server new localclone refs/remotes/origin/new
+ compare_refs server master local refs/remotes/origin/master &&
+ compare_refs server new local refs/remotes/origin/new
'
test_expect_success 'push when remote has extra refs' '
- (cd localclone &&
+ (cd local &&
git reset --hard origin/master &&
echo content >>file &&
git commit -a -m six &&
git push
) &&
- compare_refs localclone master server master
+ compare_refs local master server master
'
test_expect_success 'push new branch by name' '
- (cd localclone &&
+ (cd local &&
git checkout -b new-name &&
echo content >>file &&
git commit -a -m seven &&
git push origin new-name
) &&
- compare_refs localclone HEAD server refs/heads/new-name
+ compare_refs local HEAD server refs/heads/new-name
'
test_expect_failure 'push new branch with old:new refspec' '
- (cd localclone &&
+ (cd local &&
git push origin new-name:new-refspec
) &&
- compare_refs localclone HEAD server refs/heads/new-refspec
+ compare_refs local HEAD server refs/heads/new-refspec
'
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 08/14] remote-testgit: exercise more features
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (6 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 07/14] remote-testgit: cleanup tests Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 09/14] remote-testgit: report success after an import Felipe Contreras
` (5 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
Unfortunately they do not work.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
git-remote-testgit | 18 +++++++++++++----
t/t5801-remote-helpers.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 4 deletions(-)
mode change 100755 => 100644 t/t5801-remote-helpers.sh
diff --git a/git-remote-testgit b/git-remote-testgit
index b9810fd..6c348b0 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -6,24 +6,34 @@ url="$2"
dir="$GIT_DIR/testgit/$alias"
prefix="refs/testgit/$alias"
-refspec="refs/heads/*:${prefix}/heads/*"
+
+default_refspec="refs/heads/*:${prefix}/heads/*"
+
+refspec="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
gitmarks="$dir/git.marks"
testgitmarks="$dir/testgit.marks"
+test -z "$refspec" && prefix="refs"
+
export GIT_DIR="$url/.git"
mkdir -p "$dir"
-test -e "$gitmarks" || echo -n > "$gitmarks"
-test -e "$testgitmarks" || echo -n > "$testgitmarks"
+if [ -z "$GIT_REMOTE_TESTGIT_NO_MARKS" ]; then
+ test -e "$gitmarks" || echo -n > "$gitmarks"
+ test -e "$testgitmarks" || echo -n > "$testgitmarks"
+else
+ echo -n > "$gitmarks"
+ echo -n > "$testgitmarks"
+fi
while read line; do
case "$line" in
capabilities)
echo 'import'
echo 'export'
- echo "refspec $refspec"
+ test -n "$refspec" && echo "refspec $refspec"
echo "*import-marks $gitmarks"
echo "*export-marks $gitmarks"
echo
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
old mode 100755
new mode 100644
index 3c4e09a..83561f8
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -105,4 +105,53 @@ test_expect_failure 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
+test_expect_failure 'cloning without refspec' '
+ GIT_REMOTE_TESTGIT_REFSPEC="" \
+ git clone "testgit::${PWD}/server" local2 &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pulling without refspecs' '
+ (cd local2 &&
+ git reset --hard &&
+ GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing without refspecs' '
+ (cd local2 &&
+ echo content >>file &&
+ git commit -a -m three &&
+ GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pulling with straight refspec' '
+ (cd local2 &&
+ GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing with straight refspec' '
+ (cd local2 &&
+ echo content >>file &&
+ git commit -a -m three &&
+ GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pulling without marks' '
+ (cd local2 &&
+ GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
+ compare_refs local2 HEAD server HEAD
+'
+
+test_expect_failure 'pushing without marks' '
+ (cd local2 &&
+ echo content >>file &&
+ git commit -a -m three &&
+ GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
+ compare_refs local2 HEAD server HEAD
+'
+
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (7 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 08/14] remote-testgit: exercise more features Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 13:58 ` Stefano Lattarini
2012-11-02 2:02 ` [PATCH v4 10/14] remote-testgit: make clear the 'done' feature Felipe Contreras
` (4 subsequent siblings)
13 siblings, 1 reply; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
Doesn't make a difference for the tests, but it does for the ones
seeking reference.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
git-remote-testgit | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/git-remote-testgit b/git-remote-testgit
index 6c348b0..4e8b356 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -59,7 +59,18 @@ while read line; do
sed -e "s#refs/heads/#${prefix}/heads/#g"
;;
export)
+ declare -A before after
+
+ eval $(git for-each-ref --format='before[%(refname)]=%(objectname)')
+
git fast-import --{import,export}-marks="$testgitmarks" --quiet
+
+ eval $(git for-each-ref --format='after[%(refname)]=%(objectname)')
+
+ for ref in "${!after[@]}"; do
+ test "${before[$ref]}" == "${after[$ref]}" && continue
+ echo "ok $ref"
+ done
echo
;;
'')
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 2:02 ` [PATCH v4 09/14] remote-testgit: report success after an import Felipe Contreras
@ 2012-11-02 13:58 ` Stefano Lattarini
2012-11-02 15:46 ` Felipe Contreras
0 siblings, 1 reply; 26+ messages in thread
From: Stefano Lattarini @ 2012-11-02 13:58 UTC (permalink / raw)
To: Felipe Contreras
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On 11/02/2012 03:02 AM, Felipe Contreras wrote:
> Doesn't make a difference for the tests, but it does for the ones
> seeking reference.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> git-remote-testgit | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/git-remote-testgit b/git-remote-testgit
> index 6c348b0..4e8b356 100755
> --- a/git-remote-testgit
> +++ b/git-remote-testgit
> @@ -59,7 +59,18 @@ while read line; do
> sed -e "s#refs/heads/#${prefix}/heads/#g"
> ;;
> export)
> + declare -A before after
> +
If you convert this script to be a valid POSIX shell script (as I've
suggested in my reply to [PATCH v4 04/14]), you'll need to get rid of
this bashism (and those below) as well.
> + eval $(git for-each-ref --format='before[%(refname)]=%(objectname)')
> +
> git fast-import --{import,export}-marks="$testgitmarks" --quiet
> +
> + eval $(git for-each-ref --format='after[%(refname)]=%(objectname)')
> +
> + for ref in "${!after[@]}"; do
> + test "${before[$ref]}" == "${after[$ref]}" && continue
> + echo "ok $ref"
> + done
> echo
> ;;
> '')
Regards,
Stefano
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 13:58 ` Stefano Lattarini
@ 2012-11-02 15:46 ` Felipe Contreras
2012-11-02 16:08 ` Stefano Lattarini
0 siblings, 1 reply; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 15:46 UTC (permalink / raw)
To: Stefano Lattarini
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 2, 2012 at 2:58 PM, Stefano Lattarini
<stefano.lattarini@gmail.com> wrote:
> On 11/02/2012 03:02 AM, Felipe Contreras wrote:
>> Doesn't make a difference for the tests, but it does for the ones
>> seeking reference.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>> git-remote-testgit | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/git-remote-testgit b/git-remote-testgit
>> index 6c348b0..4e8b356 100755
>> --- a/git-remote-testgit
>> +++ b/git-remote-testgit
>> @@ -59,7 +59,18 @@ while read line; do
>> sed -e "s#refs/heads/#${prefix}/heads/#g"
>> ;;
>> export)
>> + declare -A before after
>> +
> If you convert this script to be a valid POSIX shell script (as I've
> suggested in my reply to [PATCH v4 04/14]), you'll need to get rid of
> this bashism (and those below) as well.
Yeah, but I don't want to. I originally used transitory files, and
used esoteric options of diff to do the same (which were probably not
portable).
In the end I liked this approach much better.
If you have a solution for this that works in POSIX shell, I'll be
glad to consider it, but for the moment, I think a simple, easy to
understand and maintain code is more important, and if it needs bash,
so be it.
>> + eval $(git for-each-ref --format='before[%(refname)]=%(objectname)')
>> +
>> git fast-import --{import,export}-marks="$testgitmarks" --quiet
>> +
>> + eval $(git for-each-ref --format='after[%(refname)]=%(objectname)')
>> +
>> + for ref in "${!after[@]}"; do
>> + test "${before[$ref]}" == "${after[$ref]}" && continue
>> + echo "ok $ref"
>> + done
>> echo
>> ;;
>> '')
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 15:46 ` Felipe Contreras
@ 2012-11-02 16:08 ` Stefano Lattarini
2012-11-02 16:19 ` Felipe Contreras
0 siblings, 1 reply; 26+ messages in thread
From: Stefano Lattarini @ 2012-11-02 16:08 UTC (permalink / raw)
To: Felipe Contreras
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On 11/02/2012 04:46 PM, Felipe Contreras wrote:
>
> In the end I liked this approach much better.
>
> If you have a solution for this that works in POSIX shell, I'll be
> glad to consider it, but for the moment, I think a simple, easy to
> understand and maintain code is more important, and if it needs bash,
> so be it.
>
If this is a deliberate decision, it's ok with me. I'm just a "casual"
reviewer here, not an active contributor, so I'll gladly accept
preferences and decisions of the "active crew", once it's clear that
they are deliberate and not the result of mistakes or confusion.
In any case, I agree that having a clean, understandable code as a
starting point is better than having a more "portable" but trickier
one right away. If it will need converting to POSIX, that can be
done as a follow up (and as we've both noticed, this would be the
only point where such a conversion might be problematic -- the other
changes would be trivial, almost automatic).
Regards,
Stefano
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 16:08 ` Stefano Lattarini
@ 2012-11-02 16:19 ` Felipe Contreras
2012-11-02 16:23 ` Stefano Lattarini
2012-11-02 17:19 ` Jeff King
0 siblings, 2 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 16:19 UTC (permalink / raw)
To: Stefano Lattarini
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 2, 2012 at 5:08 PM, Stefano Lattarini
<stefano.lattarini@gmail.com> wrote:
> On 11/02/2012 04:46 PM, Felipe Contreras wrote:
>>
>> In the end I liked this approach much better.
>>
>> If you have a solution for this that works in POSIX shell, I'll be
>> glad to consider it, but for the moment, I think a simple, easy to
>> understand and maintain code is more important, and if it needs bash,
>> so be it.
>>
> If this is a deliberate decision, it's ok with me. I'm just a "casual"
> reviewer here, not an active contributor, so I'll gladly accept
> preferences and decisions of the "active crew", once it's clear that
> they are deliberate and not the result of mistakes or confusion.
>
> In any case, I agree that having a clean, understandable code as a
> starting point is better than having a more "portable" but trickier
> one right away. If it will need converting to POSIX, that can be
> done as a follow up (and as we've both noticed, this would be the
> only point where such a conversion might be problematic -- the other
> changes would be trivial, almost automatic).
As things are the options are:
1) Remove this code and move to POSIX sh. People looking for reference
might scratch their heads as to why 'git push' is not showing the
update.
2) Keep this code and remain in bash.
Until we have a:
3) Replace this code with a clean POSIX sh alternative
I would rather vote for 2)
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 16:19 ` Felipe Contreras
@ 2012-11-02 16:23 ` Stefano Lattarini
2012-11-02 17:19 ` Jeff King
1 sibling, 0 replies; 26+ messages in thread
From: Stefano Lattarini @ 2012-11-02 16:23 UTC (permalink / raw)
To: Felipe Contreras
Cc: git, Junio C Hamano, Jeff King, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On 11/02/2012 05:19 PM, Felipe Contreras wrote:
>
> [SNIP]
>
> As things are the options are:
>
> 1) Remove this code and move to POSIX sh. People looking for reference
> might scratch their heads as to why 'git push' is not showing the
> update.
> 2) Keep this code and remain in bash.
>
> Until we have a:
>
> 3) Replace this code with a clean POSIX sh alternative
>
> I would rather vote for 2)
>
That's perfectly fine with me, now that you've explained the rationale
for requiring bash in the first place (maybe adding a comment to the
script or the commit messages that reports this rationale for choosing
to require bash might be worthwhile; but it's no big deal anyway).
Thanks,
Stefano
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 09/14] remote-testgit: report success after an import
2012-11-02 16:19 ` Felipe Contreras
2012-11-02 16:23 ` Stefano Lattarini
@ 2012-11-02 17:19 ` Jeff King
1 sibling, 0 replies; 26+ messages in thread
From: Jeff King @ 2012-11-02 17:19 UTC (permalink / raw)
To: Felipe Contreras
Cc: Stefano Lattarini, git, Junio C Hamano, Johannes Schindelin,
Elijah Newren, Ilari Liusvaara, Sverre Rabbelier
On Fri, Nov 02, 2012 at 05:19:33PM +0100, Felipe Contreras wrote:
> > In any case, I agree that having a clean, understandable code as a
> > starting point is better than having a more "portable" but trickier
> > one right away. If it will need converting to POSIX, that can be
> > done as a follow up (and as we've both noticed, this would be the
> > only point where such a conversion might be problematic -- the other
> > changes would be trivial, almost automatic).
>
> As things are the options are:
>
> 1) Remove this code and move to POSIX sh. People looking for reference
> might scratch their heads as to why 'git push' is not showing the
> update.
> 2) Keep this code and remain in bash.
>
> Until we have a:
>
> 3) Replace this code with a clean POSIX sh alternative
>
> I would rather vote for 2)
I'm fine with bash. The critical thing is that it not break people's
"make test" if they do not have bash (or do not have bash as /bin/bash).
-Peff
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v4 10/14] remote-testgit: make clear the 'done' feature
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (8 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 09/14] remote-testgit: report success after an import Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 11/14] fast-export: trivial cleanup Felipe Contreras
` (3 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
People seeking for reference would find it useful.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
git-remote-testgit | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/git-remote-testgit b/git-remote-testgit
index 4e8b356..1116587 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -55,8 +55,10 @@ while read line; do
echo "feature import-marks=$gitmarks"
echo "feature export-marks=$gitmarks"
- git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | \
+ echo "feature done"
+ git fast-export --{import,export}-marks="$testgitmarks" $refs | \
sed -e "s#refs/heads/#${prefix}/heads/#g"
+ echo "done"
;;
export)
declare -A before after
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 11/14] fast-export: trivial cleanup
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (9 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 10/14] remote-testgit: make clear the 'done' feature Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 12/14] fast-export: fix comparison in tests Felipe Contreras
` (2 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
Setting 'commit' to 'commit' is a no-op. It might have been there to
avoid a compiler warning, but if so, it was the compiler to blame, and
it's certainly not there any more.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a06fe10..4f3c35f 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -483,7 +483,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
for (i = 0; i < pending->nr; i++) {
struct object_array_entry *e = pending->objects + i;
unsigned char sha1[20];
- struct commit *commit = commit;
+ struct commit *commit;
char *full_name;
if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 12/14] fast-export: fix comparison in tests
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (10 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 11/14] fast-export: trivial cleanup Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 13/14] fast-export: make sure updated refs get updated Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 14/14] fast-export: don't handle uninteresting refs Felipe Contreras
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
First the expected, then the actual, otherwise the diff would be the
opposite of what we want.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t9350-fast-export.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 0c8d828..b7d3009 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -303,7 +303,7 @@ test_expect_success 'dropping tag of filtered out object' '
(
cd limit-by-paths &&
git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
- test_cmp output expected
+ test_cmp expected output
)
'
@@ -320,7 +320,7 @@ test_expect_success 'rewriting tag of filtered out object' '
(
cd limit-by-paths &&
git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
- test_cmp output expected
+ test_cmp expected output
)
'
@@ -351,7 +351,7 @@ test_expect_failure 'no exact-ref revisions included' '
(
cd limit-by-paths &&
git fast-export master~2..master~1 > output &&
- test_cmp output expected
+ test_cmp expected output
)
'
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 13/14] fast-export: make sure updated refs get updated
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (11 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 12/14] fast-export: fix comparison in tests Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
2012-11-02 2:02 ` [PATCH v4 14/14] fast-export: don't handle uninteresting refs Felipe Contreras
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
When an object has already been exported (and thus is in the marks) it's
flagged as SHOWN, so it will not be exported again, even if in a later
time it's exported through a different ref.
We don't need the object to be exported again, but we want the ref
updated, which doesn't happen.
Since we can't know if a ref was exported or not, let's just assume that
if the commit was marked (flags & SHOWN), the user still wants the ref
updated.
IOW: If it's specified in the command line, it will get updated,
regardless of wihether or not the object was marked.
So:
% git branch test master
% git fast-export $mark_flags master
% git fast-export $mark_flags test
Would export 'test' properly.
Additionally, this fixes issues with remote helpers; now they can push
refs wich objects have already been exported, and a few other issues as
well. So update the tests accordingly.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 10 +++++++---
t/t5801-remote-helpers.sh | 24 ++++++++++--------------
t/t9350-fast-export.sh | 15 +++++++++++++++
3 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 4f3c35f..26f6d1c 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -523,10 +523,14 @@ static void get_tags_and_duplicates(struct object_array *pending,
typename(e->item->type));
continue;
}
- if (commit->util)
- /* more than one name for the same object */
+
+ /*
+ * This ref will not be updated through a commit, lets make
+ * sure it gets properly upddated eventually.
+ */
+ if (commit->util || commit->object.flags & SHOWN)
string_list_append(extra_refs, full_name)->util = commit;
- else
+ if (!commit->util)
commit->util = full_name;
}
}
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 83561f8..6e4e078 100644
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -58,18 +58,6 @@ test_expect_success 'fetch new branch' '
compare_refs server HEAD local FETCH_HEAD
'
-#
-# This is only needed because of a bug not detected by this script. It will be
-# fixed shortly, but for now lets not cause regressions.
-#
-test_expect_success 'bump commit in server' '
- (cd server &&
- git checkout master &&
- echo content >>file &&
- git commit -a -m four) &&
- compare_refs server HEAD server HEAD
-'
-
test_expect_success 'fetch multiple branches' '
(cd local &&
git fetch
@@ -105,13 +93,13 @@ test_expect_failure 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
-test_expect_failure 'cloning without refspec' '
+test_expect_success 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC="" \
git clone "testgit::${PWD}/server" local2 &&
compare_refs local2 HEAD server HEAD
'
-test_expect_failure 'pulling without refspecs' '
+test_expect_success 'pulling without refspecs' '
(cd local2 &&
git reset --hard &&
GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
@@ -154,4 +142,12 @@ test_expect_failure 'pushing without marks' '
compare_refs local2 HEAD server HEAD
'
+test_expect_success 'push ref with existing object' '
+ (cd local &&
+ git branch dup master &&
+ git push origin dup
+ ) &&
+ compare_refs local dup server dup
+'
+
test_done
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index b7d3009..67a7372 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -454,4 +454,19 @@ test_expect_success 'test biridectionality' '
git fast-import --export-marks=marks-cur --import-marks=marks-cur
'
+cat > expected << EOF
+reset refs/heads/master
+from :12
+
+EOF
+
+test_expect_success 'refs are updated even if no commits need to be exported' '
+ echo -n > tmp-marks &&
+ git fast-export --import-marks=tmp-marks \
+ --export-marks=tmp-marks master > /dev/null &&
+ git fast-export --import-marks=tmp-marks \
+ --export-marks=tmp-marks master > actual &&
+ test_cmp expected actual
+'
+
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 14/14] fast-export: don't handle uninteresting refs
2012-11-02 2:02 [PATCH v4 00/14] fast-export and remote-testgit improvements Felipe Contreras
` (12 preceding siblings ...)
2012-11-02 2:02 ` [PATCH v4 13/14] fast-export: make sure updated refs get updated Felipe Contreras
@ 2012-11-02 2:02 ` Felipe Contreras
13 siblings, 0 replies; 26+ messages in thread
From: Felipe Contreras @ 2012-11-02 2:02 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Johannes Schindelin, Elijah Newren,
Ilari Liusvaara, Sverre Rabbelier, Felipe Contreras
They have been marked as UNINTERESTING for a reason, lets respect that.
Currently the first ref is handled properly, but not the rest, so:
% git fast-export master ^master
Would currently throw a reset for master (2nd ref), which is not what we
want.
% git fast-export master ^foo ^bar ^roo
% git fast-export master salsa..tacos
Even if all these refs point to the same object; foo, bar, roo, salsa,
and tacos would all get a reset, and to a non-existing object (invalid
mark :0).
And even more, it would only happen if the ref is pointing to exactly
the same commit, but not otherwise:
% git fast-export ^next next
reset refs/heads/next
from :0
% git fast-export ^next next^{commit}
# nothing
% git fast-export ^next next~0
# nothing
% git fast-export ^next next~1
# nothing
% git fast-export ^next next~2
# nothing
The reason this happens is that before traversing the commits,
fast-export checks if any of the refs point to the same object, and any
duplicated ref gets added to a list in order to issue 'reset' commands
after the traversing. Unfortunately, it's not even checking if the
commit is flagged as UNINTERESTING. The fix of course, is to do
precisely that.
The current behavior is most certainly not what we want. After this patch,
nothing gets exported, because nothing was selected (everything is
UNINTERESTING).
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 4 +++-
t/t9350-fast-export.sh | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 26f6d1c..7a310e4 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -529,7 +529,9 @@ static void get_tags_and_duplicates(struct object_array *pending,
* sure it gets properly upddated eventually.
*/
if (commit->util || commit->object.flags & SHOWN)
- string_list_append(extra_refs, full_name)->util = commit;
+ if (!(commit->object.flags & UNINTERESTING))
+ string_list_append(extra_refs, full_name)->util = commit;
+
if (!commit->util)
commit->util = full_name;
}
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 67a7372..9b53ba7 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -469,4 +469,10 @@ test_expect_success 'refs are updated even if no commits need to be exported' '
test_cmp expected actual
'
+test_expect_success 'proper extra refs handling' '
+ git fast-export master ^master master..master > actual &&
+ echo -n > expected &&
+ test_cmp expected actual
+'
+
test_done
--
1.8.0
^ permalink raw reply related [flat|nested] 26+ messages in thread