* Re: [PATCH] Specify a precision for the length of a subject string
From: Jeff King @ 2011-12-23 10:35 UTC (permalink / raw)
To: nathan.panike; +Cc: git
In-Reply-To: <20111223100957.GA1247@sigill.intra.peff.net>
On Fri, Dec 23, 2011 at 05:09:58AM -0500, Jeff King wrote:
> > The ones that make sense to limit are all those that depend on the subject, as the
> > above; it does not make sense to limit other fields that don't depend on the
> > subject, as they are fixed width, or have small variance. And it does not make
> > sense to me to limit the length of the body.
>
> I agree the subject is the most likely place. I was thinking one might
> want to do it with the body, too. But whether it would be "I want N
> bytes of the body" or "truncate each body line at N bytes without
> wrapping", I don't know.
Another place that might want it is %N (commit notes).
Here's how I would have done it. Not involving %w at all, but applying
equally to all placeholders.
[1/2]: pretty: refactor --format "magic" placeholders
[2/2]: pretty: allow "max-size" magic for all placeholders
I'm not personally interested in this topic, so I won't be pushing for
this to be included in git. But if it feels like the right direction for
you, feel free to be build on it and post it as part of your series (or
just take it as inspiration and make your own commits). Off the top of
my head, it needs:
- documentation updates
- tests
- userformat_want_item should also respect the same magic (it already
duplicates some of the "-/+/ " magic. It might be nice to factor
that part out).
-Peff
^ permalink raw reply
* [PATCH 1/2] pretty: refactor --format "magic" placeholders
From: Jeff King @ 2011-12-23 10:35 UTC (permalink / raw)
To: nathan.panike; +Cc: git
In-Reply-To: <20111223100957.GA1247@sigill.intra.peff.net>
Instead of assuming each magic token is a single character,
let's handle arbitrary-sized magic.
Signed-off-by: Jeff King <peff@peff.net>
---
pretty.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/pretty.c b/pretty.c
index 230fe1c..7b4d098 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1018,6 +1018,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void *context)
{
int consumed;
+ int magic_len = 0;
size_t orig_len;
enum {
NO_MAGIC,
@@ -1039,13 +1040,13 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
default:
break;
}
- if (magic != NO_MAGIC)
+ if (magic != NO_MAGIC) {
+ magic_len++;
placeholder++;
+ }
orig_len = sb->len;
consumed = format_commit_one(sb, placeholder, context);
- if (magic == NO_MAGIC)
- return consumed;
if ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {
while (sb->len && sb->buf[sb->len - 1] == '\n')
@@ -1056,7 +1057,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
else if (magic == ADD_SP_BEFORE_NON_EMPTY)
strbuf_insert(sb, orig_len, " ", 1);
}
- return consumed + 1;
+ return consumed + magic_len;
}
static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
--
1.7.8.1.3.gba11d
^ permalink raw reply related
* [PATCH 2/2] pretty: allow "max-size" magic for all placeholders
From: Jeff King @ 2011-12-23 10:36 UTC (permalink / raw)
To: nathan.panike; +Cc: git
In-Reply-To: <20111223100957.GA1247@sigill.intra.peff.net>
You can now truncate a given placeholder to no more than a
certain number of characters with something like "%30s".
Signed-off-by: Jeff King <peff@peff.net>
---
This just uses the made-up "%30s" syntax, but you could easily tweak it
to handle "%.30s" or whatever.
pretty.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/pretty.c b/pretty.c
index 7b4d098..06d96a7 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1019,6 +1019,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
{
int consumed;
int magic_len = 0;
+ int max_len = 0;
size_t orig_len;
enum {
NO_MAGIC,
@@ -1045,9 +1046,22 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
placeholder++;
}
+ if (isdigit(placeholder[0])) {
+ char *end;
+ max_len = strtoul(placeholder, &end, 10);
+ magic_len += (end - placeholder);
+ placeholder = end;
+ }
+
orig_len = sb->len;
consumed = format_commit_one(sb, placeholder, context);
+ if (max_len) {
+ size_t end = orig_len + max_len;
+ if (end < sb->len)
+ strbuf_setlen(sb, end);
+ }
+
if ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {
while (sb->len && sb->buf[sb->len - 1] == '\n')
strbuf_setlen(sb, sb->len - 1);
--
1.7.8.1.3.gba11d
^ permalink raw reply related
* I can never finish a push
From: Martin L Resnick @ 2011-12-23 13:11 UTC (permalink / raw)
To: git
I'm working remotely over a VERY slow line.
When I do a push it starts out fine
but after the 15 seconds it takes to push
it fails with non-fast-forward merge.
So I pull (no merge needed, its fast-forward)
and try push again. Fails again.
I can keep this up for hours on end;
pushing, pulling, pushing, pulling.
Apparently there is fast and furious development
on the branch I'm on that during my 15 seconds
of pushing someone else on-site pushes and adds
new commits before mine can finish.
Is there anyway to lock the repository while
my push is going on ?
Please don't ask why I have a slow line
or why the volume of changes that I am pushing.
Suffice it to say its military work.
^ permalink raw reply
* Re: I can never finish a push
From: Thomas Rast @ 2011-12-23 14:18 UTC (permalink / raw)
To: Martin L Resnick; +Cc: git
In-Reply-To: <4EF47DF3.9080809@bbn.com>
Martin L Resnick <mresnick@bbn.com> writes:
> I'm working remotely over a VERY slow line.
>
> When I do a push it starts out fine
> but after the 15 seconds it takes to push
> it fails with non-fast-forward merge.
>
> So I pull (no merge needed, its fast-forward)
> and try push again. Fails again.
>
> I can keep this up for hours on end;
> pushing, pulling, pushing, pulling.
> Apparently there is fast and furious development
> on the branch I'm on that during my 15 seconds
> of pushing someone else on-site pushes and adds
> new commits before mine can finish.
>
> Is there anyway to lock the repository while
> my push is going on ?
Git doesn't have any locking features.
Your best bet is probably to have someone with faster access merge your
branch, e.g., by pushing your work elsewhere (to another repo or just
a different branch) and then sending them an email asking for your work
to be merged.
If you have this issue a lot, the admins of your repo server could
probably arrange for a feature where you push to a special "please merge
this" branch namespace (such as incoming/martin-resnick), and the server
then does the merge for you using locking (and of course refusing if
there was any conflict).
However, it somewhat eludes me how you can generate churn on the order
of 2000 commits (8*3600/15) per workday *to the same repository*.
Perhaps the repository should be split into subprojects? Or at the very
least, the subprojects should be handled in different repositories, from
which an integrator pulls together the daily latest-and-greatest across
all subprojects?
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: I can never finish a push
From: demerphq @ 2011-12-23 14:19 UTC (permalink / raw)
To: Martin L Resnick; +Cc: git
In-Reply-To: <4EF47DF3.9080809@bbn.com>
On 23 December 2011 14:11, Martin L Resnick <mresnick@bbn.com> wrote:
> I'm working remotely over a VERY slow line.
>
> When I do a push it starts out fine
> but after the 15 seconds it takes to push
> it fails with non-fast-forward merge.
>
> So I pull (no merge needed, its fast-forward)
> and try push again. Fails again.
>
> I can keep this up for hours on end;
> pushing, pulling, pushing, pulling.
> Apparently there is fast and furious development
> on the branch I'm on that during my 15 seconds
> of pushing someone else on-site pushes and adds
> new commits before mine can finish.
>
> Is there anyway to lock the repository while
> my push is going on ?
>
> Please don't ask why I have a slow line
> or why the volume of changes that I am pushing.
> Suffice it to say its military work.
Maybe try pushing a branch and then having a colleague with a faster
connection do the merge for you.
yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
^ permalink raw reply
* Re: I can never finish a push
From: Johannes Sixt @ 2011-12-23 14:39 UTC (permalink / raw)
To: Martin L Resnick; +Cc: git
In-Reply-To: <4EF47DF3.9080809@bbn.com>
Am 12/23/2011 14:11, schrieb Martin L Resnick:
> I'm working remotely over a VERY slow line.
>
> When I do a push it starts out fine
> but after the 15 seconds it takes to push
> it fails with non-fast-forward merge.
>
> So I pull (no merge needed, its fast-forward)
> and try push again. Fails again.
>
> I can keep this up for hours on end;
> pushing, pulling, pushing, pulling.
Your statements can only make sense if the pushed branch generates a
"non-fast-forward" is not the same branch that you pull. Show a transcript
of your commands, and in particular also tell your setting of push.default.
-- Hannes
^ permalink raw reply
* Re: I can never finish a push
From: Andreas Schwab @ 2011-12-23 14:39 UTC (permalink / raw)
To: Martin L Resnick; +Cc: git
In-Reply-To: <4EF47DF3.9080809@bbn.com>
Martin L Resnick <mresnick@bbn.com> writes:
> So I pull (no merge needed, its fast-forward)
If the merge is fast-forward then you aren't really having anything to
push, are you? Are you sure you are pushing the right branch?
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply
* Re: "Nested quantifiers" error in gitweb with "++" in the filename
From: demerphq @ 2011-12-23 16:02 UTC (permalink / raw)
To: Jehan Bing; +Cc: git
In-Reply-To: <jd04eq$9m0$1@dough.gmane.org>
On 22 December 2011 21:37, Jehan Bing <jehan@orb.com> wrote:
> Hi,
>
> I'm getting an error when trying to look at a blob when the filename has
> "++" in it:
>
> http://.../blob/13ec1624fefc23d20d0407aac3337b35844a2ceb:/foo-++.txt
This error comes because the filename is being used a pattern without
being protected by a quotemeta.
Interestingly, a later version of perl would not have this problem as
++ is a legal quantifier as of 5.10, nevertheless it probably wouldnt
do what you expected.
yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
^ permalink raw reply
* [PATCH] fix shell command line in example
From: Joey Hess @ 2011-12-23 16:41 UTC (permalink / raw)
To: git
The comma was probably intended to be a semicolon so that the
two commands can be run by cut-n-paste.
Signed-off-by: Joey Hess <joey@kitenet.net>
---
Documentation/git-pull.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 0f18ec8..628695d 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -194,7 +194,7 @@ EXAMPLES
current branch:
+
------------------------------------------------
-$ git pull, git pull origin
+$ git pull; git pull origin
------------------------------------------------
+
Normally the branch merged in is the HEAD of the remote repository,
--
1.7.7.3
^ permalink raw reply related
* Re: [PATCH] fix shell command line in example
From: Thomas Rast @ 2011-12-23 16:56 UTC (permalink / raw)
To: Joey Hess; +Cc: git
In-Reply-To: <20111223164128.GA21918@gnu.kitenet.net>
Joey Hess <joey@kitenet.net> writes:
> The comma was probably intended to be a semicolon so that the
> two commands can be run by cut-n-paste.
[...]
> ------------------------------------------------
> -$ git pull, git pull origin
> +$ git pull; git pull origin
> ------------------------------------------------
Would it ever make sense to run the two in sequence?
But upon closer reading, it seems to be a pretty terrible example
anyway. It reads:
* Update the remote-tracking branches for the repository
you cloned from, then merge one of them into your
current branch:
+
------------------------------------------------
$ git pull, git pull origin
------------------------------------------------
+
Normally the branch merged in is the HEAD of the remote repository,
but the choice is determined by the branch.<name>.remote and
branch.<name>.merge options; see linkgit:git-config[1] for details.
But that "normally" is no longer true: with default configs, the user
would only ever have branches with tracking already set up. So
*normally*, 'git pull' will merge the @{upstream}.
'git pull origin' is even worse: with tracking configured, it goes out
of its way to verify that the specified remote (origin) is actually what
HEAD tracks[*]. So 'git pull origin' with default configs means "please
pull, but double-check me on the choice of remote". Do we want to give
that to a user as the second example?
So I'm thinking it should just read
* Update the upstream origin of the current branch, then merge the
tracked branch into the current one:
+
--------------------------------------------------
$ git pull
--------------------------------------------------
modulo avoiding confusion around upstream/tracking.
[*] a8c9bef (pull: improve advice for unconfigured error case,
2009-10-05) has a long explanation on the subject.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* [PATCH] Remove Git's support for smoke testing
From: Ævar Arnfjörð Bjarmason @ 2011-12-23 17:08 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason
I'm no longer running the Git smoke testing service at
smoke.git.nix.is due to Smolder being a fragile piece of software not
having time to follow through on making it easy for third parties to
run and submit their own smoke tests.
So remove the support in Git for sending smoke tests to
smoke.git.nix.is, it's still easy to modify the test suite to submit
smokes somewhere else.
This reverts the following commits:
Revert "t/README: Add SMOKE_{COMMENT,TAGS}= to smoke_report target" -- e38efac87d
Revert "t/README: Document the Smoke testing" -- d15e9ebc5c
Revert "t/Makefile: Create test-results dir for smoke target" -- 617344d77b
Revert "tests: Infrastructure for Git smoke testing" -- b6b84d1b74
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/Makefile | 40 +--------------------------------
t/README | 73 ------------------------------------------------------------
t/harness | 21 -----------------
3 files changed, 1 insertions(+), 133 deletions(-)
delete mode 100755 t/harness
diff --git a/t/Makefile b/t/Makefile
index 9046ec9..52a23ff 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -73,42 +73,4 @@ gitweb-test:
valgrind:
$(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
-# Smoke testing targets
--include ../GIT-VERSION-FILE
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
-uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
-
-test-results:
- mkdir -p test-results
-
-test-results/git-smoke.tar.gz: test-results
- $(PERL_PATH) ./harness \
- --archive="test-results/git-smoke.tar.gz" \
- $(T)
-
-smoke: test-results/git-smoke.tar.gz
-
-SMOKE_UPLOAD_FLAGS =
-ifdef SMOKE_USERNAME
- SMOKE_UPLOAD_FLAGS += -F username="$(SMOKE_USERNAME)" -F password="$(SMOKE_PASSWORD)"
-endif
-ifdef SMOKE_COMMENT
- SMOKE_UPLOAD_FLAGS += -F comments="$(SMOKE_COMMENT)"
-endif
-ifdef SMOKE_TAGS
- SMOKE_UPLOAD_FLAGS += -F tags="$(SMOKE_TAGS)"
-endif
-
-smoke_report: smoke
- curl \
- -H "Expect: " \
- -F project=Git \
- -F architecture="$(uname_M)" \
- -F platform="$(uname_S)" \
- -F revision="$(GIT_VERSION)" \
- -F report_file=@test-results/git-smoke.tar.gz \
- $(SMOKE_UPLOAD_FLAGS) \
- http://smoke.git.nix.is/app/projects/process_add_report/1 \
- | grep -v ^Redirecting
-
-.PHONY: pre-clean $(T) aggregate-results clean valgrind smoke smoke_report
+.PHONY: pre-clean $(T) aggregate-results clean valgrind
diff --git a/t/README b/t/README
index c85abaf..681e8b4 100644
--- a/t/README
+++ b/t/README
@@ -658,76 +658,3 @@ Then, at the top-level:
That'll generate a detailed cover report in the "cover_db_html"
directory, which you can then copy to a webserver, or inspect locally
in a browser.
-
-Smoke testing
--------------
-
-The Git test suite has support for smoke testing. Smoke testing is
-when you submit the results of a test run to a central server for
-analysis and aggregation.
-
-Running a smoke tester is an easy and valuable way of contributing to
-Git development, particularly if you have access to an uncommon OS on
-obscure hardware.
-
-After building Git you can generate a smoke report like this in the
-"t" directory:
-
- make clean smoke
-
-You can also pass arguments via the environment. This should make it
-faster:
-
- GIT_TEST_OPTS='--root=/dev/shm' TEST_JOBS=10 make clean smoke
-
-The "smoke" target will run the Git test suite with Perl's
-"TAP::Harness" module, and package up the results in a .tar.gz archive
-with "TAP::Harness::Archive". The former is included with Perl v5.10.1
-or later, but you'll need to install the latter from the CPAN. See the
-"Test coverage" section above for how you might do that.
-
-Once the "smoke" target finishes you'll see a message like this:
-
- TAP Archive created at <path to git>/t/test-results/git-smoke.tar.gz
-
-To upload the smoke report you need to have curl(1) installed, then
-do:
-
- make smoke_report
-
-To upload the report anonymously. Hopefully that'll return something
-like "Reported #7 added.".
-
-If you're going to be uploading reports frequently please request a
-user account by E-Mailing gitsmoke@v.nix.is. Once you have a username
-and password you'll be able to do:
-
- SMOKE_USERNAME=<username> SMOKE_PASSWORD=<password> make smoke_report
-
-You can also add an additional comment to attach to the report, and/or
-a comma separated list of tags:
-
- SMOKE_USERNAME=<username> SMOKE_PASSWORD=<password> \
- SMOKE_COMMENT=<comment> SMOKE_TAGS=<tags> \
- make smoke_report
-
-Once the report is uploaded it'll be made available at
-http://smoke.git.nix.is, here's an overview of Recent Smoke Reports
-for Git:
-
- http://smoke.git.nix.is/app/projects/smoke_reports/1
-
-The reports will also be mirrored to GitHub every few hours:
-
- http://github.com/gitsmoke/smoke-reports
-
-The Smolder SQLite database is also mirrored and made available for
-download:
-
- http://github.com/gitsmoke/smoke-database
-
-Note that the database includes hashed (with crypt()) user passwords
-and E-Mail addresses. Don't use a valuable password for the smoke
-service if you have an account, or an E-Mail address you don't want to
-be publicly known. The user accounts are just meant to be convenient
-labels, they're not meant to be secure.
diff --git a/t/harness b/t/harness
deleted file mode 100755
index f5c02f4..0000000
--- a/t/harness
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-use Getopt::Long ();
-use TAP::Harness::Archive;
-
-Getopt::Long::Parser->new(
- config => [ qw/ pass_through / ],
-)->getoptions(
- 'jobs:1' => \(my $jobs = $ENV{TEST_JOBS}),
- 'archive=s' => \my $archive,
-) or die "$0: Couldn't getoptions()";
-
-TAP::Harness::Archive->new({
- jobs => $jobs,
- archive => $archive,
- ($ENV{GIT_TEST_OPTS}
- ? (test_args => [ split /\s+/, $ENV{GIT_TEST_OPTS} ])
- : ()),
- extra_properties => {},
-})->runtests(@ARGV);
--
1.7.7.3
^ permalink raw reply related
* Re: [PATCH] fix shell command line in example
From: Joey Hess @ 2011-12-23 17:33 UTC (permalink / raw)
To: git
In-Reply-To: <8739cbi5v3.fsf@thomas.inf.ethz.ch>
[-- Attachment #1: Type: text/plain, Size: 929 bytes --]
Thomas Rast wrote:
> * Update the upstream origin of the current branch, then merge the
> tracked branch into the current one:
> +
> --------------------------------------------------
> $ git pull
> --------------------------------------------------
>
> modulo avoiding confusion around upstream/tracking.
I support having a simple "git pull" example; I think it's the first
thing users should be reaching for, followed perhaps by "git pull foo bar"
when they have multiple remotes.
Still, an example of pulling all tracking branches from a remote and
merging in the right one for the currently checked out branch would be
good to have, that's also a common need when using git without a
centralized origin. AFAICS, there's no way to do all that in a single
git pull command? My feeling was that this sort of scenario was what
the example was trying to do (rather badly).
--
see shy jo
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply
* Re: Gitk: shortcut to jump to the current HEAD (yellow spot)?
From: Dirk Süsserott @ 2011-12-23 18:54 UTC (permalink / raw)
To: Pat Thoyts; +Cc: Git Mailing List
In-Reply-To: <874nwslayi.fsf@fox.patthoyts.tk>
Am 22.12.2011 19:26 schrieb Pat Thoyts:
> Dirk Süsserott <newsletter@dirk.my1.cc> writes:
>
>> Hi!
>>
>> Does anybody know about a shortcut in gitk to "jump to the yellow spot"?
>>
>> I often use cmdline and gitk at the same time, switch branches, stash,
>> rebase and so on from bash. When hitting [Ctrl-]F5 in gitk, the last
>> highlighted commit is focused again and my HEAD is far off the screen.
>>
>> Is there a way to jump to the HEAD (the yellow bubble in gitk) with a
>> fingertip?
>>
>> TIA
>> Dirk
>
> Hit the Home key. The binding for that takes you to the first commit.
> End to the last (oldest) commit.
Hi Pat,
thank you, but I almost always run gitk with the '--all' parameter.
Actually, I have a function in my .bashrc for this:
# calls gitk from the top-level directory:
function gkup()
{
(cd "./$(git rev-parse --show-cdup)"; gitk --all "$@" &)
}
That's because gitk behaves odd (at least to me) when not run from the
top-level directory. E.g. the "touching paths" box won't find files in
the top dir if you don't prefix them with a slash. It's all relative to
the directory gitk was started in. To get predictable behavior, I wrote
this function and garnished it with '--all'.
Thus, my current HEAD is not always on the top of the history but
somewhere in between. However, typing "HEAD" (or "head" in the SHA1
field works for me.
Cheers
Dirk
^ permalink raw reply
* Re: "Nested quantifiers" error in gitweb with "++" in the filename
From: Jehan Bing @ 2011-12-23 19:37 UTC (permalink / raw)
To: git
In-Reply-To: <CANgJU+VA9s9t0c8D0P_DesbSDQRBQ6v913KixKQAuiy8jZsdzQ@mail.gmail.com>
On 2011-12-23 08:02, demerphq wrote:
> On 22 December 2011 21:37, Jehan Bing<jehan@orb.com> wrote:
>> Hi,
>>
>> I'm getting an error when trying to look at a blob when the filename has
>> "++" in it:
>>
>> http://.../blob/13ec1624fefc23d20d0407aac3337b35844a2ceb:/foo-++.txt
>
> This error comes because the filename is being used a pattern without
> being protected by a quotemeta.
>
> Interestingly, a later version of perl would not have this problem as
> ++ is a legal quantifier as of 5.10, nevertheless it probably wouldnt
> do what you expected.
>
Interestingly, a later version of perl would not have this problem as,
after investigating the problem further, it's actually a bug in CGI.pm
which has since been fixed ;)
My distribution comes with an old version of CGI.pm (3.15 from perl
5.8.8). After updating to the latest, the problem went away.
^ permalink raw reply
* [RFC PATCH] Allow cloning branches selectively
From: Carlos Martín Nieto @ 2011-12-23 20:13 UTC (permalink / raw)
To: git
Sometimes it's useful to clone only a subset of branches from a remote
we're cloning. Teach clone the --fetch option to select which branches
should get fetched.
Each --fetch sets up a fetch refspec for that branch. Previously this
was only possible by initializing a repo and manually setting up the
config.
---
This is still a WIP, as clone will still always fetch and checkout the
remote's HEAD, which leaves you with a detached HEAD if you didn't
want that branch, which is clearly a bug.
Otherwise it works as expected. A better name for this feature would
also be nice, as in git you don't clone branches but repos. Maybe
something like "selectively fetch branches on clone"? If there isn't
an outcry against this I'll add --fetch to the manpage as well.
cmn
builtin/clone.c | 82 ++++++++++++++++++++++++++++++++++------------
t/t5702-clone-options.sh | 22 +++++++++++--
2 files changed, 80 insertions(+), 24 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 86db954..f14ca2a 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -48,6 +48,17 @@ static int option_verbosity;
static int option_progress;
static struct string_list option_config;
static struct string_list option_reference;
+static struct string_list option_fetch;
+static const char **refspecs;
+static int refspecs_nr;
+static int refspecs_alloc;
+
+static void add_refspec(const char *ref)
+{
+ refspecs_nr++;
+ ALLOC_GROW(refspecs, refspecs_nr, refspecs_alloc);
+ refspecs[refspecs_nr-1] = ref;
+}
static int opt_parse_reference(const struct option *opt, const char *arg, int unset)
{
@@ -88,6 +99,8 @@ static struct option builtin_clone_options[] = {
"use <name> instead of 'origin' to track upstream"),
OPT_STRING('b', "branch", &option_branch, "branch",
"checkout <branch> instead of the remote's HEAD"),
+ OPT_STRING_LIST(0, "fetch", &option_fetch, "refspec",
+ "fetch <refspec> instead of all the branches"),
OPT_STRING('u', "upload-pack", &option_upload_pack, "path",
"path to git-upload-pack on the remote"),
OPT_STRING(0, "depth", &option_depth, "depth",
@@ -421,13 +434,16 @@ static void remove_junk_on_signal(int signo)
}
static struct ref *wanted_peer_refs(const struct ref *refs,
- struct refspec *refspec)
+ struct refspec *refspec, int refspec_nr)
{
struct ref *head = copy_ref(find_ref_by_name(refs, "HEAD"));
struct ref *local_refs = head;
struct ref **tail = head ? &head->next : &local_refs;
+ int i;
+
+ for (i = 0; i < refspec_nr; i++)
+ get_fetch_map(refs, &refspec[i], &tail, 0);
- get_fetch_map(refs, refspec, &tail, 0);
if (!option_mirror)
get_fetch_map(refs, tag_refspec, &tail, 0);
@@ -482,7 +498,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
int err = 0;
struct refspec *refspec;
- const char *fetch_pattern;
junk_pid = getpid();
@@ -508,6 +523,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
option_no_checkout = 1;
}
+ if (option_mirror && refspecs)
+ die(_("--mirror and --fetch options are incompatible"));
+
if (!option_origin)
option_origin = "origin";
@@ -594,30 +612,55 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_config(git_default_config, NULL);
if (option_bare) {
- if (option_mirror)
+ git_config_set("core.bare", "true");
+ if (option_mirror) {
src_ref_prefix = "refs/";
- strbuf_addstr(&branch_top, src_ref_prefix);
+ strbuf_addf(&key, "remote.%s.mirror", option_origin);
+ git_config_set(key.buf, "true");
+ strbuf_reset(&key);
+ }
- git_config_set("core.bare", "true");
+ strbuf_addstr(&branch_top, src_ref_prefix);
} else {
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
}
- strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+ strbuf_reset(&key);
+ strbuf_addf(&key, "remote.%s.fetch", option_origin);
+
+ /* If the user didn't override it, use the default values */
+ if (option_fetch.nr == 0) {
+ strbuf_reset(&value);
+ strbuf_addf(&value, "+%s*:%s*", src_ref_prefix,
+ branch_top.buf);
- if (option_mirror || !option_bare) {
- /* Configure the remote */
- strbuf_addf(&key, "remote.%s.fetch", option_origin);
git_config_set_multivar(key.buf, value.buf, "^$", 0);
- strbuf_reset(&key);
+ add_refspec(strbuf_detach(&value, NULL));
+ } else {
+ int i;
+ for (i = 0; i < option_fetch.nr; i++) {
+ const char *ref = option_fetch.items[i].string;
+ if (!valid_fetch_refspec(ref))
+ die(_("Not a valid fetch refspec: %s"), ref);
+
+ /* If we only got a branch name, make it a proper refspec */
+ if (!strchr(ref, ':')) {
+ strbuf_reset(&value);
+ strbuf_addf(&value, "refs/heads/%s:%s%s",
+ ref, branch_top.buf, ref);
+ ref = value.buf;
+ }
- if (option_mirror) {
- strbuf_addf(&key, "remote.%s.mirror", option_origin);
- git_config_set(key.buf, "true");
- strbuf_reset(&key);
+ printf("Adding refpsec %s\n", ref);
+ git_config_set_multivar(key.buf, value.buf, "^$", 0);
+ add_refspec(strbuf_detach(&value, NULL));
}
+
+ strbuf_reset(&value);
+ strbuf_reset(&key);
}
+ strbuf_reset(&key);
strbuf_addf(&key, "remote.%s.url", option_origin);
git_config_set(key.buf, repo);
strbuf_reset(&key);
@@ -625,14 +668,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_reference.nr)
setup_reference();
- fetch_pattern = value.buf;
- refspec = parse_fetch_refspec(1, &fetch_pattern);
-
- strbuf_reset(&value);
+ refspec = parse_fetch_refspec(refspecs_nr, refspecs);
if (is_local) {
refs = clone_local(path, git_dir);
- mapped_refs = wanted_peer_refs(refs, refspec);
+ mapped_refs = wanted_peer_refs(refs, refspec, refspecs_nr);
} else {
struct remote *remote = remote_get(option_origin);
transport = transport_get(remote, remote->url[0]);
@@ -654,7 +694,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
refs = transport_get_remote_refs(transport);
if (refs) {
- mapped_refs = wanted_peer_refs(refs, refspec);
+ mapped_refs = wanted_peer_refs(refs, refspec, refspecs_nr);
transport_fetch_refs(transport, mapped_refs);
}
}
diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh
index 02cb024..53d914f 100755
--- a/t/t5702-clone-options.sh
+++ b/t/t5702-clone-options.sh
@@ -8,15 +8,17 @@ test_expect_success 'setup' '
mkdir parent &&
(cd parent && git init &&
echo one >file && git add file &&
- git commit -m one)
+ git commit -m one &&
+ git branch other)
'
test_expect_success 'clone -o' '
git clone -o foo parent clone-o &&
- (cd clone-o && git rev-parse --verify refs/remotes/foo/master)
-
+ (cd clone-o &&
+ git rev-parse --verify refs/remotes/foo/master &&
+ git rev-parse --verify refs/remotes/foo/other)
'
test_expect_success 'redirected clone' '
@@ -33,4 +35,18 @@ test_expect_success 'redirected clone -v' '
'
+test_expect_success 'select one branch to fetch' '
+ git clone --progress --fetch=master "file://$(pwd)/parent" clone-select-one &&
+ (cd clone-sel &&
+ git rev-parse --verify refs/remotes/origin/master &&
+ test_must_fail git rev-parse --verify refs/remotes/origin/other)
+'
+
+test_expect_success 'select several branches to fetch' '
+ git clone --progress --fetch=master --fetch=other "file://$(pwd)/parent" clone-select-many &&
+ (cd clone-sel2 &&
+ git rev-parse --verify refs/remotes/origin/master &&
+ git rev-parse --verify refs/remotes/origin/other)
+'
+
test_done
--
1.7.8.352.g876a6f
^ permalink raw reply related
* Re: [RFC/PATCH] i18n of multi-line messages
From: Junio C Hamano @ 2011-12-23 20:54 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Ævar Arnfjörð Bjarmason
In-Reply-To: <4EF422D3.2050802@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
> IMO the solution to not translate plumbing messages is to omit the
> initialization of the gettext machinery.
That's clever, and might be a good approach. I didn't think things through
nor looked at the existing codepaths where we do that (and I won't be
looking at them over the holiday weekend).
> Anyway, here is a patch that modifies vreportf() in an i18n friendly way
> (I think). It is not necessarily meant for inclusion.
The test-part of the patch seems to match more or less what I tentatively
queued after I sent the "convert at vreportf() level" patch and then
discarded. You seem to have missed vwritef(), by the way.
^ permalink raw reply
* Re: [PATCH] Specify a precision for the length of a subject string
From: Junio C Hamano @ 2011-12-23 20:58 UTC (permalink / raw)
To: Jeff King; +Cc: nathan.panike, git
In-Reply-To: <20111223103511.GA10029@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Here's how I would have done it. Not involving %w at all, but applying
> equally to all placeholders.
Hmm, just curious why you rejected the %w() approach, as enhancing %w
sounded to me like a better approach at the design level, but that was a
knee-jerk reaction without inspecting the codepaths involved myself hence
not knowing the potential amount of work required.
> - userformat_want_item should also respect the same magic (it already
> duplicates some of the "-/+/ " magic. It might be nice to factor
> that part out).
I recall this was a bit of a bear when I looked at the area last time.
^ permalink raw reply
* Re: [RFC PATCH] Allow cloning branches selectively
From: Junio C Hamano @ 2011-12-23 21:18 UTC (permalink / raw)
To: Carlos Martín Nieto; +Cc: git
In-Reply-To: <1324671199-7074-1-git-send-email-cmn@elego.de>
Carlos Martín Nieto <cmn@elego.de> writes:
> Sometimes it's useful to clone only a subset of branches from a remote
> we're cloning. Teach clone the --fetch option to select which branches
> should get fetched.
This is just a knee-jerk reaction without reading the patch text (which I
won't be doing over the holiday weekend anyway), but is the workflow of
the primarly intended audience to clone "a subset of branches" or "a
single branch"?
I have a slight suspicion that this started out as "I often want to create
a clone to _track_ a single branch, but because I am mucking with the code
related to cloning anyway, I might as well allow more than one to be
fetched, even though I do not have any need for that, somebody might find
it useful". And that is why it is important to answer the first question.
If the primary motivation is for a single branch, I suspect supporting
only a single branch and advertising the feature as "tracking only one
branch" might make it much easier to understand to the end users.
Upon "git clone --track cn/single-clone $there x.git", you would do
something like:
it=cn/single-clone &&
git init x.git &&
cd x.git &&
# configure "git fetch origin" to only get branch $it
git config remote.origin.url "$there" &&
git config remote.origin.fetch refs/heads/$it:refs/remotes/origin/$it &&
# declare that the primary branch at origin is $it as far as we are concerned
git symbolic-ref -m clone refs/remotes/origin/HEAD refs/remotes/origin/$it &&
# Git aware prompt reminds us that this repository is to track branch $it
git symbolic-ref -m clone HEAD refs/heads/$it &&
# And Go!
git fetch origin &&
git reset --hard remotes/origin/$it &&
git config branch.$it.remote origin &&
git config branch.$it.merge $it
Of course you _could_ support more than one pretty easily, but the point
is that it is unclear how you explain to the end user what the feature
does and what it is for in easily understoodd terms, once you start doing
so. It will no longer be "this new clone is to track that branch", but
something else, and I do not know what that something else is.
And depending on what that "something else" is, which branch should be
checked out and what refs/remotes/origin/HEAD should name as the primary
branch of the remote would be different.
Thanks.
^ permalink raw reply
* Re: [PATCH v2 3/3] grep: disable threading in all but worktree case
From: Ævar Arnfjörð Bjarmason @ 2011-12-23 22:37 UTC (permalink / raw)
To: Thomas Rast
Cc: René Scharfe, Eric Herman, git, Junio C Hamano,
Fredrik Kuivinen
In-Reply-To: <5328add8b32f83b4cdbd2e66283f77c125ec127a.1322830368.git.trast@student.ethz.ch>
On Fri, Dec 2, 2011 at 14:07, Thomas Rast <trast@student.ethz.ch> wrote:
> I conjecture that this is caused by contention on
> read_sha1_mutex. [...] So disable threading entirely when not
> scanning the worktree
Why does git-grep even need to keep a mutex to call read_sha1_file()?
It's inherently a read-only operation isn't it? If the lock is needed
because data is being shared between threads in sha1_file.c shouldn't
we tackle that instead of completely disabling threading?
^ permalink raw reply
* Re: [PATCH v2 3/3] grep: disable threading in all but worktree case
From: Thomas Rast @ 2011-12-23 22:49 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason
Cc: René Scharfe, Eric Herman, git, Junio C Hamano,
Fredrik Kuivinen
In-Reply-To: <CACBZZX6hboo4wu3fOs+CHnxsdmedxw72GFMVttQzmHzpcZbqoQ@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> On Fri, Dec 2, 2011 at 14:07, Thomas Rast <trast@student.ethz.ch> wrote:
>
>> I conjecture that this is caused by contention on
>> read_sha1_mutex. [...] So disable threading entirely when not
>> scanning the worktree
>
> Why does git-grep even need to keep a mutex to call read_sha1_file()?
> It's inherently a read-only operation isn't it? If the lock is needed
> because data is being shared between threads in sha1_file.c shouldn't
> we tackle that instead of completely disabling threading?
The problem is that all sorts of data is shared. See
http://thread.gmane.org/gmane.comp.version-control.git/186618
But I need to go through it again, there are some races and double locks
in the posted version.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH] Specify a precision for the length of a subject string
From: Jeff King @ 2011-12-23 23:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: nathan.panike, git
In-Reply-To: <7v1urvc8fb.fsf@alter.siamese.dyndns.org>
On Fri, Dec 23, 2011 at 12:58:00PM -0800, Junio C Hamano wrote:
> > Here's how I would have done it. Not involving %w at all, but applying
> > equally to all placeholders.
>
> Hmm, just curious why you rejected the %w() approach, as enhancing %w
> sounded to me like a better approach at the design level, but that was a
> knee-jerk reaction without inspecting the codepaths involved myself hence
> not knowing the potential amount of work required.
Not so much rejecting as I took a quick look at how I would have done
what your original patch did, and it was simple enough that I took it
all the way to working and decided to post it. I left it up to you to
decide whether using %w would be more sensible. I just wanted to present
another alternative for discussion.
-Peff
^ permalink raw reply
* Re: [PATCH] Specify a precision for the length of a subject string
From: Jeff King @ 2011-12-23 23:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: nathan.panike, git
In-Reply-To: <20111223230228.GA1718@sigill.intra.peff.net>
On Fri, Dec 23, 2011 at 06:02:28PM -0500, Jeff King wrote:
> On Fri, Dec 23, 2011 at 12:58:00PM -0800, Junio C Hamano wrote:
>
> > > Here's how I would have done it. Not involving %w at all, but applying
> > > equally to all placeholders.
> >
> > Hmm, just curious why you rejected the %w() approach, as enhancing %w
> > sounded to me like a better approach at the design level, but that was a
> > knee-jerk reaction without inspecting the codepaths involved myself hence
> > not knowing the potential amount of work required.
>
> Not so much rejecting as I took a quick look at how I would have done
> what your original patch did, and it was simple enough that I took it
> all the way to working and decided to post it. I left it up to you to
> decide whether using %w would be more sensible. I just wanted to present
> another alternative for discussion.
Eh, I misread the "From" header. All of the "you" there is "Nathan".
-Peff
^ permalink raw reply
* Re: [PATCH v2 3/3] grep: disable threading in all but worktree case
From: Ævar Arnfjörð Bjarmason @ 2011-12-24 1:39 UTC (permalink / raw)
To: Thomas Rast
Cc: René Scharfe, Eric Herman, git, Junio C Hamano,
Fredrik Kuivinen
In-Reply-To: <87mxaihpiq.fsf@thomas.inf.ethz.ch>
2011/12/23 Thomas Rast <trast@student.ethz.ch>:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Fri, Dec 2, 2011 at 14:07, Thomas Rast <trast@student.ethz.ch> wrote:
>>
>>> I conjecture that this is caused by contention on
>>> read_sha1_mutex. [...] So disable threading entirely when not
>>> scanning the worktree
>>
>> Why does git-grep even need to keep a mutex to call read_sha1_file()?
>> It's inherently a read-only operation isn't it? If the lock is needed
>> because data is being shared between threads in sha1_file.c shouldn't
>> we tackle that instead of completely disabling threading?
>
> The problem is that all sorts of data is shared. See
>
> http://thread.gmane.org/gmane.comp.version-control.git/186618
>
> But I need to go through it again, there are some races and double locks
> in the posted version.
I mentioned this on IRC, but I thought I'd bring it up here too.
Is the expensive part of git-grep all the setup work, or the actual
traversal and searching? I'm guessing it's the latter.
In that case an easy way to do git-grep in parallel would be to simply
spawn multiple sub-processes, e.g. if we had 1000 files and 4 cores:
1. Split the 1000 into 4 parts 250 each.
2. Spawn 4 processes as: git grep <pattern> -- <250 files>
3. Aggregate all of the results in the parent process
^ permalink raw reply
* Re: Gitk: shortcut to jump to the current HEAD (yellow spot)?
From: Martin von Zweigbergk @ 2011-12-24 4:22 UTC (permalink / raw)
To: Dirk Süsserott; +Cc: Pat Thoyts, Git Mailing List
In-Reply-To: <4EF4CE80.8090502@dirk.my1.cc>
2011/12/23 Dirk Süsserott <newsletter@dirk.my1.cc>:
>
> That's because gitk behaves odd (at least to me) when not run from the
> top-level directory. E.g. the "touching paths" box won't find files in
> the top dir if you don't prefix them with a slash.
This should be fixed in c332f44 (gitk: Fix file highlight when run in
subdirectory, 2011-04-04), which is in the current master and thus, I
believe, to be released in Git 1.7.9.
Martin
^ permalink raw reply
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