From: Sverre Rabbelier <srabbelier@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>, Jeff King <peff@peff.net>,
Git List <git@vger.kernel.org>,
Daniel Barkalow <barkalow@iabervon.org>,
Ramkumar
Cc: Sverre Rabbelier <srabbelier@gmail.com>
Subject: [PATCH 5/5] setup_revisions: remember whether a ref was positive or not
Date: Sun, 24 Jul 2011 16:21:22 +0200 [thread overview]
Message-ID: <1311517282-24831-6-git-send-email-srabbelier@gmail.com> (raw)
In-Reply-To: <1311517282-24831-1-git-send-email-srabbelier@gmail.com>
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
This will be required by fast-export, when no commits were
exported, but the refs should be set, of course.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
And then finally, the fix. Thanks for reading.
builtin/fast-export.c | 36 +++++++++++++++++++++++++++++++-----
t/t9350-fast-export.sh | 2 +-
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 628eab0..9c24f4e 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -17,6 +17,8 @@
#include "utf8.h"
#include "parse-options.h"
+#define REF_HANDLED (ALL_REV_FLAGS + 1)
+
static const char *fast_export_usage[] = {
"git fast-export [rev-list-opts]",
NULL
@@ -456,6 +458,7 @@ static void handle_tag(const char *name, struct tag *tag)
}
static void get_tags_and_duplicates(struct object_array *pending,
+ struct string_list *refs,
struct string_list *extra_refs)
{
struct tag *tag;
@@ -507,8 +510,11 @@ static void get_tags_and_duplicates(struct object_array *pending,
if (commit->util)
/* more than one name for the same object */
string_list_append(extra_refs, full_name)->util = commit;
- else
+ else {
commit->util = full_name;
+ /* we might need to set this ref explicitly */
+ string_list_append(refs, full_name)->util = commit;
+ }
}
}
@@ -524,10 +530,29 @@ static void handle_reset(const char *name, struct object *object)
sha1_to_hex(object->sha1));
}
-static void handle_tags_and_duplicates(struct string_list *extra_refs)
+static void handle_tags_and_duplicates(struct string_list *refs, struct string_list *extra_refs)
{
int i;
+ /* even if no commits were exported, we need to export the ref */
+ for (i = refs->nr - 1; i >= 0; i--) {
+ const char *name = refs->items[i].string;
+ struct object *object = refs->items[i].util;
+
+ if (!(object->flags & REF_HANDLED)) {
+ if (object->type & OBJ_TAG)
+ handle_tag(name, (struct tag *)object);
+ else {
+ if (!prefixcmp(name, "refs/tags/") &&
+ (tag_of_filtered_mode != REWRITE ||
+ !get_object_mark(object)))
+ continue;
+ handle_reset(name, object);
+ object->flags |= REF_HANDLED;
+ }
+ }
+ }
+
for (i = extra_refs->nr - 1; i >= 0; i--) {
const char *name = extra_refs->items[i].string;
struct object *object = extra_refs->items[i].util;
@@ -617,7 +642,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
struct object_array commits = OBJECT_ARRAY_INIT;
- struct string_list extra_refs = STRING_LIST_INIT_NODUP;
+ struct string_list refs = STRING_LIST_INIT_NODUP, extra_refs = STRING_LIST_INIT_NODUP;
struct commit *commit;
char *export_filename = NULL, *import_filename = NULL;
struct option options[] = {
@@ -669,7 +694,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (import_filename && revs.prune_data.nr)
full_tree = 1;
- get_tags_and_duplicates(&revs.pending, &extra_refs);
+ get_tags_and_duplicates(&revs.pending, &refs, &extra_refs);
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
@@ -681,11 +706,12 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
}
else {
handle_commit(commit, &revs);
+ commit->object.flags |= REF_HANDLED;
handle_tail(&commits, &revs);
}
}
- handle_tags_and_duplicates(&extra_refs);
+ handle_tags_and_duplicates(&refs, &extra_refs);
if (export_filename)
export_marks(export_filename);
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index ed0417a..d2d7ef8 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -420,7 +420,7 @@ from $(git rev-parse master)
EOF
-test_expect_failure 'refs are updated even if no commits need to be exported' '
+test_expect_success 'refs are updated even if no commits need to be exported' '
git fast-export master..master > actual &&
test_cmp expected actual
'
--
1.7.6.385.g91185.dirty
prev parent reply other threads:[~2011-07-24 14:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-24 14:21 [PATCH 0/5] fast-export: prepare for remote helpers awesomeness Sverre Rabbelier
2011-07-24 14:21 ` [PATCH 1/5] t9350: point out that refs are not updated correctly Sverre Rabbelier
2011-07-24 14:21 ` [PATCH 2/5] fast-export: do not refer to non-existing marks Sverre Rabbelier
2011-07-24 14:21 ` [PATCH 3/5] setup_revisions: remember whether a ref was positive or not Sverre Rabbelier
2011-07-24 19:23 ` Junio C Hamano
2011-07-24 23:17 ` Junio C Hamano
2011-08-03 13:52 ` Sverre Rabbelier
2011-08-03 18:12 ` Junio C Hamano
2011-08-08 16:22 ` Johannes Schindelin
2011-08-08 17:47 ` Junio C Hamano
2011-08-08 21:27 ` Sverre Rabbelier
2011-08-08 22:07 ` Junio C Hamano
2011-08-08 22:30 ` Sverre Rabbelier
2011-08-08 22:36 ` Junio C Hamano
2011-08-08 22:38 ` Sverre Rabbelier
2011-08-08 22:46 ` Junio C Hamano
2011-08-08 22:48 ` Sverre Rabbelier
2011-08-08 23:17 ` Junio C Hamano
2011-08-08 23:25 ` Sverre Rabbelier
2011-08-08 23:39 ` Junio C Hamano
2011-08-08 22:24 ` Junio C Hamano
2011-08-08 22:28 ` Sverre Rabbelier
2011-08-08 22:56 ` Junio C Hamano
2011-08-08 23:04 ` Sverre Rabbelier
2011-07-26 15:16 ` Johannes Schindelin
2011-07-24 14:21 ` [PATCH 4/5] fast-export: do not export negative refs Sverre Rabbelier
2011-07-24 19:07 ` Junio C Hamano
2011-07-26 15:11 ` Johannes Schindelin
2011-07-24 14:21 ` Sverre Rabbelier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311517282-24831-6-git-send-email-srabbelier@gmail.com \
--to=srabbelier@gmail.com \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).