* Re: Using git to track my PhD thesis, couple of questions
From: Matthieu Moy @ 2009-08-27 20:55 UTC (permalink / raw)
To: seanh; +Cc: git
In-Reply-To: <20090827203402.GC7168@kisimul>
seanh <seanh.nospam@gmail.com> writes:
> I'm planning to use git to track my PhD thesis as I work on it and to
> let my supervisors track it. I've setup a git repository and a gitweb
> instance showing it. There are a couple of specific requirements.
>
> 1. My supervisors don't want to see all the little commits that I make
> day by day.
I'm not sure I understand why you want that. From what you say, your
supervisors won't be looking at the LaTeX source, so they won't read
the diffs for the commits. Instead, they will be looking at regular
snapshots in PDF. So, how is that disturbing to keep the intermediate
commits ?
> So I'll commit to a dev branch, then whenever I've made
> significant progress will merge it into a trunk branch. I want the trunk
> branch to get all the changes but as one big commit, not inherit all the
> little commits like a normal merge would do. I think this is a `git
> merge --squash`.
It is, but this also means _you_ will somehow lose your intermediate
commits. Well, you may not really lose them, but after a merge
--squash, you have two options to continue working: work on top of the
squashed commit (and then your ancestry doesn't contain the small
ones), or work on top of your previous branches (and then, you don't
have a proper merge tracking, and you'll get spurious conflicts if you
try another merge --squash).
> 2. They don't want to look at the latex source but the PDFs built from
> it, which they're going to annotate with their comments. So I need an
> easy way for them to get the PDF of each commit from gitweb without
> having to checkout the repo and build it themselves.
Well, they never need a PDF other than the latest version, will they?
Then, you don't need Git to send them your PDFs, just upload the PDFs
somewhere where your supervisors can grab them periodically, and
you're done.
The issue is when they start modifying the LaTeX files: then you have
to think of merging, and you'd better do that with a revision control
system.
I also used a revision control system to write my Ph.D (Git was born
after I started writting, so it wasn't Git yet), and my reviewing
system has been all the more simple: when a chapter is done, send an
email with the PDF attached, and "Hi, chapter $n is done, can you have
a look?". That just works.
> Normally I wouldn't commit the PDF files into the repo because
> they're compiled files not source files, but it seems that just
> building a PDF and committing it along with each commit to trunk
> would be by far the easiest way to achieve this. But will git store
> the PDFs efficiently, or will the repo start to get really big?
Git will do delta-compression as it can, but I don't think PDFs will
delta-compress very well, so your repository may grow rather quickly,
yes. If possible, commit the PDFs on a separate branch so that you can
easily keep your clean history small in disk space, and discard the
PDFs if needed.
--
Matthieu
^ permalink raw reply
* Re: Question regarding git fetch
From: Jeff King @ 2009-08-27 20:48 UTC (permalink / raw)
To: Avery Pennarun; +Cc: Björn Steinbrink, Tom Lambda, git
In-Reply-To: <32541b130908271022i6a825198i37e2ec82ed5f833c@mail.gmail.com>
On Thu, Aug 27, 2009 at 05:22:55PM +0000, Avery Pennarun wrote:
> 2009/8/27 Björn Steinbrink <B.Steinbrink@gmx.de>:
> > It would also be pretty hard to implement that. Given the default fetch
> > refspec, it would "simply" be a matter of mapping the given ref to the
> > refspec, so e.g. "foo" becomes "refs/heads/foo:refs/remotes/origin/foo".
> > But even just using "git remote add -t master foo git://..." breaks
> > that, as the fetch refspec in the config will no longer be a glob, and
> > thus no such mapping is possible.
>
> Hmm, I don't really see why that introduces a problem. If you use -t
> to override explicitly which refs you want to save, then it's not a
> problem if git doesn't save other refs, right?
I think you can handle both cases just by matching the fetched refs to
the LHS of the refspec.
So if you fetch "refs/heads/foo", and if you have a refspec of:
refs/heads/*:refs/remotes/origin/*
then you see that the LHS glob matches, and the RHS expands to
refs/remotes/origin/foo. And if you have a more restrictive refspec,
that would work, too:
refs/heads/foo:refs/remotes/origin/foo
would still match, but
refs/heads/bar:refs/remotes/origin/bar
does not match on the LHS, so you write nothing. It would even handle
multiple refspecs properly.
And this matching is not really any different than what the fetch code
does when applying the refspec to what the remote offers. So I don't
think it should be any significant new code; it's just a matter of
activating that matching and updating the local tracking refs based on
what we actually fetched, instead of what the remote advertised.
> I'd be more concerned about the inconsistency between
>
> git fetch git://whatever master
> and
> git fetch origin master
>
> There's no really good way for the first one to know it needs to
> update any branches, even though 'origin' might be an alias for
> git://whatever. So users will still be confused.
Well, you can always reverse-lookup each remote to see if the URL
matches. Of course you would never know that "http://whatever" is an
alias for "git://whatever". Personally, I don't imagine that users
really expect git to reverse-map remotes in that way (after all, why
would they input git://whatever long-hand if they knew that it was a
remote).
> Thinking of that also reminds me of another surprise. If you do:
>
> git fetch git://whatever
>
> ...it seems to do nothing at all, as far as I can see. Which makes
> sense, I guess, since I wouldn't really expect it to be meaningful.
> But it seems to connect up to the remote server anyway just in case.
Shouldn't it fetch HEAD from the remote and store it in FETCH_HEAD? And
then tell you that it did that?
I get:
$ mkdir foo && cd foo && git init
Initialized empty Git repository in /home/peff/foo/.git/
$ git fetch ~/compile/git
remote: Counting objects: 85011, done.
remote: Compressing objects: 100% (23942/23942), done.
remote: Total 85011 (delta 61389), reused 83076 (delta 59655)
Receiving objects: 100% (85011/85011), 19.03 MiB | 11385 KiB/s, done.
Resolving deltas: 100% (61389/61389), done.
From /home/peff/compile/git
* branch HEAD -> FETCH_HEAD
$ git fetch git://git.kernel.org/pub/scm/git/git.git
From git://git.kernel.org/pub/scm/git/git
* branch HEAD -> FETCH_HEAD
-Peff
^ permalink raw reply
* Re: Using git to track my PhD thesis, couple of questions
From: Sverre Rabbelier @ 2009-08-27 20:41 UTC (permalink / raw)
To: seanh; +Cc: git
In-Reply-To: <20090827203402.GC7168@kisimul>
Heya,
On Thu, Aug 27, 2009 at 13:34, seanh<seanh.nospam@gmail.com> wrote:
> 2. They don't want to look at the latex source but the PDFs built from
> it, which they're going to annotate with their comments. So I need an
> easy way for them to get the PDF of each commit from gitweb without
> having to checkout the repo and build it themselves. Normally I
> wouldn't commit the PDF files into the repo because they're compiled
> files not source files, but it seems that just building a PDF and
> committing it along with each commit to trunk would be by far the
> easiest way to achieve this. But will git store the PDFs efficiently, or
> will the repo start to get really big?
If they only care about the pdf anyway, why not have a separate branch
to which you commit the pdf's instead?
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Using git to track my PhD thesis, couple of questions
From: seanh @ 2009-08-27 20:34 UTC (permalink / raw)
To: git
I'm planning to use git to track my PhD thesis as I work on it and to
let my supervisors track it. I've setup a git repository and a gitweb
instance showing it. There are a couple of specific requirements.
1. My supervisors don't want to see all the little commits that I make
day by day. So I'll commit to a dev branch, then whenever I've made
significant progress will merge it into a trunk branch. I want the trunk
branch to get all the changes but as one big commit, not inherit all the
little commits like a normal merge would do. I think this is a `git
merge --squash`. Btw the help for that command ends quite brilliantly:
"(or more in case of an octopus)".
2. They don't want to look at the latex source but the PDFs built from
it, which they're going to annotate with their comments. So I need an
easy way for them to get the PDF of each commit from gitweb without
having to checkout the repo and build it themselves. Normally I
wouldn't commit the PDF files into the repo because they're compiled
files not source files, but it seems that just building a PDF and
committing it along with each commit to trunk would be by far the
easiest way to achieve this. But will git store the PDFs efficiently, or
will the repo start to get really big?
Thanks
^ permalink raw reply
* Re: bundles with multiple branches
From: Jeffrey Ratcliffe @ 2009-08-27 20:03 UTC (permalink / raw)
To: Adam Brewster; +Cc: git
In-Reply-To: <c376da900908241442t385d492cm6925fd2d8abad848@mail.gmail.com>
2009/8/24 Adam Brewster <adambrewster@gmail.com>:
>> fatal: '/media/cdrom': unable to chdir or not a git archive
>> fatal: The remote end hung up unexpectedly
>>
>
> Sorry, that's supposed to be /media/cdrom/name-of-bundle
Thanks.
^ permalink raw reply
* Re: What's cooking in git.git (Aug 2009, #05; Wed, 26)
From: Sverre Rabbelier @ 2009-08-27 19:48 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
In-Reply-To: <20090827001207.GS1033@spearce.org>
Heya,
On Wed, Aug 26, 2009 at 17:12, Shawn O. Pearce<spearce@spearce.org> wrote:
> RFC patch. And yes, because I think we already agreed in that
> thread that the date-format option is actually a feature command,
> and not an option command. The other feature commands being kicked
> around can be held for another series.
Done, see v5a of the series (I messed up v5).
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH v5 6/6] fast-import: test the new option command
From: Sverre Rabbelier @ 2009-08-27 19:44 UTC (permalink / raw)
To: Julian Phillips
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy, Matt McClure, Miklos Vajna
In-Reply-To: <alpine.LNX.2.00.0908271944540.6501@reaper.quantumfyre.co.uk>
Heya,
On Thu, Aug 27, 2009 at 11:46, Julian Phillips<julian@quantumfyre.co.uk> wrote:
> Don't you now need all tests of the option command to start with a "feature
> git-options" command?
Yes, that was the second reason for v5a, fixed there.
> (and perhaps have a test that the feature command is required too?)
Done.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH v5 5/6] fast-import: add option command
From: Sverre Rabbelier @ 2009-08-27 19:40 UTC (permalink / raw)
To: Julian Phillips
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy, Matt McClure, Miklos Vajna
In-Reply-To: <alpine.LNX.2.00.0908271942090.6501@reaper.quantumfyre.co.uk>
Heya,
On Thu, Aug 27, 2009 at 11:44, Julian Phillips<julian@quantumfyre.co.uk> wrote:
> On Thu, 27 Aug 2009, Sverre Rabbelier wrote:
>> +Option commands must be the first commands on the input, to give an
>> +option command after any non-option command is an error.
>
> Er ... shouldn't that be the first thing _after_ the "feature git-options"
> command?
Correct, updated the code but not the docs. Fixed.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH v5a 1/6] fast-import: put option parsing code in seperate functions
From: Sverre Rabbelier @ 2009-08-27 19:37 UTC (permalink / raw)
To: Teemu Likonen
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
In-Reply-To: <87y6p5xf5x.fsf@iki.fi>
Heya,
On Thu, Aug 27, 2009 at 11:52, Teemu Likonen<tlikonen@iki.fi> wrote:
> fast-import: put option parsing code in seperate functions
Thanks, fixed.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: git-svn intermittent issues with absent_file
From: Eric Wong @ 2009-08-27 19:19 UTC (permalink / raw)
To: Matthias Andree; +Cc: git
In-Reply-To: <op.uzbs4bsq3myrm3@balu.cs.uni-paderborn.de>
Matthias Andree <matthias.andree@uni-paderborn.de> wrote:
> Greetings,
>
> we seem to have issues with checking out files from an SVN server via
> https://. The problem is hard to reproduce, and shows as "absent_file"
> warnings, i. e. files that are in the SVN checkout don't make it to the
> Git checkin.
>
> Perhaps this rings a bell with someone or there are similar reports that
> relate to our issues...
Hi Matthias,
I don't recall any issues with the "absent_file" callback ever being
reported to me. I don't think I've ever touched a repo that triggered
it, either...
> ## ISSUE ## Once in a while, a git-svn clone or rebase fails with files
> missing from commits, as mentioned above. We haven't been able to figure
> out under what circumstances this happens. If we try to reproduce this
> (i. e. kill the directory completely and re-run the git svn clone),
> another revision (for instance 170) might show this, or the clone may
> succeed.
> This was observed with Git 1.6.0.4 under Ubuntu Linux Jaunty Jackalope
> (9.04) and on a different computer with Git 1.6.4.1.196.g31f0b (from the
> master branch) under a fully updated Cygwin 1.5.
I assume this happens with the latest git under Ubuntu Linux, too; but
can you give that a try just in case?
There have been a few odd bugs fixed since 1.6.0.4, but nothing rings a
bell here. This doesn't seem to be a Cygwin/Win32-related issue, but
I'd like to minimize the number of variables since I can't support
Cygwin/Win32 directly.
> Example log of failed data (sorry, we are not allowed to let you access
> the repository, so we must debug by proxy).
> I'm replacing substrings in the log below to maintain corporate
> confidentiality levels:
>
> $ git svn clone --no-checkout https://svnserver.example.edu/project/
> Initialized empty Git repository in /tmp/compnet/.git/
> W: +empty_dir: branches
> W: +empty_dir: tags
> W: +empty_dir: trunk
> r1 = a1b0e99e3986da4d8d461944b623b6abb2460de4 (refs/remotes/git-svn)
> ...
> r135 = 294077e62ee5f463b8ab97d961d9742ef89ae662 (refs/remotes/git-svn)
> A ... (~100 PDF files)
> ...
> A d1/u1/2009_06/f1.pdf
> W: +empty_dir: d1/u2/slides/2009_06
> W: absent_file: d1/u1/2009_06/d1/u1/2009_06/f2.pdf Insufficient
> permissions?
> W: absent_file: d1/u3/06_2009/f1/u3/2009_06/f3.pdf Insufficient
> permissions?
> W: absent_file: d1/u2/slides/2009_06/d1/u2/slides/2009_06/f4.pdf
> Insufficient permissions?
> r136 = 58523cf1fa867d33a74080dabdcbc85ae0ba99ec (refs/remotes/git-svn)
> ...
> r139 = 2fb1647bc40d3815a5eefb32d43a375e03d2e871 (refs/remotes/git-svn)
> Incomplete data: Delta source ended unexpectedly at
> /usr/local/libexec/git-core/git-svn line 4605
>
>
> Just re-running "git svn fetch" reproduces the "Incomplete data:" error
> and aborts, but re-fetching an older version succeeds. No fiddling with
> permissions needed.
>
>
> ## WORKAROUND ##
>
> If this happens, I can force a checkout with, say, "git checkout -t -b
> master remotes/git-svn", revert to the last good revision with "git svn
> reset -r135" (this doesn't work without prior checkout) and then re-run
> git svn fetch, which will usually succeed then.
>
>
> The three absent_file lines are also recorded in
> .git/svn/refs/remotes/git-svn/unhandled.log for r136.
>
>
> Questions:
>
> 1. What causes these absent_file issues? How can we assist with debugging
> this?
Permissions would be my first (and only) guess as I have no experience
with this condition...
Are you using anything weird in ~/.subversion/config by any chance?
And you're sure you're using the same user/account in all cases?
Are the files you're hitting absent_file on unusually large and
hitting some limit on the server side?
> 2. What does "Delta source ended unexpectedly" mean? (the line number is
> bogus, it's just the finish_report call)
Sometimes the server can just shut down/drop connections. Do you have
access to the server logs? How many simultaneous connections can
it accept? Which version of the Subversion server is running?
How reliable is your network connection to the server?
Anything weird with the network configuration? Mismatched MTU, odd
firewall rules, non-standard TCP stack configuration, VPN, proxies...
> 3. Is this or a similar issue known? Is this an issue with the SVN
> server, the SVN bindings, or the git svn adaptor?
The "Incomplete data: Delta source ended unexpectedly" happens
from time to time on a few odd servers, but I've never found it
reproducible and retrying "git svn fetch" always fixes it.
This is more than likely the fault of the network or server.
The "absent_file" issue I've never seen...
> 4. How can we avoid or fix this?
Other than your workaround, I don't know...
> We're happy to test patches.
Cool. I don't have any ideas for patches right now, but does this
problem happen with other SVN clients? Even svk/svm could be
worth a shot for testing...
--
Eric Won
^ permalink raw reply
* Re: [PATCH v5a 1/6] fast-import: put option parsing code in seperate functions
From: Teemu Likonen @ 2009-08-27 18:52 UTC (permalink / raw)
To: Sverre Rabbelier
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
In-Reply-To: <1251398431-12461-2-git-send-email-srabbelier@gmail.com>
On 2009-08-27 11:40 (-0700), Sverre Rabbelier wrote:
> Putting the options in their own functions increases readability of
> the option parsing block and makes it easier to reuse the option
> parsing code later on.
>
> Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Typo in the title:
fast-import: put option parsing code in seperate functions
^
"separate"
^ permalink raw reply
* Re: [PATCH v5 6/6] fast-import: test the new option command
From: Julian Phillips @ 2009-08-27 18:46 UTC (permalink / raw)
To: Sverre Rabbelier
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy, Matt McClure, Miklos Vajna, Aaron Bentley
In-Reply-To: <1251396736-928-6-git-send-email-srabbelier@gmail.com>
On Thu, 27 Aug 2009, Sverre Rabbelier wrote:
> Test three options (quiet and import/export-marks) and verify that the
> commandline options override these.
>
> Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
> ---
>
> Only difference from v4 is that it is rebased and a new test to
> verify that 'feature git-options' is now accepted.
Don't you now need all tests of the option command to start with a
"feature git-options" command? (and perhaps have a test that the feature
command is required too?)
--
Julian
---
Bubble Memory, n.:
A derogatory term, usually referring to a person's intelligence.
See also "vacuum tube".
^ permalink raw reply
* Re: [PATCH v5 5/6] fast-import: add option command
From: Julian Phillips @ 2009-08-27 18:44 UTC (permalink / raw)
To: Sverre Rabbelier
Cc: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy, Matt McClure, Miklos Vajna, Aaron Bentley
In-Reply-To: <1251396736-928-5-git-send-email-srabbelier@gmail.com>
On Thu, 27 Aug 2009, Sverre Rabbelier wrote:
> Similar to v4, but now requires that the 'feature git-options'
> command is seen before any 'option' command.
...
> +Option commands must be the first commands on the input, to give an
> +option command after any non-option command is an error.
Er ... shouldn't that be the first thing _after_ the "feature git-options"
command?
--
Julian
---
You can't play your friends like marks, kid.
-- Henry Gondorf, "The Sting"
^ permalink raw reply
* [PATCH v5a 6/6] fast-import: test the new option command
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-6-git-send-email-srabbelier@gmail.com>
Test three options (quiet and import/export-marks) and verify that the
commandline options override these.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Only difference from v4 is that it is rebased and a new test to
verify that 'feature git-options' is now accepted.
t/t9300-fast-import.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 67 insertions(+), 1 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index a5b9b38..1fbfc5e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1089,7 +1089,7 @@ test_expect_success 'P: fail on blob mark in gitlink' '
test_must_fail git fast-import <input'
###
-### series Q (feature)
+### series Q (feature and option)
###
cat >input <<EOF
@@ -1108,4 +1108,70 @@ test_expect_success 'Q: supported feature is accepted' '
git fast-import <input
'
+cat >input << EOF
+feature git-options
+option quiet
+blob
+data 3
+hi
+
+EOF
+
+touch empty
+
+test_expect_success 'Q: quiet option results in no stats being output' '
+ cat input | git fast-import 2> output &&
+ test_cmp empty output
+'
+
+cat >input << EOF
+feature git-options
+option export-marks=git.marks
+blob
+mark :1
+data 3
+hi
+
+EOF
+
+test_expect_success \
+ 'Q: export-marks option results in a marks file being created' \
+ 'cat input | git fast-import &&
+ grep :1 git.marks'
+
+test_expect_success \
+ 'Q: export-marks options can be overriden by commandline options' \
+ 'cat input | git fast-import --export-marks=other.marks &&
+ grep :1 other.marks'
+
+cat >input << EOF
+feature git-options
+option import-marks=marks.out
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import to output marks works without any content' \
+ 'cat input | git fast-import &&
+ test_cmp marks.out marks.new'
+
+cat >input <<EOF
+feature git-options
+option import-marks=nonexistant.marks
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import marks uses the commandline marks file when the stream specifies one' \
+ 'cat input | git fast-import --import-marks=marks.out &&
+ test_cmp marks.out marks.new'
+
+cat >input <<EOF
+feature git-options
+EOF
+
+test_expect_success 'Q: feature option is accepted' '
+ git fast-import <input
+'
+
test_done
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5a 5/6] fast-import: add option command
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-5-git-send-email-srabbelier@gmail.com>
This allows the frontend to specify any of the supported options as
long as no non-option command has been given. This way the
user does not have to include any frontend-specific options, but
instead she can rely on the frontend to tell fast-import what it
needs.
Also factor out parsing of argv and have it execute when we reach the
first non-option command, or after all commands have been read and
no non-option command has been encountered.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Similar to v4, but now requires that the 'feature git-options'
command is seen before any 'option' command.
Difference from v5 is adding of prefixcmp feature.
Documentation/git-fast-import.txt | 23 ++++++++++++
fast-import.c | 68 ++++++++++++++++++++++++++++++------
2 files changed, 79 insertions(+), 12 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 1e293f2..4ba62f3 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -307,6 +307,11 @@ and control the current import process. More detailed discussion
Require that fast-import supports the specified feature, or
abort if it does not.
+`option`::
+ Specify any of the options listed under OPTIONS to change
+ fast-import's behavior to suit the frontend's needs. This command
+ is optional and is not needed to perform an import.
+
`commit`
~~~~~~~~
Create or update a branch with a new commit, recording one logical
@@ -829,6 +834,24 @@ it does not.
The <feature> part of the command may be any string matching
[a-zA-Z-] and should be understood by a version of fast-import.
+`option`
+~~~~~~~~
+Processes the specified option so that git fast-import behaves in a
+way that suits the frontend's needs.
+Note that options specified by the frontend are overridden by any
+options the user may specify to git fast-import itself.
+
+....
+ 'option' SP <option> LF
+....
+
+The `<option>` part of the command may contain any of the options
+listed in the OPTIONS section, without the leading '--' and is
+treated in the same way.
+
+Option commands must be the first commands on the input, to give an
+option command after any non-option command is an error.
+
Crash Reports
-------------
If fast-import is supplied invalid input it will terminate with a
diff --git a/fast-import.c b/fast-import.c
index 9bf06a4..334dd4f 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -292,6 +292,8 @@ static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
static unsigned int show_stats = 1;
+static int global_argc;
+static const char **global_argv;
/* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -349,6 +351,10 @@ static struct recent_command *rc_free;
static unsigned int cmd_save = 100;
static uintmax_t next_mark;
static struct strbuf new_data = STRBUF_INIT;
+static int options_enabled;
+static int seen_non_option_command;
+
+static void parse_argv(void);
static void write_branch_report(FILE *rpt, struct branch *b)
{
@@ -1700,6 +1706,12 @@ static int read_next_command(void)
if (stdin_eof)
return EOF;
+ if (!seen_non_option_command
+ && prefixcmp(command_buf.buf, "feature ")
+ && prefixcmp(command_buf.buf, "option ")) {
+ parse_argv();
+ }
+
rc = rc_free;
if (rc)
rc_free = rc->next;
@@ -2456,11 +2468,26 @@ static void parse_feature(void)
if (!prefixcmp(feature, "date-format=")) {
option_date_format(feature + 12);
+ } else if (!strcmp("git-options", feature)) {
+ options_enabled = 1;
} else {
die("This version of fast-import does not support feature %s.", feature);
}
}
+static void parse_option(void)
+{
+ char* option = command_buf.buf + 7;
+
+ if (!options_enabled)
+ die("Got option command '%s' before options feature'", option);
+
+ if (seen_non_option_command)
+ die("Got option command '%s' after non-option command", option);
+
+ parse_one_option(option);
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2485,6 +2512,26 @@ static int git_pack_config(const char *k, const char *v, void *cb)
static const char fast_import_usage[] =
"git fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
+static void parse_argv(void)
+{
+ unsigned int i;
+
+ for (i = 1; i < global_argc; i++) {
+ const char *a = global_argv[i];
+
+ if (*a != '-' || !strcmp(a, "--"))
+ break;
+
+ parse_one_option(a + 2);
+ }
+ if (i != global_argc)
+ usage(fast_import_usage);
+
+ seen_non_option_command = 1;
+ if (input_file)
+ read_marks();
+}
+
int main(int argc, const char **argv)
{
unsigned int i;
@@ -2503,18 +2550,8 @@ int main(int argc, const char **argv)
avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
marks = pool_calloc(1, sizeof(struct mark_set));
- for (i = 1; i < argc; i++) {
- const char *a = argv[i];
-
- if (*a != '-' || !strcmp(a, "--"))
- break;
-
- parse_one_option(a + 2);
- }
- if (i != argc)
- usage(fast_import_usage);
- if (input_file)
- read_marks();
+ global_argc = argc;
+ global_argv = argv;
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
@@ -2539,9 +2576,16 @@ int main(int argc, const char **argv)
parse_progress();
else if (!prefixcmp(command_buf.buf, "feature "))
parse_feature();
+ else if (!prefixcmp(command_buf.buf, "option "))
+ parse_option();
else
die("Unsupported command: %s", command_buf.buf);
}
+
+ // argv hasn't been parsed yet, do so
+ if (!seen_non_option_command)
+ parse_argv();
+
end_packfile();
dump_branches();
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [RFC PATCH v5a 4/6] fast-import: test the new feature command
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-4-git-send-email-srabbelier@gmail.com>
Test that an unknown feature causes fast-import to abort, and that a
known feature is accepted.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
New in this series, nothing special here
Also fixed from line.
t/t9300-fast-import.sh | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 821be7c..a5b9b38 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1088,4 +1088,24 @@ INPUT_END
test_expect_success 'P: fail on blob mark in gitlink' '
test_must_fail git fast-import <input'
+###
+### series Q (feature)
+###
+
+cat >input <<EOF
+feature no-such-feature-exists
+EOF
+
+test_expect_success 'Q: abort on unsupported feature' '
+ test_must_fail git fast-import <input
+'
+
+cat >input <<EOF
+feature date-format=now
+EOF
+
+test_expect_success 'Q: supported feature is accepted' '
+ git fast-import <input
+'
+
test_done
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [RFC PATCH v5a 3/6] fast-import: add feature command
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-3-git-send-email-srabbelier@gmail.com>
This allows the fronted to require a specific feature to be supported
by the frontend, or abort.
Also add support for the first feature, date-format=.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
New in this series, currently RFC. This should make it easier
for frontends to specify their needs.
Also fixed from line.
Documentation/git-fast-import.txt | 16 ++++++++++++++++
fast-import.c | 13 +++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index c2f483a..1e293f2 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -303,6 +303,10 @@ and control the current import process. More detailed discussion
standard output. This command is optional and is not needed
to perform an import.
+`feature`::
+ Require that fast-import supports the specified feature, or
+ abort if it does not.
+
`commit`
~~~~~~~~
Create or update a branch with a new commit, recording one logical
@@ -813,6 +817,18 @@ Placing a `progress` command immediately after a `checkpoint` will
inform the reader when the `checkpoint` has been completed and it
can safely access the refs that fast-import updated.
+`feature`
+~~~~~~~~~
+Require that fast-import supports the specified feature, or abort if
+it does not.
+
+....
+ 'feature' SP <feature> LF
+....
+
+The <feature> part of the command may be any string matching
+[a-zA-Z-] and should be understood by a version of fast-import.
+
Crash Reports
-------------
If fast-import is supplied invalid input it will terminate with a
diff --git a/fast-import.c b/fast-import.c
index 812fcf0..9bf06a4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2450,6 +2450,17 @@ static void parse_one_option(const char *option)
}
}
+static void parse_feature(void)
+{
+ char *feature = command_buf.buf + 8;
+
+ if (!prefixcmp(feature, "date-format=")) {
+ option_date_format(feature + 12);
+ } else {
+ die("This version of fast-import does not support feature %s.", feature);
+ }
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2526,6 +2537,8 @@ int main(int argc, const char **argv)
parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
parse_progress();
+ else if (!prefixcmp(command_buf.buf, "feature "))
+ parse_feature();
else
die("Unsupported command: %s", command_buf.buf);
}
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5a 2/6] fast-import: put marks reading in it's own function
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-2-git-send-email-srabbelier@gmail.com>
All options do nothing but set settings, with the exception of the
--input-marks option. Delay the reading of the marks file till after
all options have been parsed.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Unchanged from v4/v5.
fast-import.c | 73 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index b904f20..812fcf0 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -315,6 +315,7 @@ static struct object_entry_pool *blocks;
static struct object_entry *object_table[1 << 16];
static struct mark_set *marks;
static const char *mark_file;
+static const char *input_file;
/* Our last blob */
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
@@ -1643,6 +1644,42 @@ static void dump_marks(void)
}
}
+static void read_marks(void)
+{
+ char line[512];
+ FILE *f = fopen(input_file, "r");
+ if (!f)
+ die_errno("cannot read '%s'", input_file);
+ while (fgets(line, sizeof(line), f)) {
+ uintmax_t mark;
+ char *end;
+ unsigned char sha1[20];
+ struct object_entry *e;
+
+ end = strchr(line, '\n');
+ if (line[0] != ':' || !end)
+ die("corrupt mark line: %s", line);
+ *end = 0;
+ mark = strtoumax(line + 1, &end, 10);
+ if (!mark || end == line + 1
+ || *end != ' ' || get_sha1(end + 1, sha1))
+ die("corrupt mark line: %s", line);
+ e = find_object(sha1);
+ if (!e) {
+ enum object_type type = sha1_object_info(sha1, NULL);
+ if (type < 0)
+ die("object not found: %s", sha1_to_hex(sha1));
+ e = insert_object(sha1);
+ e->type = type;
+ e->pack_id = MAX_PACK_ID;
+ e->offset = 1; /* just not zero! */
+ }
+ insert_mark(mark, e);
+ }
+ fclose(f);
+}
+
+
static int read_next_command(void)
{
static int stdin_eof = 0;
@@ -2338,39 +2375,9 @@ static void parse_progress(void)
skip_optional_lf();
}
-static void option_import_marks(const char *input_file)
+static void option_import_marks(const char *marks)
{
- char line[512];
- FILE *f = fopen(input_file, "r");
- if (!f)
- die_errno("cannot read '%s'", input_file);
- while (fgets(line, sizeof(line), f)) {
- uintmax_t mark;
- char *end;
- unsigned char sha1[20];
- struct object_entry *e;
-
- end = strchr(line, '\n');
- if (line[0] != ':' || !end)
- die("corrupt mark line: %s", line);
- *end = 0;
- mark = strtoumax(line + 1, &end, 10);
- if (!mark || end == line + 1
- || *end != ' ' || get_sha1(end + 1, sha1))
- die("corrupt mark line: %s", line);
- e = find_object(sha1);
- if (!e) {
- enum object_type type = sha1_object_info(sha1, NULL);
- if (type < 0)
- die("object not found: %s", sha1_to_hex(sha1));
- e = insert_object(sha1);
- e->type = type;
- e->pack_id = MAX_PACK_ID;
- e->offset = 1; /* just not zero! */
- }
- insert_mark(mark, e);
- }
- fclose(f);
+ input_file = xstrdup(marks);
}
static void option_date_format(const char *fmt)
@@ -2495,6 +2502,8 @@ int main(int argc, const char **argv)
}
if (i != argc)
usage(fast_import_usage);
+ if (input_file)
+ read_marks();
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5a 1/6] fast-import: put option parsing code in seperate functions
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251398431-12461-1-git-send-email-srabbelier@gmail.com>
Putting the options in their own functions increases readability of
the option parsing block and makes it easier to reuse the option
parsing code later on.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Unchanged since v4/v5.
fast-import.c | 115 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 75 insertions(+), 40 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7ef9865..b904f20 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -291,6 +291,7 @@ static unsigned long branch_count;
static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
+static unsigned int show_stats = 1;
/* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -2337,7 +2338,7 @@ static void parse_progress(void)
skip_optional_lf();
}
-static void import_marks(const char *input_file)
+static void option_import_marks(const char *input_file)
{
char line[512];
FILE *f = fopen(input_file, "r");
@@ -2372,6 +2373,76 @@ static void import_marks(const char *input_file)
fclose(f);
}
+static void option_date_format(const char *fmt)
+{
+ if (!strcmp(fmt, "raw"))
+ whenspec = WHENSPEC_RAW;
+ else if (!strcmp(fmt, "rfc2822"))
+ whenspec = WHENSPEC_RFC2822;
+ else if (!strcmp(fmt, "now"))
+ whenspec = WHENSPEC_NOW;
+ else
+ die("unknown --date-format argument %s", fmt);
+}
+
+static void option_max_pack_size(const char *packsize)
+{
+ max_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;
+}
+
+static void option_depth(const char *depth)
+{
+ max_depth = strtoul(depth, NULL, 0);
+ if (max_depth > MAX_DEPTH)
+ die("--depth cannot exceed %u", MAX_DEPTH);
+}
+
+static void option_active_branches(const char *branches)
+{
+ max_active_branches = strtoul(branches, NULL, 0);
+}
+
+static void option_export_marks(const char *marks)
+{
+ mark_file = xstrdup(marks);
+}
+
+static void option_export_pack_edges(const char *edges)
+{
+ if (pack_edges)
+ fclose(pack_edges);
+ pack_edges = fopen(edges, "a");
+ if (!pack_edges)
+ die_errno("Cannot open '%s'", edges);
+}
+
+static void parse_one_option(const char *option)
+{
+ if (!prefixcmp(option, "date-format=")) {
+ option_date_format(option + 12);
+ } else if (!prefixcmp(option, "max-pack-size=")) {
+ option_max_pack_size(option + 14);
+ } else if (!prefixcmp(option, "depth=")) {
+ option_depth(option + 6);
+ } else if (!prefixcmp(option, "active-branches=")) {
+ option_active_branches(option + 16);
+ } else if (!prefixcmp(option, "import-marks=")) {
+ option_import_marks(option + 13);
+ } else if (!prefixcmp(option, "export-marks=")) {
+ option_export_marks(option + 13);
+ } else if (!prefixcmp(option, "export-pack-edges=")) {
+ option_export_pack_edges(option + 18);
+ } else if (!prefixcmp(option, "force")) {
+ force_update = 1;
+ } else if (!prefixcmp(option, "quiet")) {
+ show_stats = 0;
+ } else if (!prefixcmp(option, "stats")) {
+ show_stats = 1;
+ } else {
+ die("Unsupported option: %s", option);
+ }
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2398,7 +2469,7 @@ static const char fast_import_usage[] =
int main(int argc, const char **argv)
{
- unsigned int i, show_stats = 1;
+ unsigned int i;
git_extract_argv0_path(argv[0]);
@@ -2419,44 +2490,8 @@ int main(int argc, const char **argv)
if (*a != '-' || !strcmp(a, "--"))
break;
- else if (!prefixcmp(a, "--date-format=")) {
- const char *fmt = a + 14;
- if (!strcmp(fmt, "raw"))
- whenspec = WHENSPEC_RAW;
- else if (!strcmp(fmt, "rfc2822"))
- whenspec = WHENSPEC_RFC2822;
- else if (!strcmp(fmt, "now"))
- whenspec = WHENSPEC_NOW;
- else
- die("unknown --date-format argument %s", fmt);
- }
- else if (!prefixcmp(a, "--max-pack-size="))
- max_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;
- else if (!prefixcmp(a, "--depth=")) {
- max_depth = strtoul(a + 8, NULL, 0);
- if (max_depth > MAX_DEPTH)
- die("--depth cannot exceed %u", MAX_DEPTH);
- }
- else if (!prefixcmp(a, "--active-branches="))
- max_active_branches = strtoul(a + 18, NULL, 0);
- else if (!prefixcmp(a, "--import-marks="))
- import_marks(a + 15);
- else if (!prefixcmp(a, "--export-marks="))
- mark_file = a + 15;
- else if (!prefixcmp(a, "--export-pack-edges=")) {
- if (pack_edges)
- fclose(pack_edges);
- pack_edges = fopen(a + 20, "a");
- if (!pack_edges)
- die_errno("Cannot open '%s'", a + 20);
- } else if (!strcmp(a, "--force"))
- force_update = 1;
- else if (!strcmp(a, "--quiet"))
- show_stats = 0;
- else if (!strcmp(a, "--stats"))
- show_stats = 1;
- else
- die("unknown option %s", a);
+
+ parse_one_option(a + 2);
}
if (i != argc)
usage(fast_import_usage);
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5a 0/6] add new feature and option command
From: Sverre Rabbelier @ 2009-08-27 18:40 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Apologies for the borked v5.
This is a reroll of sr/gfi-options to include suggestions from an
off-list discussion about the fast-import format.
Reworked the series (compared to v4) to introduce a 'feature' command
first, and use that in the new 'option' series.
Sverre Rabbelier (6):
fast-import: put option parsing code in seperate functions
fast-import: put marks reading in it's own function
fast-import: add feature command
fast-import: test the new feature command
fast-import: add option command
fast-import: test the new option command
Documentation/git-fast-import.txt | 39 ++++++
fast-import.c | 255 ++++++++++++++++++++++++++-----------
t/t9300-fast-import.sh | 86 +++++++++++++
3 files changed, 303 insertions(+), 77 deletions(-)
^ permalink raw reply
* [PATCH v5 6/6] fast-import: test the new option command
From: Sverre Rabbelier @ 2009-08-27 18:12 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251396736-928-5-git-send-email-srabbelier@gmail.com>
Test three options (quiet and import/export-marks) and verify that the
commandline options override these.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Only difference from v4 is that it is rebased and a new test to
verify that 'feature git-options' is now accepted.
t/t9300-fast-import.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index a5b9b38..08469a2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1089,7 +1089,7 @@ test_expect_success 'P: fail on blob mark in gitlink' '
test_must_fail git fast-import <input'
###
-### series Q (feature)
+### series Q (feature and option)
###
cat >input <<EOF
@@ -1108,4 +1108,66 @@ test_expect_success 'Q: supported feature is accepted' '
git fast-import <input
'
+cat >input << EOF
+option quiet
+blob
+data 3
+hi
+
+EOF
+
+touch empty
+
+test_expect_success 'Q: quiet option results in no stats being output' '
+ cat input | git fast-import 2> output &&
+ test_cmp empty output
+'
+
+cat >input << EOF
+option export-marks=git.marks
+blob
+mark :1
+data 3
+hi
+
+EOF
+
+test_expect_success \
+ 'Q: export-marks option results in a marks file being created' \
+ 'cat input | git fast-import &&
+ grep :1 git.marks'
+
+test_expect_success \
+ 'Q: export-marks options can be overriden by commandline options' \
+ 'cat input | git fast-import --export-marks=other.marks &&
+ grep :1 other.marks'
+
+cat >input << EOF
+option import-marks=marks.out
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import to output marks works without any content' \
+ 'cat input | git fast-import &&
+ test_cmp marks.out marks.new'
+
+cat >input <<EOF
+option import-marks=nonexistant.marks
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import marks uses the commandline marks file when the stream specifies one' \
+ 'cat input | git fast-import --import-marks=marks.out &&
+ test_cmp marks.out marks.new'
+
+cat >input <<EOF
+feature git-options
+EOF
+
+test_expect_success 'Q: feature option is accepted' '
+ git fast-import <input
+'
+
test_done
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5 5/6] fast-import: add option command
From: Sverre Rabbelier @ 2009-08-27 18:12 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251396736-928-4-git-send-email-srabbelier@gmail.com>
This allows the frontend to specify any of the supported options as
long as no non-option command has been given. This way the
user does not have to include any frontend-specific options, but
instead she can rely on the frontend to tell fast-import what it
needs.
Also factor out parsing of argv and have it execute when we reach the
first non-option command, or after all commands have been read and
no non-option command has been encountered.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Similar to v4, but now requires that the 'feature git-options'
command is seen before any 'option' command.
Documentation/git-fast-import.txt | 23 +++++++++++++
fast-import.c | 67 ++++++++++++++++++++++++++++++-------
2 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 1e293f2..4ba62f3 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -307,6 +307,11 @@ and control the current import process. More detailed discussion
Require that fast-import supports the specified feature, or
abort if it does not.
+`option`::
+ Specify any of the options listed under OPTIONS to change
+ fast-import's behavior to suit the frontend's needs. This command
+ is optional and is not needed to perform an import.
+
`commit`
~~~~~~~~
Create or update a branch with a new commit, recording one logical
@@ -829,6 +834,24 @@ it does not.
The <feature> part of the command may be any string matching
[a-zA-Z-] and should be understood by a version of fast-import.
+`option`
+~~~~~~~~
+Processes the specified option so that git fast-import behaves in a
+way that suits the frontend's needs.
+Note that options specified by the frontend are overridden by any
+options the user may specify to git fast-import itself.
+
+....
+ 'option' SP <option> LF
+....
+
+The `<option>` part of the command may contain any of the options
+listed in the OPTIONS section, without the leading '--' and is
+treated in the same way.
+
+Option commands must be the first commands on the input, to give an
+option command after any non-option command is an error.
+
Crash Reports
-------------
If fast-import is supplied invalid input it will terminate with a
diff --git a/fast-import.c b/fast-import.c
index 9bf06a4..043520b 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -292,6 +292,8 @@ static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
static unsigned int show_stats = 1;
+static int global_argc;
+static const char **global_argv;
/* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -349,6 +351,10 @@ static struct recent_command *rc_free;
static unsigned int cmd_save = 100;
static uintmax_t next_mark;
static struct strbuf new_data = STRBUF_INIT;
+static int options_enabled;
+static int seen_non_option_command;
+
+static void parse_argv(void);
static void write_branch_report(FILE *rpt, struct branch *b)
{
@@ -1700,6 +1706,11 @@ static int read_next_command(void)
if (stdin_eof)
return EOF;
+ if (!seen_non_option_command
+ && prefixcmp(command_buf.buf, "option ")) {
+ parse_argv();
+ }
+
rc = rc_free;
if (rc)
rc_free = rc->next;
@@ -2456,11 +2467,26 @@ static void parse_feature(void)
if (!prefixcmp(feature, "date-format=")) {
option_date_format(feature + 12);
+ } else if (!strcmp("git-options", feature)) {
+ options_enabled = 1;
} else {
die("This version of fast-import does not support feature %s.", feature);
}
}
+static void parse_option(void)
+{
+ char* option = command_buf.buf + 7;
+
+ if (!options_enabled)
+ die("Got option command '%s' before options feature'", option);
+
+ if (seen_non_option_command)
+ die("Got option command '%s' after non-option command", option);
+
+ parse_one_option(option);
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2485,6 +2511,26 @@ static int git_pack_config(const char *k, const char *v, void *cb)
static const char fast_import_usage[] =
"git fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
+static void parse_argv(void)
+{
+ unsigned int i;
+
+ for (i = 1; i < global_argc; i++) {
+ const char *a = global_argv[i];
+
+ if (*a != '-' || !strcmp(a, "--"))
+ break;
+
+ parse_one_option(a + 2);
+ }
+ if (i != global_argc)
+ usage(fast_import_usage);
+
+ seen_non_option_command = 1;
+ if (input_file)
+ read_marks();
+}
+
int main(int argc, const char **argv)
{
unsigned int i;
@@ -2503,18 +2549,8 @@ int main(int argc, const char **argv)
avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
marks = pool_calloc(1, sizeof(struct mark_set));
- for (i = 1; i < argc; i++) {
- const char *a = argv[i];
-
- if (*a != '-' || !strcmp(a, "--"))
- break;
-
- parse_one_option(a + 2);
- }
- if (i != argc)
- usage(fast_import_usage);
- if (input_file)
- read_marks();
+ global_argc = argc;
+ global_argv = argv;
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
@@ -2539,9 +2575,16 @@ int main(int argc, const char **argv)
parse_progress();
else if (!prefixcmp(command_buf.buf, "feature "))
parse_feature();
+ else if (!prefixcmp(command_buf.buf, "option "))
+ parse_option();
else
die("Unsupported command: %s", command_buf.buf);
}
+
+ // argv hasn't been parsed yet, do so
+ if (!seen_non_option_command)
+ parse_argv();
+
end_packfile();
dump_branches();
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5 4/6] fast-import: test the new feature command
From: Sverre Rabbelier @ 2009-08-27 18:12 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier, Sverre Rabbelier
In-Reply-To: <1251396736-928-3-git-send-email-srabbelier@gmail.com>
From: Sverre Rabbelier <srabbelier@google.com>
Test that an unknown feature causes fast-import to abort, and that a
known feature is accepted.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
New in this series, nothing special here.
t/t9300-fast-import.sh | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 821be7c..a5b9b38 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1088,4 +1088,24 @@ INPUT_END
test_expect_success 'P: fail on blob mark in gitlink' '
test_must_fail git fast-import <input'
+###
+### series Q (feature)
+###
+
+cat >input <<EOF
+feature no-such-feature-exists
+EOF
+
+test_expect_success 'Q: abort on unsupported feature' '
+ test_must_fail git fast-import <input
+'
+
+cat >input <<EOF
+feature date-format=now
+EOF
+
+test_expect_success 'Q: supported feature is accepted' '
+ git fast-import <input
+'
+
test_done
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [RFC PATCH v5 3/6] fast-import: add feature command
From: Sverre Rabbelier @ 2009-08-27 18:12 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier, Sverre Rabbelier
In-Reply-To: <1251396736-928-2-git-send-email-srabbelier@gmail.com>
From: Sverre Rabbelier <srabbelier@google.com>
This allows the fronted to require a specific feature to be supported
by the frontend, or abort.
Also add support for the first feature, date-format=.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
New in this series, currently RFC. This should make it easier
for frontends to specify their needs.
Documentation/git-fast-import.txt | 16 ++++++++++++++++
fast-import.c | 13 +++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index c2f483a..1e293f2 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -303,6 +303,10 @@ and control the current import process. More detailed discussion
standard output. This command is optional and is not needed
to perform an import.
+`feature`::
+ Require that fast-import supports the specified feature, or
+ abort if it does not.
+
`commit`
~~~~~~~~
Create or update a branch with a new commit, recording one logical
@@ -813,6 +817,18 @@ Placing a `progress` command immediately after a `checkpoint` will
inform the reader when the `checkpoint` has been completed and it
can safely access the refs that fast-import updated.
+`feature`
+~~~~~~~~~
+Require that fast-import supports the specified feature, or abort if
+it does not.
+
+....
+ 'feature' SP <feature> LF
+....
+
+The <feature> part of the command may be any string matching
+[a-zA-Z-] and should be understood by a version of fast-import.
+
Crash Reports
-------------
If fast-import is supplied invalid input it will terminate with a
diff --git a/fast-import.c b/fast-import.c
index 812fcf0..9bf06a4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2450,6 +2450,17 @@ static void parse_one_option(const char *option)
}
}
+static void parse_feature(void)
+{
+ char *feature = command_buf.buf + 8;
+
+ if (!prefixcmp(feature, "date-format=")) {
+ option_date_format(feature + 12);
+ } else {
+ die("This version of fast-import does not support feature %s.", feature);
+ }
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2526,6 +2537,8 @@ int main(int argc, const char **argv)
parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
parse_progress();
+ else if (!prefixcmp(command_buf.buf, "feature "))
+ parse_feature();
else
die("Unsupported command: %s", command_buf.buf);
}
--
1.6.4.122.g6ffd7
^ permalink raw reply related
* [PATCH v5 2/6] fast-import: put marks reading in it's own function
From: Sverre Rabbelier @ 2009-08-27 18:12 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List,
Ian Clatworthy <ian.cla
Cc: Sverre Rabbelier
In-Reply-To: <1251396736-928-1-git-send-email-srabbelier@gmail.com>
All options do nothing but set settings, with the exception of the
--input-marks option. Delay the reading of the marks file till after
all options have been parsed.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Unchanged from v4.
fast-import.c | 73 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index b904f20..812fcf0 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -315,6 +315,7 @@ static struct object_entry_pool *blocks;
static struct object_entry *object_table[1 << 16];
static struct mark_set *marks;
static const char *mark_file;
+static const char *input_file;
/* Our last blob */
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
@@ -1643,6 +1644,42 @@ static void dump_marks(void)
}
}
+static void read_marks(void)
+{
+ char line[512];
+ FILE *f = fopen(input_file, "r");
+ if (!f)
+ die_errno("cannot read '%s'", input_file);
+ while (fgets(line, sizeof(line), f)) {
+ uintmax_t mark;
+ char *end;
+ unsigned char sha1[20];
+ struct object_entry *e;
+
+ end = strchr(line, '\n');
+ if (line[0] != ':' || !end)
+ die("corrupt mark line: %s", line);
+ *end = 0;
+ mark = strtoumax(line + 1, &end, 10);
+ if (!mark || end == line + 1
+ || *end != ' ' || get_sha1(end + 1, sha1))
+ die("corrupt mark line: %s", line);
+ e = find_object(sha1);
+ if (!e) {
+ enum object_type type = sha1_object_info(sha1, NULL);
+ if (type < 0)
+ die("object not found: %s", sha1_to_hex(sha1));
+ e = insert_object(sha1);
+ e->type = type;
+ e->pack_id = MAX_PACK_ID;
+ e->offset = 1; /* just not zero! */
+ }
+ insert_mark(mark, e);
+ }
+ fclose(f);
+}
+
+
static int read_next_command(void)
{
static int stdin_eof = 0;
@@ -2338,39 +2375,9 @@ static void parse_progress(void)
skip_optional_lf();
}
-static void option_import_marks(const char *input_file)
+static void option_import_marks(const char *marks)
{
- char line[512];
- FILE *f = fopen(input_file, "r");
- if (!f)
- die_errno("cannot read '%s'", input_file);
- while (fgets(line, sizeof(line), f)) {
- uintmax_t mark;
- char *end;
- unsigned char sha1[20];
- struct object_entry *e;
-
- end = strchr(line, '\n');
- if (line[0] != ':' || !end)
- die("corrupt mark line: %s", line);
- *end = 0;
- mark = strtoumax(line + 1, &end, 10);
- if (!mark || end == line + 1
- || *end != ' ' || get_sha1(end + 1, sha1))
- die("corrupt mark line: %s", line);
- e = find_object(sha1);
- if (!e) {
- enum object_type type = sha1_object_info(sha1, NULL);
- if (type < 0)
- die("object not found: %s", sha1_to_hex(sha1));
- e = insert_object(sha1);
- e->type = type;
- e->pack_id = MAX_PACK_ID;
- e->offset = 1; /* just not zero! */
- }
- insert_mark(mark, e);
- }
- fclose(f);
+ input_file = xstrdup(marks);
}
static void option_date_format(const char *fmt)
@@ -2495,6 +2502,8 @@ int main(int argc, const char **argv)
}
if (i != argc)
usage(fast_import_usage);
+ if (input_file)
+ read_marks();
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
--
1.6.4.122.g6ffd7
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox