From: Sverre Rabbelier <srabbelier@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
"Shawn O. Pearce" <spearce@spearce.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Git List <git@vger.kernel.org>,
<vcs-fast-import-devs@l
Cc: Sverre Rabbelier <srabbelier@gmail.com>,
Daniel Barkalow <barkalow@iabervon.org>
Subject: [PATCH v8 7/7] fast-import: add (non-)relative-marks feature
Date: Fri, 4 Dec 2009 18:07:00 +0100 [thread overview]
Message-ID: <1259946420-8845-8-git-send-email-srabbelier@gmail.com> (raw)
In-Reply-To: <1259946420-8845-7-git-send-email-srabbelier@gmail.com>
After specifying 'feature relative-marks' the paths specified with
'feature import-marks' and 'feature export-marks' are relative to an
internal directory in the current repository.
In git-fast-import this means that the paths are relative to the
'.git/info/fast-import' directory. However, other importers may use a
different location.
Add 'feature non-relative-marks' to disable this behavior, this way
it is possible to, for example, specify the import-marks location as
relative, and the export-marks location as non-relative.
Also add tests to verify this behavior.
Cc: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
As requested by Daniel, it is now possible to have the marks be
relative to a constant directory. We might want to consider making
this the default at some point.
This patch opens the way for remote-helpers to use the marks feature
without poluting the work tree, which I think is very important.
Documentation/git-fast-import.txt | 16 ++++++++++++++++
fast-import.c | 19 +++++++++++++++++--
t/t9300-fast-import.sh | 25 +++++++++++++++++++++++++
3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 752f85c..1a63835 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -75,6 +75,20 @@ OPTIONS
set of marks. If a mark is defined to different values,
the last file wins.
+--relative-marks::
+ After specifying --relative-marks= the paths specified
+ with --import-marks= and --export-marks= are relative
+ to an internal directory in the current repository.
+ In git-fast-import this means that the paths are relative
+ to the .git/info/fast-import directory. However, other
+ importers may use a different location.
+
+--no-relative-marks::
+ Negates a previous --relative-marks. Allows for combining
+ relative and non-relative marks by interweaving
+ --(no-)-relative-marks= with the --(import|export)-marks=
+ options.
+
--export-pack-edges=<file>::
After creating a packfile, print a line of data to
<file> listing the filename of the packfile and the last
@@ -875,6 +889,8 @@ The following features are currently supported:
* date-format
* import-marks
* export-marks
+* relative-marks
+* no-relative-marks
* force
The import-marks behaves differently from when it is specified as
diff --git a/fast-import.c b/fast-import.c
index 4c3406e..8d50a1e 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -323,6 +323,7 @@ static struct mark_set *marks;
static const char *export_marks_file;
static const char *import_marks_file;
static int import_marks_file_from_stream;
+static int relative_marks_paths;
/* Our last blob */
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
@@ -2470,6 +2471,16 @@ static void parse_progress(void)
skip_optional_lf();
}
+static char* make_fast_import_path(const char *path)
+{
+ if (!relative_marks_paths || is_absolute_path(path))
+ return xstrdup(path);
+
+ struct strbuf abs_path = STRBUF_INIT;
+ strbuf_addf(&abs_path, "%s/info/fast-import/%s", get_git_dir(), path);
+ return strbuf_detach(&abs_path, NULL);
+}
+
static void option_import_marks(const char *marks, int from_stream)
{
if (import_marks_file) {
@@ -2481,7 +2492,7 @@ static void option_import_marks(const char *marks, int from_stream)
read_marks();
}
- import_marks_file = xstrdup(marks);
+ import_marks_file = make_fast_import_path(marks);
import_marks_file_from_stream = from_stream;
}
@@ -2516,7 +2527,7 @@ static void option_active_branches(const char *branches)
static void option_export_marks(const char *marks)
{
- export_marks_file = xstrdup(marks);
+ export_marks_file = make_fast_import_path(marks);
}
static void option_export_pack_edges(const char *edges)
@@ -2557,6 +2568,10 @@ static int parse_one_feature(const char *feature, int from_stream)
option_import_marks(feature + 13, from_stream);
} else if (!prefixcmp(feature, "export-marks=")) {
option_export_marks(feature + 13);
+ } else if (!prefixcmp(feature, "relative-marks")) {
+ relative_marks_paths = 1;
+ } else if (!prefixcmp(feature, "no-relative-marks")) {
+ relative_marks_paths = 0;
} else if (!prefixcmp(feature, "force")) {
force_update = 1;
} else {
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index ba92775..a1b8c2b 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1346,6 +1346,31 @@ test_expect_success 'R: multiple --import-marks= should be honoured' '
test_cmp marks.out combined.marks
'
+cat >input <<EOF
+feature relative-marks
+feature import-marks=relative.in
+feature export-marks=relative.out
+EOF
+
+test_expect_success 'R: feature relative-marks should be honoured' '
+ mkdir -p .git/info/fast-import/ &&
+ cp marks.new .git/info/fast-import/relative.in &&
+ git fast-import <input &&
+ test_cmp marks.new .git/info/fast-import/relative.out
+'
+
+cat >input <<EOF
+feature relative-marks
+feature import-marks=relative.in
+feature no-relative-marks
+feature export-marks=non-relative.out
+EOF
+
+test_expect_success 'R: feature no-relative-marks should be honoured' '
+ git fast-import <input &&
+ test_cmp marks.new non-relative.out
+'
+
cat >input << EOF
option git quiet
blob
--
1.6.5.3.164.g07b0c
next prev parent reply other threads:[~2009-12-04 17:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 17:06 [PATCH v8 0/7] fast-import: add new feature and option command Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 1/7] fast-import: put option parsing code in separate functions Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 2/7] fast-import: put marks reading in it's own function Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 3/7] fast-import: add feature command Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 4/7] fast-import: add option command Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 5/7] fast-import: test the new " Sverre Rabbelier
2009-12-04 17:06 ` [PATCH v8 6/7] fast-import: allow for multiple --import-marks= arguments Sverre Rabbelier
2009-12-04 17:07 ` Sverre Rabbelier [this message]
2009-12-04 18:09 ` [PATCH v8 7/7] fast-import: add (non-)relative-marks feature Daniel Barkalow
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=1259946420-8845-8-git-send-email-srabbelier@gmail.com \
--to=srabbelier@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=spearce@spearce.org \
--cc=vcs-fast-import-devs@l \
/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).