* [PATCH v7 00/11] transport-helper: updates
@ 2013-11-12 20:56 Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 01/11] transport-helper: fix extra lines Felipe Contreras
` (18 more replies)
0 siblings, 19 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Hi,
Here are the patches that allow transport helpers to be completely transparent;
renaming branches, deleting them, custom refspecs, --force, --dry-run,
reporting forced update, everything works.
Changes since v6:
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 72f745d..aacd8a9 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -599,7 +599,7 @@ test_expect_success 'remote big push fetch first' '
)
'
-test_expect_failure 'remote big push force' '
+test_expect_success 'remote big push force' '
test_when_finished "rm -rf hgrepo gitrepo*" &&
setup_big_push
@@ -629,7 +629,7 @@ test_expect_failure 'remote big push force' '
check_bookmark hgrepo new_bmark six
'
-test_expect_failure 'remote big push dry-run' '
+test_expect_success 'remote big push dry-run' '
test_when_finished "rm -rf hgrepo gitrepo*" &&
setup_big_push
diff --git a/transport-helper.c b/transport-helper.c
index 2257588..7a95125 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -863,7 +863,7 @@ static int push_refs_with_export(struct transport *transport,
if (flags & TRANSPORT_PUSH_FORCE) {
if (set_helper_option(transport, "force", "true") != 0)
- die("helper %s does not support 'force'", data->name);
+ warning("helper %s does not support 'force'", data->name);
}
helper = get_helper(transport);
Felipe Contreras (10):
transport-helper: fix extra lines
transport-helper: don't update refs in dry-run
transport-helper: add 'force' to 'export' helpers
transport-helper: check for 'forced update' message
fast-export: improve argument parsing
fast-export: add new --refspec option
transport-helper: add support for old:new refspec
fast-import: add support to delete refs
fast-export: add support to delete refs
transport-helper: add support to delete branches
Richard Hansen (1):
test-hg.sh: tests are now expected to pass
Documentation/git-fast-export.txt | 4 +++
Documentation/git-fast-import.txt | 3 +++
Documentation/gitremote-helpers.txt | 4 +++
builtin/fast-export.c | 49 ++++++++++++++++++++++++++++++++++++-
contrib/remote-helpers/test-hg.sh | 4 +--
fast-import.c | 13 +++++++---
git-remote-testgit.sh | 18 ++++++++++++++
t/t5801-remote-helpers.sh | 23 ++++++++++++++++-
t/t9300-fast-import.sh | 18 ++++++++++++++
t/t9350-fast-export.sh | 18 ++++++++++++++
transport-helper.c | 47 +++++++++++++++++++++++------------
11 files changed, 179 insertions(+), 22 deletions(-)
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 01/11] transport-helper: fix extra lines
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 02/11] transport-helper: don't update refs in dry-run Felipe Contreras
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Commit 9c51558 (transport-helper: trivial code shuffle) moved these
lines above, but 99d9ec0 (Merge branch 'fc/transport-helper-no-refspec')
had a wrong merge conflict and readded them.
Reported-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
transport-helper.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index 673b7c2..b66c7fd 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -875,9 +875,6 @@ static int push_refs_with_export(struct transport *transport,
}
free(private);
- if (ref->deletion)
- die("remote-helpers do not support ref deletion");
-
if (ref->peer_ref) {
if (strcmp(ref->peer_ref->name, ref->name))
die("remote-helpers do not support old:new syntax");
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 02/11] transport-helper: don't update refs in dry-run
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 01/11] transport-helper: fix extra lines Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 03/11] transport-helper: add 'force' to 'export' helpers Felipe Contreras
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
The remote helper namespace should not be updated.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
transport-helper.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index b66c7fd..9558a0d 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -728,7 +728,8 @@ static int push_update_ref_status(struct strbuf *buf,
}
static void push_update_refs_status(struct helper_data *data,
- struct ref *remote_refs)
+ struct ref *remote_refs,
+ int flags)
{
struct strbuf buf = STRBUF_INIT;
struct ref *ref = remote_refs;
@@ -742,7 +743,7 @@ static void push_update_refs_status(struct helper_data *data,
if (push_update_ref_status(&buf, &ref, remote_refs))
continue;
- if (!data->refspecs || data->no_private_update)
+ if (flags & TRANSPORT_PUSH_DRY_RUN || !data->refspecs || data->no_private_update)
continue;
/* propagate back the update to the remote namespace */
@@ -833,7 +834,7 @@ static int push_refs_with_push(struct transport *transport,
sendline(data, &buf);
strbuf_release(&buf);
- push_update_refs_status(data, remote_refs);
+ push_update_refs_status(data, remote_refs, flags);
return 0;
}
@@ -887,7 +888,7 @@ static int push_refs_with_export(struct transport *transport,
if (finish_command(&exporter))
die("Error while running fast-export");
- push_update_refs_status(data, remote_refs);
+ push_update_refs_status(data, remote_refs, flags);
return 0;
}
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 03/11] transport-helper: add 'force' to 'export' helpers
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 01/11] transport-helper: fix extra lines Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 02/11] transport-helper: don't update refs in dry-run Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 04/11] transport-helper: check for 'forced update' message Felipe Contreras
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Otherwise they cannot know when to force the push or not (other than
hacks).
Tests-by: Richard Hansen <rhansen@bbn.com>
Documentation-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/gitremote-helpers.txt | 4 ++++
git-remote-testgit.sh | 18 ++++++++++++++++++
t/t5801-remote-helpers.sh | 13 +++++++++++++
transport-helper.c | 5 +++++
4 files changed, 40 insertions(+)
diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index f1f4ca9..e75699c 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -437,6 +437,10 @@ set by Git if the remote helper has the 'option' capability.
'option check-connectivity' \{'true'|'false'\}::
Request the helper to check connectivity of a clone.
+'option force' \{'true'|'false'\}::
+ Request the helper to perform a force update. Defaults to
+ 'false'.
+
SEE ALSO
--------
linkgit:git-remote[1]
diff --git a/git-remote-testgit.sh b/git-remote-testgit.sh
index 6d2f282..1c006a0 100755
--- a/git-remote-testgit.sh
+++ b/git-remote-testgit.sh
@@ -15,6 +15,8 @@ test -z "$refspec" && prefix="refs"
export GIT_DIR="$url/.git"
+force=
+
mkdir -p "$dir"
if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
@@ -39,6 +41,7 @@ do
fi
test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
+ echo 'option'
echo
;;
list)
@@ -93,6 +96,7 @@ do
before=$(git for-each-ref --format=' %(refname) %(objectname) ')
git fast-import \
+ ${force:+--force} \
${testgitmarks:+"--import-marks=$testgitmarks"} \
${testgitmarks:+"--export-marks=$testgitmarks"} \
--quiet
@@ -115,6 +119,20 @@ do
echo
;;
+ option\ *)
+ read cmd opt val <<-EOF
+ $line
+ EOF
+ case $opt in
+ force)
+ test $val = "true" && force="true" || force=
+ echo "ok"
+ ;;
+ *)
+ echo "unsupported"
+ ;;
+ esac
+ ;;
'')
exit
;;
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 613f69a..c33cc25 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,19 @@ test_expect_failure 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
+test_expect_success 'forced push' '
+ (cd local &&
+ git checkout -b force-test &&
+ echo content >> file &&
+ git commit -a -m eight &&
+ git push origin force-test &&
+ echo content >> file &&
+ git commit -a --amend -m eight-modified &&
+ git push --force origin force-test
+ ) &&
+ compare_refs local refs/heads/force-test server refs/heads/force-test
+'
+
test_expect_success 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC="" \
git clone "testgit::${PWD}/server" local2 2>error &&
diff --git a/transport-helper.c b/transport-helper.c
index 9558a0d..60fba99 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -855,6 +855,11 @@ static int push_refs_with_export(struct transport *transport,
die("helper %s does not support dry-run", data->name);
}
+ if (flags & TRANSPORT_PUSH_FORCE) {
+ if (set_helper_option(transport, "force", "true") != 0)
+ warning("helper %s does not support 'force'", data->name);
+ }
+
helper = get_helper(transport);
write_constant(helper->in, "export\n");
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 04/11] transport-helper: check for 'forced update' message
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (2 preceding siblings ...)
2013-11-12 20:56 ` [PATCH v7 03/11] transport-helper: add 'force' to 'export' helpers Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:56 ` [PATCH v6 05/10] fast-export: improve argument parsing Felipe Contreras
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
So the remote-helpers can tell us when a forced push was needed.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
transport-helper.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/transport-helper.c b/transport-helper.c
index 60fba99..23af747 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -644,7 +644,7 @@ static int push_update_ref_status(struct strbuf *buf,
struct ref *remote_refs)
{
char *refname, *msg;
- int status;
+ int status, forced = 0;
if (!prefixcmp(buf->buf, "ok ")) {
status = REF_STATUS_OK;
@@ -702,6 +702,11 @@ static int push_update_ref_status(struct strbuf *buf,
free(msg);
msg = NULL;
}
+ else if (!strcmp(msg, "forced update")) {
+ forced = 1;
+ free(msg);
+ msg = NULL;
+ }
}
if (*ref)
@@ -723,6 +728,7 @@ static int push_update_ref_status(struct strbuf *buf,
}
(*ref)->status = status;
+ (*ref)->forced_update = forced;
(*ref)->remote_status = msg;
return !(status == REF_STATUS_OK);
}
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 05/10] fast-export: improve argument parsing
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (3 preceding siblings ...)
2013-11-12 20:56 ` [PATCH v7 04/11] transport-helper: check for 'forced update' message Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 05/11] test-hg.sh: tests are now expected to pass Felipe Contreras
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
We don't want to pass arguments specific to fast-export to
setup_revisions.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78250ea..eea5b8c 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -701,8 +701,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
revs.topo_order = 1;
revs.show_source = 1;
revs.rewrite_parents = 1;
+ argc = parse_options(argc, argv, prefix, options, fast_export_usage,
+ PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN);
argc = setup_revisions(argc, argv, &revs, NULL);
- argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0);
if (argc > 1)
usage_with_options (fast_export_usage, options);
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 05/11] test-hg.sh: tests are now expected to pass
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (4 preceding siblings ...)
2013-11-12 20:56 ` [PATCH v6 05/10] fast-export: improve argument parsing Felipe Contreras
@ 2013-11-12 20:56 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 06/10] fast-export: add new --refspec option Felipe Contreras
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:56 UTC (permalink / raw)
To: git; +Cc: Richard Hansen
From: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Richard Hansen <rhansen@bbn.com>
---
contrib/remote-helpers/test-hg.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 72f745d..aacd8a9 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -599,7 +599,7 @@ test_expect_success 'remote big push fetch first' '
)
'
-test_expect_failure 'remote big push force' '
+test_expect_success 'remote big push force' '
test_when_finished "rm -rf hgrepo gitrepo*" &&
setup_big_push
@@ -629,7 +629,7 @@ test_expect_failure 'remote big push force' '
check_bookmark hgrepo new_bmark six
'
-test_expect_failure 'remote big push dry-run' '
+test_expect_success 'remote big push dry-run' '
test_when_finished "rm -rf hgrepo gitrepo*" &&
setup_big_push
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 06/10] fast-export: add new --refspec option
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (5 preceding siblings ...)
2013-11-12 20:56 ` [PATCH v7 05/11] test-hg.sh: tests are now expected to pass Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 06/11] fast-export: improve argument parsing Felipe Contreras
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
So that we can convert the exported ref names.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-fast-export.txt | 4 ++++
builtin/fast-export.c | 32 ++++++++++++++++++++++++++++++++
t/t9350-fast-export.sh | 7 +++++++
3 files changed, 43 insertions(+)
diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
index 85f1f30..221506b 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -105,6 +105,10 @@ marks the same across runs.
in the commit (as opposed to just listing the files which are
different from the commit's first parent).
+--refspec::
+ Apply the specified refspec to each ref exported. Multiple of them can
+ be specified.
+
[<git-rev-list-args>...]::
A list of arguments, acceptable to 'git rev-parse' and
'git rev-list', that specifies the specific objects and references
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index eea5b8c..cf745ec 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -17,6 +17,7 @@
#include "utf8.h"
#include "parse-options.h"
#include "quote.h"
+#include "remote.h"
static const char *fast_export_usage[] = {
N_("git fast-export [rev-list-opts]"),
@@ -31,6 +32,8 @@ static int use_done_feature;
static int no_data;
static int full_tree;
static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
+static struct refspec *refspecs;
+static int refspecs_nr;
static int parse_opt_signed_tag_mode(const struct option *opt,
const char *arg, int unset)
@@ -525,6 +528,15 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
continue;
+ if (refspecs) {
+ char *private;
+ private = apply_refspecs(refspecs, refspecs_nr, full_name);
+ if (private) {
+ free(full_name);
+ full_name = private;
+ }
+ }
+
commit = get_commit(e, full_name);
if (!commit) {
warning("%s: Unexpected object of type %s, skipping.",
@@ -668,6 +680,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
struct commit *commit;
char *export_filename = NULL, *import_filename = NULL;
uint32_t lastimportid;
+ struct string_list refspecs_list = STRING_LIST_INIT_NODUP;
struct option options[] = {
OPT_INTEGER(0, "progress", &progress,
N_("show progress after <n> objects")),
@@ -688,6 +701,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "use-done-feature", &use_done_feature,
N_("Use the done feature to terminate the stream")),
OPT_BOOL(0, "no-data", &no_data, N_("Skip output of blob data")),
+ OPT_STRING_LIST(0, "refspec", &refspecs_list, N_("refspec"),
+ N_("Apply refspec to exported refs")),
OPT_END()
};
@@ -707,6 +722,21 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (argc > 1)
usage_with_options (fast_export_usage, options);
+ if (refspecs_list.nr) {
+ const char **refspecs_str;
+ int i;
+
+ refspecs_str = xmalloc(sizeof(*refspecs_str) * refspecs_list.nr);
+ for (i = 0; i < refspecs_list.nr; i++)
+ refspecs_str[i] = refspecs_list.items[i].string;
+
+ refspecs_nr = refspecs_list.nr;
+ refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
+
+ string_list_clear(&refspecs_list, 1);
+ free(refspecs_str);
+ }
+
if (use_done_feature)
printf("feature done\n");
@@ -741,5 +771,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (use_done_feature)
printf("done\n");
+ free_refspec(refspecs_nr, refspecs);
+
return 0;
}
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 2312dec..3d475af 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -504,4 +504,11 @@ test_expect_success 'refs are updated even if no commits need to be exported' '
test_cmp expected actual
'
+test_expect_success 'use refspec' '
+ git fast-export --refspec refs/heads/master:refs/heads/foobar master | \
+ grep "^commit " | sort | uniq > actual &&
+ echo "commit refs/heads/foobar" > expected &&
+ test_cmp expected actual
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 06/11] fast-export: improve argument parsing
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (6 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v6 06/10] fast-export: add new --refspec option Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 07/11] fast-export: add new --refspec option Felipe Contreras
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
We don't want to pass arguments specific to fast-export to
setup_revisions.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78250ea..eea5b8c 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -701,8 +701,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
revs.topo_order = 1;
revs.show_source = 1;
revs.rewrite_parents = 1;
+ argc = parse_options(argc, argv, prefix, options, fast_export_usage,
+ PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN);
argc = setup_revisions(argc, argv, &revs, NULL);
- argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0);
if (argc > 1)
usage_with_options (fast_export_usage, options);
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 07/11] fast-export: add new --refspec option
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (7 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 06/11] fast-export: improve argument parsing Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 07/10] transport-helper: add support for old:new refspec Felipe Contreras
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
So that we can convert the exported ref names.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-fast-export.txt | 4 ++++
builtin/fast-export.c | 32 ++++++++++++++++++++++++++++++++
t/t9350-fast-export.sh | 7 +++++++
3 files changed, 43 insertions(+)
diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
index 85f1f30..221506b 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -105,6 +105,10 @@ marks the same across runs.
in the commit (as opposed to just listing the files which are
different from the commit's first parent).
+--refspec::
+ Apply the specified refspec to each ref exported. Multiple of them can
+ be specified.
+
[<git-rev-list-args>...]::
A list of arguments, acceptable to 'git rev-parse' and
'git rev-list', that specifies the specific objects and references
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index eea5b8c..cf745ec 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -17,6 +17,7 @@
#include "utf8.h"
#include "parse-options.h"
#include "quote.h"
+#include "remote.h"
static const char *fast_export_usage[] = {
N_("git fast-export [rev-list-opts]"),
@@ -31,6 +32,8 @@ static int use_done_feature;
static int no_data;
static int full_tree;
static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
+static struct refspec *refspecs;
+static int refspecs_nr;
static int parse_opt_signed_tag_mode(const struct option *opt,
const char *arg, int unset)
@@ -525,6 +528,15 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
continue;
+ if (refspecs) {
+ char *private;
+ private = apply_refspecs(refspecs, refspecs_nr, full_name);
+ if (private) {
+ free(full_name);
+ full_name = private;
+ }
+ }
+
commit = get_commit(e, full_name);
if (!commit) {
warning("%s: Unexpected object of type %s, skipping.",
@@ -668,6 +680,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
struct commit *commit;
char *export_filename = NULL, *import_filename = NULL;
uint32_t lastimportid;
+ struct string_list refspecs_list = STRING_LIST_INIT_NODUP;
struct option options[] = {
OPT_INTEGER(0, "progress", &progress,
N_("show progress after <n> objects")),
@@ -688,6 +701,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "use-done-feature", &use_done_feature,
N_("Use the done feature to terminate the stream")),
OPT_BOOL(0, "no-data", &no_data, N_("Skip output of blob data")),
+ OPT_STRING_LIST(0, "refspec", &refspecs_list, N_("refspec"),
+ N_("Apply refspec to exported refs")),
OPT_END()
};
@@ -707,6 +722,21 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (argc > 1)
usage_with_options (fast_export_usage, options);
+ if (refspecs_list.nr) {
+ const char **refspecs_str;
+ int i;
+
+ refspecs_str = xmalloc(sizeof(*refspecs_str) * refspecs_list.nr);
+ for (i = 0; i < refspecs_list.nr; i++)
+ refspecs_str[i] = refspecs_list.items[i].string;
+
+ refspecs_nr = refspecs_list.nr;
+ refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
+
+ string_list_clear(&refspecs_list, 1);
+ free(refspecs_str);
+ }
+
if (use_done_feature)
printf("feature done\n");
@@ -741,5 +771,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (use_done_feature)
printf("done\n");
+ free_refspec(refspecs_nr, refspecs);
+
return 0;
}
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 2312dec..3d475af 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -504,4 +504,11 @@ test_expect_success 'refs are updated even if no commits need to be exported' '
test_cmp expected actual
'
+test_expect_success 'use refspec' '
+ git fast-export --refspec refs/heads/master:refs/heads/foobar master | \
+ grep "^commit " | sort | uniq > actual &&
+ echo "commit refs/heads/foobar" > expected &&
+ test_cmp expected actual
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 07/10] transport-helper: add support for old:new refspec
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (8 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 07/11] fast-export: add new --refspec option Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 08/10] fast-import: add support to delete refs Felipe Contreras
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
By using fast-export's new --refspec option.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 2 +-
transport-helper.c | 13 ++++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index c33cc25..454337e 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
compare_refs local HEAD server refs/heads/new-name
'
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
(cd local &&
git push origin new-name:new-refspec
) &&
diff --git a/transport-helper.c b/transport-helper.c
index 23af747..2da4259 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -850,7 +850,7 @@ static int push_refs_with_export(struct transport *transport,
struct ref *ref;
struct child_process *helper, exporter;
struct helper_data *data = transport->data;
- struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+ struct string_list revlist_args = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
if (!data->refspecs)
@@ -888,8 +888,13 @@ static int push_refs_with_export(struct transport *transport,
free(private);
if (ref->peer_ref) {
- if (strcmp(ref->peer_ref->name, ref->name))
- die("remote-helpers do not support old:new syntax");
+ if (strcmp(ref->name, ref->peer_ref->name)) {
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ string_list_append(&revlist_args, "--refspec");
+ string_list_append(&revlist_args, buf.buf);
+ strbuf_release(&buf);
+ }
string_list_append(&revlist_args, ref->peer_ref->name);
}
}
@@ -897,6 +902,8 @@ static int push_refs_with_export(struct transport *transport,
if (get_exporter(transport, &exporter, &revlist_args))
die("Couldn't run fast-export");
+ string_list_clear(&revlist_args, 1);
+
if (finish_command(&exporter))
die("Error while running fast-export");
push_update_refs_status(data, remote_refs, flags);
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 08/10] fast-import: add support to delete refs
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (9 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v6 07/10] transport-helper: add support for old:new refspec Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 08/11] transport-helper: add support for old:new refspec Felipe Contreras
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-fast-import.txt | 3 +++
fast-import.c | 13 ++++++++++---
t/t9300-fast-import.sh | 18 ++++++++++++++++++
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 73f9806..2ffae42 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -483,6 +483,9 @@ Marks must be declared (via `mark`) before they can be used.
* Any valid Git SHA-1 expression that resolves to a commit. See
``SPECIFYING REVISIONS'' in linkgit:gitrevisions[7] for details.
+* The special null SHA-1 (40 zeros) specifies that the branch is to be
+ removed.
+
The special case of restarting an incremental import from the
current branch value should be written as:
----
diff --git a/fast-import.c b/fast-import.c
index f4d9969..fdce0b7 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -248,6 +248,7 @@ struct branch {
uintmax_t last_commit;
uintmax_t num_notes;
unsigned active : 1;
+ unsigned delete : 1;
unsigned pack_id : PACK_ID_BITS;
unsigned char sha1[20];
};
@@ -1690,10 +1691,13 @@ static int update_branch(struct branch *b)
struct ref_lock *lock;
unsigned char old_sha1[20];
- if (is_null_sha1(b->sha1))
- return 0;
if (read_ref(b->name, old_sha1))
hashclr(old_sha1);
+ if (is_null_sha1(b->sha1)) {
+ if (b->delete)
+ delete_ref(b->name, old_sha1, 0);
+ return 0;
+ }
lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
if (!lock)
return error("Unable to lock %s", b->name);
@@ -2620,8 +2624,11 @@ static int parse_from(struct branch *b)
free(buf);
} else
parse_from_existing(b);
- } else if (!get_sha1(from, b->sha1))
+ } else if (!get_sha1(from, b->sha1)) {
parse_from_existing(b);
+ if (is_null_sha1(b->sha1))
+ b->delete = 1;
+ }
else
die("Invalid ref name or SHA1 expression: %s", from);
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 27263df..5fc9ef2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2999,4 +2999,22 @@ test_expect_success 'T: ls root tree' '
test_cmp expect actual
'
+test_expect_success 'T: delete branch' '
+ git branch to-delete &&
+ git fast-import <<-EOF &&
+ reset refs/heads/to-delete
+ from 0000000000000000000000000000000000000000
+ EOF
+ test_must_fail git rev-parse --verify refs/heads/to-delete
+'
+
+test_expect_success 'T: empty reset doesnt delete branch' '
+ git branch not-to-delete &&
+ git fast-import <<-EOF &&
+ reset refs/heads/not-to-delete
+ EOF
+ git show-ref &&
+ git rev-parse --verify refs/heads/not-to-delete
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 08/11] transport-helper: add support for old:new refspec
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (10 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v6 08/10] fast-import: add support to delete refs Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 09/10] fast-export: add support to delete refs Felipe Contreras
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
By using fast-export's new --refspec option.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 2 +-
transport-helper.c | 13 ++++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index c33cc25..454337e 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
compare_refs local HEAD server refs/heads/new-name
'
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
(cd local &&
git push origin new-name:new-refspec
) &&
diff --git a/transport-helper.c b/transport-helper.c
index 23af747..2da4259 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -850,7 +850,7 @@ static int push_refs_with_export(struct transport *transport,
struct ref *ref;
struct child_process *helper, exporter;
struct helper_data *data = transport->data;
- struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+ struct string_list revlist_args = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
if (!data->refspecs)
@@ -888,8 +888,13 @@ static int push_refs_with_export(struct transport *transport,
free(private);
if (ref->peer_ref) {
- if (strcmp(ref->peer_ref->name, ref->name))
- die("remote-helpers do not support old:new syntax");
+ if (strcmp(ref->name, ref->peer_ref->name)) {
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ string_list_append(&revlist_args, "--refspec");
+ string_list_append(&revlist_args, buf.buf);
+ strbuf_release(&buf);
+ }
string_list_append(&revlist_args, ref->peer_ref->name);
}
}
@@ -897,6 +902,8 @@ static int push_refs_with_export(struct transport *transport,
if (get_exporter(transport, &exporter, &revlist_args))
die("Couldn't run fast-export");
+ string_list_clear(&revlist_args, 1);
+
if (finish_command(&exporter))
die("Error while running fast-export");
push_update_refs_status(data, remote_refs, flags);
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 09/10] fast-export: add support to delete refs
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (11 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 08/11] transport-helper: add support for old:new refspec Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 09/11] fast-import: " Felipe Contreras
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 14 ++++++++++++++
t/t9350-fast-export.sh | 11 +++++++++++
2 files changed, 25 insertions(+)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index cf745ec..4b76222 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -673,6 +673,19 @@ static void import_marks(char *input_file)
fclose(f);
}
+static void handle_deletes(void)
+{
+ int i;
+ for (i = 0; i < refspecs_nr; i++) {
+ struct refspec *refspec = &refspecs[i];
+ if (*refspec->src)
+ continue;
+
+ printf("reset %s\nfrom %s\n\n",
+ refspec->dst, sha1_to_hex(null_sha1));
+ }
+}
+
int cmd_fast_export(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -764,6 +777,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
}
handle_tags_and_duplicates();
+ handle_deletes();
if (export_filename && lastimportid != last_idnum)
export_marks(export_filename);
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 3d475af..66c8b0a 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -511,4 +511,15 @@ test_expect_success 'use refspec' '
test_cmp expected actual
'
+test_expect_success 'delete refspec' '
+ git branch to-delete &&
+ git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual &&
+ cat > expected <<-EOF &&
+ reset refs/heads/to-delete
+ from 0000000000000000000000000000000000000000
+
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 09/11] fast-import: add support to delete refs
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (12 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v6 09/10] fast-export: add support to delete refs Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 10/11] fast-export: " Felipe Contreras
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-fast-import.txt | 3 +++
fast-import.c | 13 ++++++++++---
t/t9300-fast-import.sh | 18 ++++++++++++++++++
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 73f9806..2ffae42 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -483,6 +483,9 @@ Marks must be declared (via `mark`) before they can be used.
* Any valid Git SHA-1 expression that resolves to a commit. See
``SPECIFYING REVISIONS'' in linkgit:gitrevisions[7] for details.
+* The special null SHA-1 (40 zeros) specifies that the branch is to be
+ removed.
+
The special case of restarting an incremental import from the
current branch value should be written as:
----
diff --git a/fast-import.c b/fast-import.c
index f4d9969..fdce0b7 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -248,6 +248,7 @@ struct branch {
uintmax_t last_commit;
uintmax_t num_notes;
unsigned active : 1;
+ unsigned delete : 1;
unsigned pack_id : PACK_ID_BITS;
unsigned char sha1[20];
};
@@ -1690,10 +1691,13 @@ static int update_branch(struct branch *b)
struct ref_lock *lock;
unsigned char old_sha1[20];
- if (is_null_sha1(b->sha1))
- return 0;
if (read_ref(b->name, old_sha1))
hashclr(old_sha1);
+ if (is_null_sha1(b->sha1)) {
+ if (b->delete)
+ delete_ref(b->name, old_sha1, 0);
+ return 0;
+ }
lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
if (!lock)
return error("Unable to lock %s", b->name);
@@ -2620,8 +2624,11 @@ static int parse_from(struct branch *b)
free(buf);
} else
parse_from_existing(b);
- } else if (!get_sha1(from, b->sha1))
+ } else if (!get_sha1(from, b->sha1)) {
parse_from_existing(b);
+ if (is_null_sha1(b->sha1))
+ b->delete = 1;
+ }
else
die("Invalid ref name or SHA1 expression: %s", from);
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 27263df..5fc9ef2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2999,4 +2999,22 @@ test_expect_success 'T: ls root tree' '
test_cmp expect actual
'
+test_expect_success 'T: delete branch' '
+ git branch to-delete &&
+ git fast-import <<-EOF &&
+ reset refs/heads/to-delete
+ from 0000000000000000000000000000000000000000
+ EOF
+ test_must_fail git rev-parse --verify refs/heads/to-delete
+'
+
+test_expect_success 'T: empty reset doesnt delete branch' '
+ git branch not-to-delete &&
+ git fast-import <<-EOF &&
+ reset refs/heads/not-to-delete
+ EOF
+ git show-ref &&
+ git rev-parse --verify refs/heads/not-to-delete
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 10/11] fast-export: add support to delete refs
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (13 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 09/11] fast-import: " Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 10/10] transport-helper: add support to delete branches Felipe Contreras
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/fast-export.c | 14 ++++++++++++++
t/t9350-fast-export.sh | 11 +++++++++++
2 files changed, 25 insertions(+)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index cf745ec..4b76222 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -673,6 +673,19 @@ static void import_marks(char *input_file)
fclose(f);
}
+static void handle_deletes(void)
+{
+ int i;
+ for (i = 0; i < refspecs_nr; i++) {
+ struct refspec *refspec = &refspecs[i];
+ if (*refspec->src)
+ continue;
+
+ printf("reset %s\nfrom %s\n\n",
+ refspec->dst, sha1_to_hex(null_sha1));
+ }
+}
+
int cmd_fast_export(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -764,6 +777,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
}
handle_tags_and_duplicates();
+ handle_deletes();
if (export_filename && lastimportid != last_idnum)
export_marks(export_filename);
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 3d475af..66c8b0a 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -511,4 +511,15 @@ test_expect_success 'use refspec' '
test_cmp expected actual
'
+test_expect_success 'delete refspec' '
+ git branch to-delete &&
+ git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual &&
+ cat > expected <<-EOF &&
+ reset refs/heads/to-delete
+ from 0000000000000000000000000000000000000000
+
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 10/10] transport-helper: add support to delete branches
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (14 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 10/11] fast-export: " Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 11/11] " Felipe Contreras
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
For remote-helpers that use 'export' to push.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 8 ++++++++
transport-helper.c | 11 ++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 454337e..c667965 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,14 @@ test_expect_success 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
+test_expect_success 'push delete branch' '
+ (cd local &&
+ git push origin :new-name
+ ) &&
+ test_must_fail git --git-dir="server/.git" \
+ rev-parse --verify refs/heads/new-name
+'
+
test_expect_success 'forced push' '
(cd local &&
git checkout -b force-test &&
diff --git a/transport-helper.c b/transport-helper.c
index 2da4259..7a95125 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -876,9 +876,6 @@ static int push_refs_with_export(struct transport *transport,
char *private;
unsigned char sha1[20];
- if (ref->deletion)
- die("remote-helpers do not support ref deletion");
-
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (private && !get_sha1(private, sha1)) {
strbuf_addf(&buf, "^%s", private);
@@ -890,12 +887,16 @@ static int push_refs_with_export(struct transport *transport,
if (ref->peer_ref) {
if (strcmp(ref->name, ref->peer_ref->name)) {
struct strbuf buf = STRBUF_INIT;
- strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ if (!ref->deletion)
+ strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ else
+ strbuf_addf(&buf, ":%s", ref->name);
string_list_append(&revlist_args, "--refspec");
string_list_append(&revlist_args, buf.buf);
strbuf_release(&buf);
}
- string_list_append(&revlist_args, ref->peer_ref->name);
+ if (!ref->deletion)
+ string_list_append(&revlist_args, ref->peer_ref->name);
}
}
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v7 11/11] transport-helper: add support to delete branches
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (15 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v6 10/10] transport-helper: add support to delete branches Felipe Contreras
@ 2013-11-12 20:57 ` Felipe Contreras
2013-11-12 22:24 ` [PATCH v7 00/11] transport-helper: updates Junio C Hamano
2013-11-18 5:08 ` [PATCH v3] remote-bzr: support the new 'force' option Richard Hansen
18 siblings, 0 replies; 20+ messages in thread
From: Felipe Contreras @ 2013-11-12 20:57 UTC (permalink / raw)
To: git; +Cc: Richard Hansen, Felipe Contreras
For remote-helpers that use 'export' to push.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t5801-remote-helpers.sh | 8 ++++++++
transport-helper.c | 11 ++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 454337e..c667965 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,14 @@ test_expect_success 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
+test_expect_success 'push delete branch' '
+ (cd local &&
+ git push origin :new-name
+ ) &&
+ test_must_fail git --git-dir="server/.git" \
+ rev-parse --verify refs/heads/new-name
+'
+
test_expect_success 'forced push' '
(cd local &&
git checkout -b force-test &&
diff --git a/transport-helper.c b/transport-helper.c
index 2da4259..7a95125 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -876,9 +876,6 @@ static int push_refs_with_export(struct transport *transport,
char *private;
unsigned char sha1[20];
- if (ref->deletion)
- die("remote-helpers do not support ref deletion");
-
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (private && !get_sha1(private, sha1)) {
strbuf_addf(&buf, "^%s", private);
@@ -890,12 +887,16 @@ static int push_refs_with_export(struct transport *transport,
if (ref->peer_ref) {
if (strcmp(ref->name, ref->peer_ref->name)) {
struct strbuf buf = STRBUF_INIT;
- strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ if (!ref->deletion)
+ strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+ else
+ strbuf_addf(&buf, ":%s", ref->name);
string_list_append(&revlist_args, "--refspec");
string_list_append(&revlist_args, buf.buf);
strbuf_release(&buf);
}
- string_list_append(&revlist_args, ref->peer_ref->name);
+ if (!ref->deletion)
+ string_list_append(&revlist_args, ref->peer_ref->name);
}
}
--
1.8.4.2+fc1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v7 00/11] transport-helper: updates
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (16 preceding siblings ...)
2013-11-12 20:57 ` [PATCH v7 11/11] " Felipe Contreras
@ 2013-11-12 22:24 ` Junio C Hamano
2013-11-18 5:08 ` [PATCH v3] remote-bzr: support the new 'force' option Richard Hansen
18 siblings, 0 replies; 20+ messages in thread
From: Junio C Hamano @ 2013-11-12 22:24 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git, Richard Hansen
Felipe Contreras <felipe.contreras@gmail.com> writes:
> Here are the patches that allow transport helpers to be completely transparent;
Thanks, will replace what is on 'pu'.
> Felipe Contreras (10):
> transport-helper: fix extra lines
I'll retitle this one to "mismerge fix" to make it clear where the
blame lies ;-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v3] remote-bzr: support the new 'force' option
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
` (17 preceding siblings ...)
2013-11-12 22:24 ` [PATCH v7 00/11] transport-helper: updates Junio C Hamano
@ 2013-11-18 5:08 ` Richard Hansen
18 siblings, 0 replies; 20+ messages in thread
From: Richard Hansen @ 2013-11-18 5:08 UTC (permalink / raw)
To: gitster; +Cc: git, felipe.contreras, srabbelier, Richard Hansen
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
---
This is a reroll of:
http://article.gmane.org/gmane.comp.version-control.git/237699
based on feedback from Felipe:
http://article.gmane.org/gmane.comp.version-control.git/237756
This patch is an optional extension to Felipe's "transport-helper:
updates" patch series:
http://thread.gmane.org/gmane.comp.version-control.git/237738
and it requires those changes to work.
Changes from v2:
* remove 'import types' (no longer necessary)
* change '(opt, val) = parser[1:3]' to 'opt, val = parser[1:3]'
* add 'Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>'
to commit message based on Felipe's comment in:
http://article.gmane.org/gmane.comp.version-control.git/237756
contrib/remote-helpers/git-remote-bzr | 31 ++++++++++++++++++++++++++++++-
contrib/remote-helpers/test-bzr.sh | 22 +++++++++++++++++++++-
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 7e34532..ea0e82a 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -684,7 +684,8 @@ def do_export(parser):
peer = bzrlib.branch.Branch.open(peers[name],
possible_transports=transports)
try:
- peer.bzrdir.push_branch(branch, revision_id=revid)
+ peer.bzrdir.push_branch(branch, revision_id=revid,
+ overwrite=force)
except bzrlib.errors.DivergedBranches:
print "error %s non-fast forward" % ref
continue
@@ -718,8 +719,32 @@ def do_capabilities(parser):
print "*import-marks %s" % path
print "*export-marks %s" % path
+ print "option"
print
+class InvalidOptionValue(Exception):
+ pass
+
+def get_bool_option(val):
+ if val == 'true':
+ return True
+ elif val == 'false':
+ return False
+ else:
+ raise InvalidOptionValue()
+
+def do_option(parser):
+ global force
+ opt, val = parser[1:3]
+ try:
+ if opt == 'force':
+ force = get_bool_option(val)
+ print 'ok'
+ else:
+ print 'unsupported'
+ except InvalidOptionValue:
+ print "error '%s' is not a valid value for option '%s'" % (val, opt)
+
def ref_is_valid(name):
return not True in [c in name for c in '~^: \\']
@@ -882,6 +907,7 @@ def main(args):
global is_tmp
global branches, peers
global transports
+ global force
alias = args[1]
url = args[2]
@@ -895,6 +921,7 @@ def main(args):
branches = {}
peers = {}
transports = []
+ force = False
if alias[5:] == url:
is_tmp = True
@@ -930,6 +957,8 @@ def main(args):
do_import(parser)
elif parser.check('export'):
do_export(parser)
+ elif parser.check('option'):
+ do_option(parser)
else:
die('unhandled command: %s' % line)
sys.stdout.flush()
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index 1e53ff9..4f379c2 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -66,13 +66,33 @@ test_expect_success 'pushing' '
test_cmp expected actual
'
+test_expect_success 'forced pushing' '
+ (
+ cd gitrepo &&
+ echo three-new >content &&
+ git commit -a --amend -m three-new &&
+ git push -f
+ ) &&
+
+ (
+ cd bzrrepo &&
+ # the forced update overwrites the bzr branch but not the bzr
+ # working directory (it tries to merge instead)
+ bzr revert
+ ) &&
+
+ echo three-new >expected &&
+ cat bzrrepo/content >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'roundtrip' '
(
cd gitrepo &&
git pull &&
git log --format="%s" -1 origin/master >actual
) &&
- echo three >expected &&
+ echo three-new >expected &&
test_cmp expected actual &&
(cd gitrepo && git push && git pull) &&
--
1.8.5.rc2.10.g50cf47a
^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2013-11-18 5:09 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12 20:56 [PATCH v7 00/11] transport-helper: updates Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 01/11] transport-helper: fix extra lines Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 02/11] transport-helper: don't update refs in dry-run Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 03/11] transport-helper: add 'force' to 'export' helpers Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 04/11] transport-helper: check for 'forced update' message Felipe Contreras
2013-11-12 20:56 ` [PATCH v6 05/10] fast-export: improve argument parsing Felipe Contreras
2013-11-12 20:56 ` [PATCH v7 05/11] test-hg.sh: tests are now expected to pass Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 06/10] fast-export: add new --refspec option Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 06/11] fast-export: improve argument parsing Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 07/11] fast-export: add new --refspec option Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 07/10] transport-helper: add support for old:new refspec Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 08/10] fast-import: add support to delete refs Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 08/11] transport-helper: add support for old:new refspec Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 09/10] fast-export: add support to delete refs Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 09/11] fast-import: " Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 10/11] fast-export: " Felipe Contreras
2013-11-12 20:57 ` [PATCH v6 10/10] transport-helper: add support to delete branches Felipe Contreras
2013-11-12 20:57 ` [PATCH v7 11/11] " Felipe Contreras
2013-11-12 22:24 ` [PATCH v7 00/11] transport-helper: updates Junio C Hamano
2013-11-18 5:08 ` [PATCH v3] remote-bzr: support the new 'force' option Richard Hansen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.