* What's cooking in gitweb (20 Sep 2008)
From: Jakub Narebski @ 2008-09-20 23:38 UTC (permalink / raw)
To: git; +Cc: Giuseppe Bilotta, Lea Wiemann, J.H., Gustavo Sverzut Barbieri
This is short summary of not-applied (and not ready to be applied)
gitweb patches, in reverse chronological order, with most recent
entries on top (first). Patches which probably should be resend, now
that we are after 1.6.0 release
Junio, what about "[PATCH] avoid gitweb uninitialized value warning"
(http://thread.gmane.org/gmane.comp.version-control.git/95028)? This
is pure bugfix (well, warning fix, and failrly rare one, but warning
which goes to web server logs).
$gmane=thread.gmane.org/gmane.comp.version-control.git
1. "gitweb pathinfo improvements" by Giuseppe Bilotta
Message-ID: <1220435839-29360-1-git-send-email-giuseppe.bilotta@gmail.com>
http://$gmane/94779
Table of contents:
==================
* [PATCH 1/5] gitweb: action in path with use_pathinfo
* [PATCH 2/5] gitweb: use_pathinfo filenames start with /
* [PATCH 3/5] gitweb: parse parent..current syntax from pathinfo
* [PATCH 4/5] gitweb: use_pathinfo creates parent..current paths
* [PATCH 5/5] gitweb: remove PATH_INFO from $my_url and $my_uri
Need some refinement, especially with respect to _generating_
path_info URLs inside gitweb. Some patches (2 and 5) does not
need correction, and probably should be sent as separate series.
Author promised to resend series, if I remember correctly.
2. "[PATCH] gitweb: shortlog now also obeys $hash_parent" by Giuseppe Bilotta
Message-ID: <1218204731-9931-1-git-send-email-giuseppe.bilotta@gmail.com>
http://$gmane/91666
Very good idea, but for the following two caveats. The name
'$commit_hash' is a bit strange to mean also revision range; passing
"a..b" to parse_commits()... well, it is a good solution, but for me it
feels a bit hacky. But this is not something serious.
More importnat fact is that I'd very much like for _all_ log-like views
(perhaps with exception of feeds: Atom and RSS) to implement this
feature. This could be done by either doing it all in the same commit,
doing commit series changing 'shortlog', 'log' and 'history' separately,
or what I would prefer actually, to refactor generation of log-like views
to use single worker/engine subroutine.
3. "[PATCH 1/1] Add "git" link to the end of project line on the
project_list page." by John 'Warthog9' Hawley
Message-ID: <1217815217-11329-2-git-send-email-warthog19@eaglescrag.net>
http://$gmane/91305
See also: http://$gmane/90778
As it was said in the commit message (which should be line-wrapped by
the way) it makes the assumption that each repository is available from
unique location. Both per-repo cloneurl and gitweb.url, and per
instllation @git_base_url_list allow for multiple repository URLs.
The problem of course is _which_ of those to choose for the targer of
'git' links on projects list page. And I don't think adding yet another
prefix to generate $project URL is a good dolution; better to simply
use first of URLs, and mention it both in comments in gitweb, and in
gitweb/README. Perhaps simply use first entry in @git_base_url_list.
Commit message could be improved too.
3. "Re: [PATCH 0/3] Git::Repo API and gitweb caching" by Lea Wiemann
Message-ID: <48A9CEC0.2020100@gmail.com>
http://$gmane/92726
Demo: http://odin3.kernel.org/git-lewiemann/
Result of "gitweb caching" Google Summer of Code 2008 project.
This is second resend of gitweb patch; the patches adding Mechanize
test of gitweb output, and Git::Repo api had more revisions (reviews)
on git mailing list.
Quote (perhaps it is simply not possible...):
> I unfortunately didn't end up being able to split up the third patch
> (use Perl API in Gitweb, and add caching layer), since the two changes
> are too intricately linked to be properly separated (I actually tried
> splitting it two times, two different ways, and it just didn't work).
Those patches, in particular the gitweb one, needs some review I think,
as they affect quite a bit of code.
4. "[PATCH 0/2] gitweb use sections" by Gustavo Sverzut Barbieri
Message-ID: <1217298868-16513-1-git-send-email-barbieri@profusion.mobi>
http://$gmane/90553
Demo: http://staff.get-e.org/
Patches overview:
==================
* [PATCH 1/2] gitweb: sort projects by path.
* [PATCH 2/2] gitweb: add section support to gitweb project listing.
What I'd like to have for first patch is at least estimating
performance hit (if there is any), and an example where original old
code sorts paths wrongly.
Nevetheless I think it is a good idea to have. I didn't reviewed the
code though...
--
Jakub Narebski
Poland
^ permalink raw reply
* clone fails: Could not get the current working directory
From: John Freeman @ 2008-09-21 0:49 UTC (permalink / raw)
To: git
Howdy,
I'm trying to clone a remote repository. Here's the background:
- The repository is bare, under Bob's home directory on a remote Sun system.
- Bob has set the group permissions for the repo directory to repogroup.
- I have an account on the remote system that is in repogroup.
I am trying to clone the repo on my home machine, using
> git clone ssh://john@remote.system.edu/home/bob/path/to/repo
It fails with
remote: fatal: Could not get the current working directory
error: git-upload-pack: git-pack-objects died with error.
fatal: git-upload-pack: aborting due to possible repository corruption
on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed
Checking the source code, this error is triggered after getcwd() returns
a null pointer in setup.c:set_work_tree(), which is called at only one
place, in setup.c:setup_git_directory_gently().
Can anyone provide any insight as to why am I seeing this error?
Thank you,
John
^ permalink raw reply
* [PATCH v2 0/1] git-svn: testcase for partial rebuild
From: Deskin Miller @ 2008-09-21 2:45 UTC (permalink / raw)
To: Eric Wong; +Cc: git
In-Reply-To: <20080918063754.GA13328@untitled>
>From 45c9876a04ff0aac141300dd10fca50d6db30522 Mon Sep 17 00:00:00 2001
From: Deskin Miler <deskinm@umich.edu>
Date: Thu, 18 Sep 2008 17:55:14 -0400
Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
On Wed, Sep 17, 2008 at 11:38:04PM -0700, Eric Wong wrote:
> This seems to break the following test case for me:
>
> *** t9107-git-svn-migrate.sh ***
> * ok 1: setup old-looking metadata
> * ok 2: git-svn-HEAD is a real HEAD
> * ok 3: initialize old-style (v0) git svn layout
> * ok 4: initialize a multi-repository repo
> * ok 5: multi-fetch works on partial urls + paths
> * ok 6: migrate --minimize on old inited layout
> * FAIL 7: .rev_db auto-converted to .rev_map.UUID
>
> I haven't had time to diagnose it. Also, can you add a test that
> demonstrates this functionality (and ensures things keeps working when
> future work is done on git-svn?)
Thanks for the response; I had a bug in my Perl that my testing hadn't caught.
Gave me an opportunity to learn how the git testsuites work!
This testcase fails for me when applied to master, and passes with patch 1/1 in
the series.
t/t9126-git-svn-partial-rebuild.sh | 53 ++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
create mode 100755 t/t9126-git-svn-partial-rebuild.sh
diff --git a/t/t9126-git-svn-partial-rebuild.sh b/t/t9126-git-svn-partial-rebuild.sh
new file mode 100755
index 0000000..9a94866
--- /dev/null
+++ b/t/t9126-git-svn-partial-rebuild.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Deskin Miller
+#
+
+test_description='git svn partial-rebuild tests'
+. ./lib-git-svn.sh
+
+test_expect_success \
+ 'initialize svnrepo' '
+ mkdir import &&
+ cd import &&
+ mkdir trunk branches tags &&
+ cd trunk &&
+ echo foo > foo &&
+ cd .. &&
+ svn import -m "import for git-svn" . "$svnrepo" >/dev/null &&
+ svn copy "$svnrepo"/trunk "$svnrepo"/branches/a \
+ -m "created branch a" &&
+ cd .. &&
+ rm -rf import &&
+ svn co "$svnrepo"/trunk trunk &&
+ cd trunk &&
+ echo bar >> foo &&
+ svn ci -m "updated trunk" &&
+ cd .. &&
+ svn co "$svnrepo"/branches/a a &&
+ cd a &&
+ echo baz >> a &&
+ svn add a &&
+ svn ci -m "updated a" &&
+ cd .. &&
+ git svn init --stdlayout "$svnrepo"'
+
+test_expect_success 'import an early SVN revision into git' \
+ 'git svn fetch -r1:2'
+
+test_expect_success 'make full git mirror of SVN' \
+ 'mkdir mirror &&
+ cd mirror &&
+ git init &&
+ git svn init --stdlayout "$svnrepo" &&
+ git svn fetch &&
+ cd ..'
+
+test_expect_success 'fetch from git mirror and partial-rebuild' \
+ 'git config --add remote.origin.url "file://$PWD/mirror/.git" &&
+ git config --add remote.origin.fetch refs/remotes/*:refs/remotes/* &&
+ git fetch origin &&
+ git svn fetch
+ '
+
+test_done
--
1.6.0.2.GIT
^ permalink raw reply related
* [PATCH v2 1/1] git-svn: do a partial rebuild if rev_map is out-of-date
From: Deskin Miller @ 2008-09-21 2:45 UTC (permalink / raw)
To: Eric Wong; +Cc: git
In-Reply-To: <20080918063754.GA13328@untitled>
>From 11ef3a043bb9cf89cd87d7030c684a1ee566a87a Mon Sep 17 00:00:00 2001
From: Deskin Miller <deskinm@umich.edu>
Date: Mon, 15 Sep 2008 21:12:58 -0400
Suppose you're using git-svn to work with a certain SVN repository.
Since you don't like 'git-svn fetch' to take forever, and you don't want
to accidentally interrupt it and end up corrupting your repository, you
set up a remote Git repository to mirror the SVN repository, which does
its own 'git-svn fetch' on a cronjob; now you can 'git-fetch' from the
Git mirror into your local repository, and still dcommit to SVN when you
have changes to push.
After you do this, though, git-svn will get very confused if you ever
try to do 'git-svn fetch' in your local repository again, since its
rev_map will differ from the branch's head, and it will be unable to
fetch new commits from SVN because of the metadata conflict. But all
the necessary metadata are there in the Git commit message; git-svn
already knows how to rebuild rev_map files that get blown away, by
using the metadata.
This commit will have git-svn do a partial rebuild of the rev_map to
match the true state of the branch, if it ever is used to fetch again.
This will only work for projects not using either noMetadata or
useSvmProps configuration options; if you are using these options,
git-svn will fall back to the previous behaviour.
Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
On Wed, Sep 17, 2008 at 11:38:04PM -0700, Eric Wong wrote:
> This seems to break the following test case for me:
>
> *** t9107-git-svn-migrate.sh ***
> * ok 1: setup old-looking metadata
> * ok 2: git-svn-HEAD is a real HEAD
> * ok 3: initialize old-style (v0) git svn layout
> * ok 4: initialize a multi-repository repo
> * ok 5: multi-fetch works on partial urls + paths
> * ok 6: migrate --minimize on old inited layout
> * FAIL 7: .rev_db auto-converted to .rev_map.UUID
>
> I haven't had time to diagnose it. Also, can you add a test that
> demonstrates this functionality (and ensures things keeps working when
> future work is done on git-svn?)
Here is the new, fixed version. It allows the test in patch 0/1 to pass.
git-svn.perl | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index af8279a..80a5728 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2626,9 +2626,9 @@ sub rebuild_from_rev_db {
sub rebuild {
my ($self) = @_;
my $map_path = $self->map_path;
- return if (-e $map_path && ! -z $map_path);
+ my $partial = (-e $map_path && ! -z $map_path);
return unless ::verify_ref($self->refname.'^0');
- if ($self->use_svm_props || $self->no_metadata) {
+ if (!$partial && ($self->use_svm_props || $self->no_metadata)) {
my $rev_db = $self->rev_db_path;
$self->rebuild_from_rev_db($rev_db);
if ($self->use_svm_props) {
@@ -2638,10 +2638,13 @@ sub rebuild {
$self->unlink_rev_db_symlink;
return;
}
- print "Rebuilding $map_path ...\n";
+ print "Rebuilding $map_path ...\n" if (!$partial);
+ my ($base_rev, $head) = ($partial ? $self->rev_map_max_norebuild(1) :
+ (undef, undef));
my ($log, $ctx) =
command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,
- $self->refname, '--');
+ ($head ? "$head.." : "") . $self->refname,
+ '--');
my $metadata_url = $self->metadata_url;
remove_username($metadata_url);
my $svn_uuid = $self->ra_uuid;
@@ -2664,12 +2667,17 @@ sub rebuild {
($metadata_url && $url && ($url ne $metadata_url))) {
next;
}
+ if ($partial && $head) {
+ print "Partial-rebuilding $map_path ...\n";
+ print "Currently at $base_rev = $head\n";
+ $head = undef;
+ }
$self->rev_map_set($rev, $c);
print "r$rev = $c\n";
}
command_close_pipe($log, $ctx);
- print "Done rebuilding $map_path\n";
+ print "Done rebuilding $map_path\n" if (!$partial || !$head);
my $rev_db_path = $self->rev_db_path;
if (-f $self->rev_db_path) {
unlink $self->rev_db_path or croak "unlink: $!";
@@ -2809,6 +2817,12 @@ sub rev_map_set {
sub rev_map_max {
my ($self, $want_commit) = @_;
$self->rebuild;
+ my ($r, $c) = $self->rev_map_max_norebuild($want_commit);
+ $want_commit ? ($r, $c) : $r;
+}
+
+sub rev_map_max_norebuild {
+ my ($self, $want_commit) = @_;
my $map_path = $self->map_path;
stat $map_path or return $want_commit ? (0, undef) : 0;
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
--
1.6.0.2.GIT
^ permalink raw reply related
* Re: [PATCH 01/14] Extend index to save more flags
From: Nguyen Thai Ngoc Duy @ 2008-09-21 4:34 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <m3skrulbrd.fsf@localhost.localdomain>
On 9/21/08, Jakub Narebski <jnareb@gmail.com> wrote:
> > +
> > +#define CE_EXTENDED_FLAGS (0)
> > +
> > +/*
> > + * Safeguard to avoid saving wrong flags:
> > + * - CE_EXTENDED2 won't get saved until its semantic is known
> > + * - Bits in 0x0000FFFF have been saved in ce_flags already
> > + * - Bits in 0x003F0000 are currently in-memory flags
> > + */
> > +#if CE_EXTENDED_FLAGS & 0x80CFFFFF
> > +#error "CE_EXTENDED_FLAGS out of range"
> > +#endif
>
>
> I don't quite understand the above fragment (especially with the fact
> that CE_EXTENDED_FLAGS is defined as (0))...
Because this patch does not introduce any new on-disk flag yet so
CE_EXTENDED_FLAGS remains 0. In the next patch, CE_EXTENDED_FLAGS will
be updated to have CE_NO_CHECKOUT.
--
Duy
^ permalink raw reply
* Re: What's cooking in gitweb (20 Sep 2008)
From: Junio C Hamano @ 2008-09-21 4:54 UTC (permalink / raw)
To: Jakub Narebski
Cc: git, Giuseppe Bilotta, Lea Wiemann, J.H.,
Gustavo Sverzut Barbieri
In-Reply-To: <200809210138.01874.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Junio, what about "[PATCH] avoid gitweb uninitialized value warning"
> (http://thread.gmane.org/gmane.comp.version-control.git/95028)? This
> is pure bugfix (well, warning fix, and failrly rare one, but warning
> which goes to web server logs).
Thanks for a summary. I think I've applied this one a few days ago to
'maint' and merged the result up.
^ permalink raw reply
* Re: [PATCH 1/7] Windows: Add workaround for MSYS' path conversion
From: Steffen Prohaska @ 2008-09-21 7:48 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin
In-Reply-To: <200808172235.48321.johannes.sixt@telecom.at>
On Aug 17, 2008, at 10:35 PM, Johannes Sixt wrote:
> On Sonntag, 17. August 2008, Steffen Prohaska wrote:
>> MSYS' automatic path conversion causes problems when passing paths
>> as '-D'
>> arguments to the compiler. MSYS tries to be smart and converts
>> absolute
>> paths to native Windows paths. But we want the paths as we compute
>> them in
>> the Makefile.
>
> Huh? Doesn't the Makefile compute paths like "/c/path/to/git"? We
> certainly
> don't want to compile such paths into git that in Windows speak
> actually
> mean "c:/path/to/git" - git is not an MSYS program and wouldn't
> understand
> the former. Which form of conversion are you refering to?
MSYS' automatic path conversion causes problems when passing paths as
defines ('-D' arguments to the compiler). MSYS tries to be smart and
converts absolute paths to native Windows paths, e.g. if MSYS sees
"/bin" it converts it to "c:/msysgit/bin". But we want completely
unmodified paths; e.g. if we set bindir in the Makefile to "/bin", the
define BINDIR shall expand to "/bin". Conversion to absolute Windows
path will takes place later, during runtime.
I'll update the commit message.
Steffen
^ permalink raw reply
* [funny] "git checkout -t origin/xyzzy" seems to misbehave
From: Junio C Hamano @ 2008-09-21 8:23 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Daniel Barkalow
When you
* are on a branch "foo" that is not "bar",
* have "origin/bar",
* and already have a local branch "bar",
"git checkout -t origin/bar" seems to misbehave.
$ git clone -s git.junio victim-002
$ cd victim-002
$ git branch
* master
$ git checkout -t origin/next
Branch next set up to track remote branch refs/remotes/origin/next.
Switched to a new branch "next"
$ git checkout -t origin/master
fatal: A branch named 'master' already exists.
$ git branch
master
* next
$ git diff --cached --shortstat
60 files changed, 2378 insertions(+), 3412 deletions(-)
$ git diff --cached master
$ exit
The first "checkout -t" is fine. The failed one seems to have already
updated the index and the work tree when it notices that it cannot create
a new branch.
I suspect "-t" does not have to be in effect to trigger this; in other
words, "git checkout -b master origin/master" would have the same issue.
I'm reporting this before digging it further myself, because I may not be
able to diagnose this before I leave for a vacation.
^ permalink raw reply
* Re: [PATCH v2 00/14] Sparse checkout
From: Nguyen Thai Ngoc Duy @ 2008-09-21 10:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jakub Narebski, git
In-Reply-To: <7vzlm21n83.fsf@gitster.siamese.dyndns.org>
On 9/21/08, Junio C Hamano <gitster@pobox.com> wrote:
> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
>
> > On 9/21/08, Jakub Narebski <jnareb@gmail.com> wrote:
>
> > ...
>
> >> >> BTW I think that the same rules are used in gitattributes, aren't
> >> >> they?
> >> >
> >> > They have different implementations. Though the rules may be the same.
> >>
> >> Were you able to reuse either one?
> >
> > No. .gitignore is tied to read_directory() while .gitattributes has
> > attributes attached. So I rolled out another one for index.
>
>
> I am sorry, but that sounds like a rather lame excuse. It certainly is
> possible to introduce an "ignored" attribute and have .gitattributes file
> specify that, instead of having an entry in .gitignore file, if you teach
> read_directory() to pay attention to the attributes mechanism. If we had
> from day one that a more generic gitattributes mechanism, I would imagine
> we wouldn't even had a separate .gitignore codepath but used the attribute
> mechanism throughout the system.
>
> Now I do not think we are ever going to deprecate gitignore and move
> everybody to "ignored" attributes, because such a transition would not buy
> the end users anything, but it technically is possible and would have been
> the right thing to do, if we were building the system from scratch. We
> still could add it as an optional feature (i.e. if a path has the
> attribute that says "ignored" or "not ignored", then that determines the
> fate of the path, otherwise we look at gitignore).
>
> I wouldn't be surprised if an alternative implementation of your code to
> assign "sparseness" to each path internally used "to-be-checked-out"
> attribute, and used that attribute to control how ls-files filters its
> output.
>
> A better excuse might have been that "I am not reading these patterns from
> anywhere but command line", but that got me thinking further.
That "from command line" piece makes a bit of difference. For example
patterns separated by colons and backslash escape, but that does not
stop it from reusing attr.c.
> How would that --narrow-match that is not stored anywhere on the
> filesystem but used only for filtering the output be any more useful than
> a grep that filters ls-files output in practice?
Well, it works exactly like 'grep' internally.
> I would imagine it would be much more useful if .git/info/attributes can
> specify "checkout" attribute that is defined like this:
>
> `checkout`
> ^^^^^^^^^^
>
> This attribute controls if the path can be left not checked-out to the
> working tree.
>
> Unset::
> Unsetting the `checkout` marks the path not to be checked out.
>
> Unspecified::
> A path which does not have any `checkout` attribute specified is
> handled in no special way.
>
> Any value set to `checkout` is ignored, and git acts as if the
> attribute is left unspecified.
>
> Then whenever a new path enters the index, you _could_ check with the
> attribute mechanism to set the CE_NOCHECKOUT flag. Just like an already
> tracked path is not ignored even if it matches .gitignore pattern, a path
> without CE_NOCHECKOUT that is in the index is checked out even if it has
> checkout attribute Unset.
>
> Hmm?
Well I think people would want to save no-checkout rules eventually.
But I don't know how they want to use it. Will the saved rules be hard
restriction, that no files can be checked out outside defined areas?
Will it be to save a couple of keystrokes, that is, instead of
typing "--reset-sparse=blah" all the time, now just "--reset-sparse"
and default rules will be applied? Your suggestion would be the third,
applying on new files only.
Anyway I will try to extend attr.c a bit to take input from command
line, then move "sparse patterns" over to use attr.c.
--
Duy
^ permalink raw reply
* Re: git-am strips final ')' character from author name
From: Jeff King @ 2008-09-21 10:18 UTC (permalink / raw)
To: AI; +Cc: git
In-Reply-To: <2f54d7a20809191058w558f3a28nc1537dc82f4a6ec2@mail.gmail.com>
On Fri, Sep 19, 2008 at 07:58:14PM +0200, AI wrote:
> Applying attached patch with git-am strips the ')' character from the name.
Are you using 1.5.x? This seems to be fixed in v1.6.0 by 0d4ede9f
(mailinfo: better parse email adresses containg parentheses).
-Peff
^ permalink raw reply
* Re: [PATCH] Builtin-commit: show on which branch a commit was added
From: Jeff King @ 2008-09-21 10:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pieter de Bie, Git Mailinglist
In-Reply-To: <7vzlmkpltb.fsf@gitster.siamese.dyndns.org>
On Sat, Sep 06, 2008 at 10:27:44PM -0700, Junio C Hamano wrote:
> Given the recent "reminder" discussion, I suspect people without $PS1 set
> to show the current branch would like this, majority of others would be
> neutral, while some may actively hate it for cluttering the output even
> more. But I also suspect the initial annoyance the third camp may feel
> will pass rather quickly after they get used to seeing these.
OK, I have lived with it for a little while, and I am still annoyed. ;)
My complaints are:
1. It wastes more horizontal screen real estate, making it more likely
that the line will wrap.
2. In almost all of my projects (including git), I use the subject
line convention of "subsystem: one line summary". So you end up
with the visually confusing:
Created commit abcd1234 on master: subsystem: one line summary
which is even worse on a topic branch which is meaningful to the
project:
Created commit abcd1234 on widget: subwidget: one line summary
which has literally left me scratching my head wondering why I put
"widget" into the commit message.
Maybe it is better to simply break the line, which solves both problems.
Something like:
Created commit abcd1234 on master:
subsystem: do some stuff
1 files changes, 1 insertions(+), 0 deletions(-)
Trivial patch is below.
---
diff --git a/builtin-commit.c b/builtin-commit.c
index 917f638..53dcde6 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -899,7 +899,7 @@ static char *get_commit_format_string(void)
strbuf_addch(&buf, *cp);
}
}
- strbuf_addstr(&buf, ": %s");
+ strbuf_addstr(&buf, ":%n %s");
return strbuf_detach(&buf, NULL);
}
^ permalink raw reply related
* Re: [PATCH v2 00/14] Sparse checkout
From: Jakub Narebski @ 2008-09-21 10:49 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: Junio C Hamano, git
In-Reply-To: <fcaeb9bf0809210311x7e9337fbmd978e95aa7998525@mail.gmail.com>
On Sun, 21 Sep 2008, Nguyen Thai Ngoc Duy wrote:
> On 9/21/08, Junio C Hamano <gitster@pobox.com> wrote:
> > How would that --narrow-match that is not stored anywhere on the
> > filesystem but used only for filtering the output be any more useful than
> > a grep that filters ls-files output in practice?
>
> Well, it works exactly like 'grep' internally.
>
> > I would imagine it would be much more useful if .git/info/attributes can
> > specify "checkout" attribute that is defined like this:
> >
> > `checkout`
> > ^^^^^^^^^^
[...]
> > Then whenever a new path enters the index, you _could_ check with the
> > attribute mechanism to set the CE_NOCHECKOUT flag. Just like an already
> > tracked path is not ignored even if it matches .gitignore pattern, a path
> > without CE_NOCHECKOUT that is in the index is checked out even if it has
> > checkout attribute Unset.
> >
> > Hmm?
>
> Well I think people would want to save no-checkout rules eventually.
> But I don't know how they want to use it. Will the saved rules be hard
> restriction, that no files can be checked out outside defined areas?
> Will it be to save a couple of keystrokes, that is, instead of
> typing "--reset-sparse=blah" all the time, now just "--reset-sparse"
> and default rules will be applied? Your suggestion would be the third,
> applying on new files only.
>
> Anyway I will try to extend attr.c a bit to take input from command
> line, then move "sparse patterns" over to use attr.c.
First, I think that this was Junio asking for discussion more than
for changing the design.
Second, while unifying the "check the match" part of gitignore,
gitattribute and sparse checkout would be IMVHO a good idea, I'm
not sure if trying to use/reuse attr.c literally would be a good
idea, at least not without larger surgery. AFAIK, IIUC gitattributes
have some limitations, one of which that they are read from working
area (and there is no API for reading from tree); although this could
be enough for `checkout' attribute, which is not that different in
work from `smudge' attribute, or `crlf` attribute.
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: git-am strips final ')' character from author name
From: AI @ 2008-09-21 10:51 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20080921101808.GD3376@sigill.intra.peff.net>
On Sun, Sep 21, 2008 at 12:18, Jeff King <peff@peff.net> wrote:
> Are you using 1.5.x? This seems to be fixed in v1.6.0 by 0d4ede9f
> (mailinfo: better parse email adresses containg parentheses).
I'm using 1.5.4.3, even ubuntu intrepid still uses 1.5.6.3.
Ah well, more reasons to switch to debian.
^ permalink raw reply
* [JGIT PATCH] Test and fix handling of quotes in ~/.ssh/config
From: Jonas Fonseca @ 2008-09-21 11:25 UTC (permalink / raw)
To: sverre; +Cc: Robin Rosenberg, Shawn O. Pearce, git
In-Reply-To: <bd6139dc0809201819o5d6eb5b1r7bf0e46702c711d7@mail.gmail.com>
Removal of quoting had an off-by-one error, and was not handled for the
patterns used for the Host entry.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../spearce/jgit/transport/OpenSshConfigTest.java | 26 ++++++++++++++++++++
.../org/spearce/jgit/transport/OpenSshConfig.java | 5 ++-
2 files changed, 29 insertions(+), 2 deletions(-)
Sverre Rabbelier <alturin@gmail.com> wrote Sun, Sep 21, 2008:
> Heya,
Allo,
> I'm not involved with JGit, so feel free to discared this mail :).
Thanks, it made me dig a bit further, and find a bug.
> On Sun, Sep 21, 2008 at 00:29, Jonas Fonseca <fonseca@diku.dk> wrote:
> > - final String[] parts = line.split("[ \t=]", 2);
> > + final String[] parts = line.split("[ \t]*[= \t]", 2);
>
> Unless I'm guessing the purpose of this split wrong, wouldn't it be
> even better to go for "[ \t]*=[ \t]+", or something like that (e.g.,
> to allow for multiple tabs/spaces at the end as well).
The code using the split result trims tabs and spaces at the end, so the
main purpose of the regex is to find something that splits. This
something can be tabs/spaces or _optionally_ one '='.
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
index 8c1133d..ad6e79c 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
@@ -105,6 +105,32 @@ config("Host\tfirst\n" +
assertEquals("last.tld", osc.lookup("last").getHostName());
}
+ public void testQuoteParsing() throws Exception {
+ config("Host \"good\"\n" +
+ " HostName=\"good.tld\"\n" +
+ " Port=\"6007\"\n" +
+ " User=\"gooduser\"\n" +
+ "Host multiple unquoted and \"quoted\" \"hosts\"\n" +
+ " Port=\"2222\"\n" +
+ "Host \"spaced\"\n" +
+ "# Bad host name, but testing preservation of spaces\n" +
+ " HostName=\" spaced\ttld \"\n" +
+ "# Misbalanced quotes\n" +
+ "Host \"bad\"\n" +
+ "# OpenSSH doesn't allow this but ...\n" +
+ " HostName=bad.tld\"\n");
+ assertEquals("good.tld", osc.lookup("good").getHostName());
+ assertEquals("gooduser", osc.lookup("good").getUser());
+ assertEquals(6007, osc.lookup("good").getPort());
+ assertEquals(2222, osc.lookup("multiple").getPort());
+ assertEquals(2222, osc.lookup("quoted").getPort());
+ assertEquals(2222, osc.lookup("and").getPort());
+ assertEquals(2222, osc.lookup("unquoted").getPort());
+ assertEquals(2222, osc.lookup("hosts").getPort());
+ assertEquals(" spaced\ttld ", osc.lookup("spaced").getHostName());
+ assertEquals("bad.tld\"", osc.lookup("bad").getHostName());
+ }
+
public void testAlias_DoesNotMatch() throws Exception {
config("Host orcz\n" + "\tHostName repo.or.cz\n");
final Host h = osc.lookup("repo.or.cz");
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java
index a9c6c12..b08d5c6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java
@@ -173,7 +173,8 @@ public Host lookup(final String hostName) {
if ("Host".equalsIgnoreCase(keyword)) {
current.clear();
- for (final String name : argValue.split("[ \t]")) {
+ for (final String pattern : argValue.split("[ \t]")) {
+ final String name = dequote(pattern);
Host c = m.get(name);
if (c == null) {
c = new Host();
@@ -243,7 +244,7 @@ private static boolean isHostMatch(final String pattern, final String name) {
private static String dequote(final String value) {
if (value.startsWith("\"") && value.endsWith("\""))
- return value.substring(1, value.length() - 2);
+ return value.substring(1, value.length() - 1);
return value;
}
--
1.6.0.2.444.gf2494
--
Jonas Fonseca
^ permalink raw reply related
* Re: [PATCH v2 00/14] Sparse checkout
From: Nguyen Thai Ngoc Duy @ 2008-09-21 11:32 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Junio C Hamano, git
In-Reply-To: <200809211249.10016.jnareb@gmail.com>
On 9/21/08, Jakub Narebski <jnareb@gmail.com> wrote:
> On Sun, 21 Sep 2008, Nguyen Thai Ngoc Duy wrote:
> > On 9/21/08, Junio C Hamano <gitster@pobox.com> wrote:
>
>
> > > How would that --narrow-match that is not stored anywhere on the
> > > filesystem but used only for filtering the output be any more useful than
> > > a grep that filters ls-files output in practice?
> >
> > Well, it works exactly like 'grep' internally.
> >
> > > I would imagine it would be much more useful if .git/info/attributes can
> > > specify "checkout" attribute that is defined like this:
> > >
> > > `checkout`
> > > ^^^^^^^^^^
>
> [...]
>
>
> > > Then whenever a new path enters the index, you _could_ check with the
> > > attribute mechanism to set the CE_NOCHECKOUT flag. Just like an already
> > > tracked path is not ignored even if it matches .gitignore pattern, a path
> > > without CE_NOCHECKOUT that is in the index is checked out even if it has
> > > checkout attribute Unset.
> > >
> > > Hmm?
> >
> > Well I think people would want to save no-checkout rules eventually.
> > But I don't know how they want to use it. Will the saved rules be hard
> > restriction, that no files can be checked out outside defined areas?
> > Will it be to save a couple of keystrokes, that is, instead of
> > typing "--reset-sparse=blah" all the time, now just "--reset-sparse"
> > and default rules will be applied? Your suggestion would be the third,
> > applying on new files only.
> >
> > Anyway I will try to extend attr.c a bit to take input from command
> > line, then move "sparse patterns" over to use attr.c.
>
>
> First, I think that this was Junio asking for discussion more than
> for changing the design.
I just tried to see if it was feasible. Checking the source again, I
misunderstood gitattributes/gitingore's leading '/' notion (in a good
way). Leading '/' means './' and that would be fine for
.git{attributes,ignore}. In sparse patterns, leading '/' means
toplevel directory because you may want to checkout some more from a
subdirectory without moving up to toplevel directory. Now
.git{ignore,attributes} and sparse patterns are incompatible, gaah...
> Second, while unifying the "check the match" part of gitignore,
> gitattribute and sparse checkout would be IMVHO a good idea, I'm
It is surely good. Optimization like 68492fc (Speedup scanning for
excluded files.) could be applied to .gitattributes too. Now I know
why I was confused when reading the matching part of
.git{attributes,ignore}.
--
Duy
^ permalink raw reply
* [PATCH] gitattributes documentation: link to gitignore for glob format
From: Nguyễn Thái Ngọc Duy @ 2008-09-21 12:43 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/gitattributes.txt | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 9a75257..45c11df 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -21,7 +21,9 @@ Each line in `gitattributes` file is of form:
glob attr1 attr2 ...
That is, a glob pattern followed by an attributes list,
-separated by whitespaces. When the glob pattern matches the
+separated by whitespaces. Glob pattern format is as same as
+one used by `gitignore` files. Please refer to linkgit:gitignore[5]
+for more information. When the glob pattern matches the
path in question, the attributes listed on the line are given to
the path.
--
1.6.0.2.427.g8dbf1
^ permalink raw reply related
* Re: [PATCH] gitattributes documentation: link to gitignore for glob format
From: Wincent Colaiuta @ 2008-09-21 13:00 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <1222001031-11382-1-git-send-email-pclouds@gmail.com>
El 21/9/2008, a las 14:43, Nguyễn Thái Ngọc Duy escribió:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> Documentation/gitattributes.txt | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/gitattributes.txt b/Documentation/
> gitattributes.txt
> index 9a75257..45c11df 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -21,7 +21,9 @@ Each line in `gitattributes` file is of form:
> glob attr1 attr2 ...
>
> That is, a glob pattern followed by an attributes list,
> -separated by whitespaces. When the glob pattern matches the
> +separated by whitespaces. Glob pattern format is as same as
It's "whitespace", not "whitespaces". And the sentence you added has
two errors:
"as same as" should be "the same as"
> +one used by `gitignore` files. Please refer to linkgit:gitignore[5]
> +for more information. When the glob pattern matches the
And: "as one" should be "as the one".
And as a style point, you probably should start the sentence with "The
glob pattern" rather than "Glob pattern".
Did you actually proofread this before sending it?
Cheers,
Wincent
^ permalink raw reply
* [PATCH] gitattributes documentation: link to gitignore for glob format
From: Nguyễn Thái Ngọc Duy @ 2008-09-21 13:23 UTC (permalink / raw)
To: git, Wincent Colaiuta; +Cc: Nguyễn Thái Ngọc Duy
In-Reply-To: <C4AD5305-CDD8-418D-95C8-C738A86E78E1@wincent.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
On 9/21/08, Wincent Colaiuta <win@wincent.com> wrote:
> Did you actually proofread this before sending it?
I did, but obviously I should have been more serious on
English classes.
Documentation/gitattributes.txt | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 9a75257..708a9b5 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -21,7 +21,9 @@ Each line in `gitattributes` file is of form:
glob attr1 attr2 ...
That is, a glob pattern followed by an attributes list,
-separated by whitespaces. When the glob pattern matches the
+separated by whitespace. The glob pattern format is the same as
+the one used by `gitignore` files. Please refer to linkgit:gitignore[5]
+for more information. When the glob pattern matches the
path in question, the attributes listed on the line are given to
the path.
--
1.6.0.2.427.g8dbf1
^ permalink raw reply related
* Re: Re* [RFC/PATCH] extend meaning of "--root" option to index comparisons
From: Jeff King @ 2008-09-21 13:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Anatol Pomozov, sverre, Git Mailing List
In-Reply-To: <7vskrvswxp.fsf@gitster.siamese.dyndns.org>
On Fri, Sep 19, 2008 at 01:27:46PM -0700, Junio C Hamano wrote:
> (1) A user getting an error message from "git init && git log" may be
> annoyed, but he very well knows there is no history yet _anyway_.
> This initial annoyance will pass immediately after creating any
> commit, so I do not think it is a big issue.
I think there is an additional case of script writers, who want their
scripts to fail gracefully or otherwise do the right thing with an
initial commit. Right now they have to special-case the initial commit.
I don't know if it is possible to have sane enough behavior that the
special case can be eliminated, or if it will simply make things worse.
> "bad default revision 'HEAD'" is a cryptic way to give that indicaion
> that can be improved but that is a separate issue. Rewording it so
> that it explains the situation better in user's terms would be a
> worthy improvement.
I agree that would be an improvement.
> (2) "--root" is about "do we show a creation event as a huge diff from
> emptyness?". Yes, we turn it on for "git log" but it does not have
> anything to do with the issue of yet to be born branch, where there
> isn't even a big creation event yet.
What about index comparisons? What should an index comparison to a
branch yet-to-be-born look like? Right now it is an error.
> I am reluctant to agree with the opinion that "git log" should be _silent_
> in a world without any history.
It feels a bit more Unix-y to me. That is, if I am asking for some set
of commits, and there are _no_ commits in the set, then I expect no
output. That makes sense for text processing.
> - argc = setup_revisions(argc, argv, rev, "HEAD");
> + argc = setup_revisions(argc, argv, rev, NULL);
> + if (!rev->pending.nr) {
> + add_head_to_pending(rev);
> + if (!rev->pending.nr) {
> + printf("No commits (yet).\n");
> + exit(0);
> + }
> + }
I like the idea of an improved message, but such a message should
definitely not go to stdout; it would feed nonsense to a command like
"git log | my_log_filter".
-Peff
^ permalink raw reply
* Re: TopGit: how to deal with upstream inclusion
From: Petr Baudis @ 2008-09-21 14:19 UTC (permalink / raw)
To: martin f krafft; +Cc: git
In-Reply-To: <20080919170406.GA22849@lapse.rw.madduck.net>
On Fri, Sep 19, 2008 at 06:04:06PM +0100, martin f krafft wrote:
> also sprach Petr Baudis <pasky@suse.cz> [2008.09.14.2203 +0100]:
> > (iii) Merge in RETIRED head branch with -s ours
>
> Yes, it does. One might want to consider to make the use of -s ours
> in (iiii) configurable, but otherwise that's it.
That might be pretty dangerous, since then your topic branch will have
outstanding branches of the retired branch, but they will _NOT_ be
visible to tg patch and others since they will be in both the base and
head.
--
Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC. -- Bill Gates
^ permalink raw reply
* Re: [ANNOUNCE] TopGit v0.3
From: Petr Baudis @ 2008-09-21 14:24 UTC (permalink / raw)
To: Jan Nieuwenhuizen; +Cc: martin f krafft, git
In-Reply-To: <1221648520.30402.12.camel@heerbeest>
On Wed, Sep 17, 2008 at 12:48:40PM +0200, Jan Nieuwenhuizen wrote:
> On vr, 2008-09-12 at 19:14 +0100, martin f krafft wrote:
>
> > I've considered this question a lot before and could not come up
> > with anything; you cannot undo a merge.
>
> Isn't that overly pessimistic? Can't we have git create a merge
> commit that can be reverted with git revert?
>
> For our ooo-build use case, I'm hoping to use [top]git as "a better
> patch" and hope to have mostly orthogonal topic branches. With patch,
> to "undo a merge" usually means patch -R and remove the patch from
> the dependency list. I can hardly imagine something easily possible
> with patch is still impossible with git.
The problem is that you can undo the merge content, but not the history
information. So this revert can e.g. propagate even into branches which
still *should* depend on the other branch, you get into trouble when you
want to make your branch depend on the other one anyway, etc.
Petr "Pasky" Baudis
^ permalink raw reply
* [StGit] kha/{safe,experimental} updated
From: Karl Hasselström @ 2008-09-21 15:37 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, David Kågedal, Daniel White
Just pushed out the stack log stuff to kha/safe. It really should be
ready for wider use at this point, and it was getting tiresome to keep
rebasing it.
One patch is still in experimental -- it depends on a new git feature
that isn't in any release yet.
There's also a patch for much improved bash completion support; I'll
post it as a reply to this mail.
-+-
The following changes since commit 3ce5fec2ef4154369653a41eb7692aca25878298:
Catalin Marinas (1):
Merge branch 'stable'
are available in the git repository at:
git://repo.or.cz/stgit/kha.git safe
Daniel White (1):
Fixes for auto-generation of man pages
David Kågedal (1):
Add support for initializing a branch for stgit from Emacs.
Karl Hasselström (24):
Auto-generate man pages for all StGit commands
asciidoc.conf: Steal updates from git
Generate command lists automatically
Write to a stack log when stack is modified
New command: stg reset
Log conflicts separately
Log conflicts separately for all commands
Add a --hard flag to stg reset
Don't write a log entry if there were no changes
Move stack reset function to a shared location
New command: stg undo
New command: stg redo
Log and undo external modifications
Test that stg coalesce handles head != top gracefully
Check for top == head at the start of every transaction
Make "stg log" show stack log instead of patch log
Convert "stg refresh" to the new infrastructure
New refresh tests
Remove --undo flags from stg commands and docs
Refactor stgit.commands.edit
Invoke the correct interactive editor
Implement "stg refresh --edit" again
Automatic bash completion
Read several objects at once with git cat-file --batch
.gitignore | 1 +
Documentation/.gitignore | 5 +-
Documentation/COMMAND-TEMPLATE.txt | 42 ---
Documentation/Makefile | 15 +-
Documentation/asciidoc.conf | 100 +++++--
Documentation/stg-branch.txt | 114 --------
Documentation/stg-clone.txt | 32 ---
Documentation/stg-init.txt | 29 --
Documentation/stg-new.txt | 115 --------
Documentation/stg-sink.txt | 49 ----
Documentation/stg.txt | 138 +----------
Documentation/tutorial.txt | 4 +-
INSTALL | 4 +-
Makefile | 21 ++-
TODO | 2 -
contrib/stgit-completion.bash | 270 -------------------
contrib/stgit.el | 12 +-
setup.py | 4 +-
stg-build | 41 +++
stgit/argparse.py | 260 +++++++++++++++---
stgit/commands/.gitignore | 1 +
stgit/commands/__init__.py | 78 ++++++
stgit/commands/branch.py | 148 +++++++----
stgit/commands/clean.py | 23 +-
stgit/commands/clone.py | 23 +-
stgit/commands/coalesce.py | 16 +-
stgit/commands/commit.py | 27 ++-
stgit/commands/common.py | 18 +-
stgit/commands/delete.py | 19 +-
stgit/commands/diff.py | 36 ++--
stgit/commands/edit.py | 106 ++------
stgit/commands/export.py | 53 ++--
stgit/commands/files.py | 31 ++-
stgit/commands/float.py | 24 +-
stgit/commands/fold.py | 26 +-
stgit/commands/goto.py | 16 +-
stgit/commands/hide.py | 23 +-
stgit/commands/id.py | 15 +-
stgit/commands/imprt.py | 98 ++++----
stgit/commands/init.py | 17 +-
stgit/commands/log.py | 192 +++++---------
stgit/commands/mail.py | 126 ++++-----
stgit/commands/new.py | 39 ++--
stgit/commands/patches.py | 27 +-
stgit/commands/pick.py | 57 ++--
stgit/commands/pop.py | 33 ++--
stgit/commands/pull.py | 28 +-
stgit/commands/push.py | 65 ++---
stgit/commands/rebase.py | 30 +-
stgit/commands/redo.py | 56 ++++
stgit/commands/refresh.py | 355 ++++++++++++++++--------
stgit/commands/rename.py | 32 ++-
stgit/commands/repair.py | 21 +-
stgit/commands/reset.py | 65 +++++
stgit/commands/resolved.py | 33 ++--
stgit/commands/series.py | 82 +++---
stgit/commands/show.py | 36 ++--
stgit/commands/sink.py | 46 +++-
stgit/commands/status.py | 61 ++---
stgit/commands/sync.py | 56 ++---
stgit/commands/top.py | 18 +-
stgit/commands/uncommit.py | 34 ++-
stgit/commands/undo.py | 53 ++++
stgit/commands/unhide.py | 24 +-
stgit/completion.py | 140 ++++++++++
stgit/git.py | 4 -
stgit/lib/edit.py | 99 +++++++
stgit/lib/git.py | 116 ++++++++-
stgit/lib/log.py | 524 ++++++++++++++++++++++++++++++++++++
stgit/lib/stack.py | 25 ++
stgit/lib/transaction.py | 128 ++++++---
stgit/main.py | 140 +---------
stgit/run.py | 19 ++
stgit/stack.py | 45 +---
stgit/utils.py | 22 +-
t/t1200-push-modified.sh | 2 +-
t/t1201-pull-trailing.sh | 2 +-
t/t1202-push-undo.sh | 8 +-
t/t1400-patch-history.sh | 103 -------
t/t2300-refresh-subdir.sh | 29 ++-
t/t2600-coalesce.sh | 13 +
t/t2701-refresh-p.sh | 2 +-
t/t3100-reset.sh | 160 +++++++++++
t/t3101-reset-hard.sh | 53 ++++
t/t3102-undo.sh | 81 ++++++
t/t3103-undo-hard.sh | 53 ++++
t/t3104-redo.sh | 114 ++++++++
t/t3105-undo-external-mod.sh | 65 +++++
t/t3300-edit.sh | 12 +-
t/test-lib.sh | 5 +-
90 files changed, 3348 insertions(+), 2241 deletions(-)
delete mode 100644 Documentation/COMMAND-TEMPLATE.txt
delete mode 100644 Documentation/stg-branch.txt
delete mode 100644 Documentation/stg-clone.txt
delete mode 100644 Documentation/stg-init.txt
delete mode 100644 Documentation/stg-new.txt
delete mode 100644 Documentation/stg-sink.txt
delete mode 100644 contrib/stgit-completion.bash
create mode 100755 stg-build
create mode 100644 stgit/commands/.gitignore
create mode 100644 stgit/commands/redo.py
create mode 100644 stgit/commands/reset.py
create mode 100644 stgit/commands/undo.py
create mode 100644 stgit/completion.py
create mode 100644 stgit/lib/edit.py
create mode 100644 stgit/lib/log.py
delete mode 100755 t/t1400-patch-history.sh
create mode 100755 t/t3100-reset.sh
create mode 100755 t/t3101-reset-hard.sh
create mode 100755 t/t3102-undo.sh
create mode 100755 t/t3103-undo-hard.sh
create mode 100755 t/t3104-redo.sh
create mode 100755 t/t3105-undo-external-mod.sh
-+-
The following changes since commit 2f34dbb4625e0c04a983229477a50ba4de7036bf:
Karl Hasselström (1):
Read several objects at once with git cat-file --batch
are available in the git repository at:
git://repo.or.cz/stgit/kha.git experimental
Karl Hasselström (1):
Diff several trees at once with git diff-tree --stdin
INSTALL | 5 +++--
stgit/lib/git.py | 37 +++++++++++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 6 deletions(-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* [StGit PATCH] Automatic bash completion
From: Karl Hasselström @ 2008-09-21 15:17 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git
In-Reply-To: <20080921153757.GA9098@diana.vm.bytemark.co.uk>
Teach the build process to create a bash tab completion script. This
has three benefits:
1. The tab completion gets faster, since it no longer has to run stg
to figure out the set of available flags for each command.
2. The tab completion script used to encode the list of stg
subcommands, and the kind of arguments each subcommand expected.
This information now lives in just one place: the subcommand's
module.
3. The tab completion script now knows what kind of argument each
flag wants, and can tab complete those as well. So "stg refresh
<tab>" will complete dirty files, but "stg refresh -p <tab>" will
complete patch names.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
.gitignore | 1
Makefile | 5 +
contrib/stgit-completion.bash | 270 -----------------------------------------
setup.py | 4 -
stg-build | 6 +
stgit/argparse.py | 92 ++++++++++++--
stgit/commands/branch.py | 3
stgit/commands/clean.py | 1
stgit/commands/clone.py | 3
stgit/commands/coalesce.py | 2
stgit/commands/commit.py | 3
stgit/commands/delete.py | 5 +
stgit/commands/diff.py | 4 +
stgit/commands/edit.py | 2
stgit/commands/export.py | 9 +
stgit/commands/files.py | 2
stgit/commands/float.py | 4 -
stgit/commands/fold.py | 5 -
stgit/commands/goto.py | 2
stgit/commands/hide.py | 6 +
stgit/commands/id.py | 3
stgit/commands/imprt.py | 3
stgit/commands/init.py | 1
stgit/commands/log.py | 7 +
stgit/commands/mail.py | 5 +
stgit/commands/new.py | 1
stgit/commands/patches.py | 5 -
stgit/commands/pick.py | 9 +
stgit/commands/pop.py | 3
stgit/commands/pull.py | 3
stgit/commands/push.py | 3
stgit/commands/rebase.py | 3
stgit/commands/redo.py | 1
stgit/commands/refresh.py | 4 -
stgit/commands/rename.py | 6 +
stgit/commands/repair.py | 1
stgit/commands/reset.py | 4 +
stgit/commands/resolved.py | 4 -
stgit/commands/series.py | 8 +
stgit/commands/show.py | 5 +
stgit/commands/sink.py | 6 +
stgit/commands/status.py | 3
stgit/commands/sync.py | 8 +
stgit/commands/top.py | 4 -
stgit/commands/uncommit.py | 6 +
stgit/commands/undo.py | 1
stgit/commands/unhide.py | 5 -
stgit/completion.py | 140 +++++++++++++++++++++
48 files changed, 354 insertions(+), 327 deletions(-)
delete mode 100644 contrib/stgit-completion.bash
create mode 100644 stgit/completion.py
diff --git a/.gitignore b/.gitignore
index 91dbad2..e7fffb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ patches-*
release.sh
setup.cfg.rpm
snapshot.sh
+stgit-completion.bash
diff --git a/Makefile b/Makefile
index 288622a..7183670 100644
--- a/Makefile
+++ b/Makefile
@@ -7,13 +7,16 @@ TEST_PATCHES ?= ..
all: build
$(PYTHON) setup.py build
-build: stgit/commands/cmdlist.py
+build: stgit/commands/cmdlist.py stgit-completion.bash
ALL_PY = $(shell find stgit -name '*.py')
stgit/commands/cmdlist.py: $(ALL_PY)
$(PYTHON) stg-build --py-cmd-list > $@
+stgit-completion.bash: $(ALL_PY)
+ $(PYTHON) stg-build --bash-completion > $@
+
install: build
$(PYTHON) setup.py install --prefix=$(prefix) --root=$(DESTDIR) --force
diff --git a/contrib/stgit-completion.bash b/contrib/stgit-completion.bash
deleted file mode 100644
index 1467c28..0000000
--- a/contrib/stgit-completion.bash
+++ /dev/null
@@ -1,270 +0,0 @@
-# bash completion support for StGIT -*- shell-script -*-
-#
-# Copyright (C) 2006, Karl Hasselström <kha@treskal.com>
-# Based on git-completion.sh
-#
-# To use these routines:
-#
-# 1. Copy this file to somewhere (e.g. ~/.stgit-completion.bash).
-#
-# 2. Add the following line to your .bashrc:
-# . ~/.stgit-completion.bash
-
-_stg_commands="
- branch
- delete
- diff
- clean
- clone
- coalesce
- commit
- edit
- export
- files
- float
- fold
- goto
- hide
- id
- import
- init
- log
- mail
- new
- patches
- pick
- pop
- pull
- push
- rebase
- refresh
- rename
- repair
- resolved
- series
- show
- sink
- status
- sync
- top
- uncommit
- unhide
-"
-
-# The path to .git, or empty if we're not in a repository.
-_gitdir ()
-{
- echo "$(git rev-parse --git-dir 2>/dev/null)"
-}
-
-# Name of the current branch, or empty if there isn't one.
-_current_branch ()
-{
- local b=$(git symbolic-ref HEAD 2>/dev/null)
- echo ${b#refs/heads/}
-}
-
-# List of all applied patches.
-_applied_patches ()
-{
- local g=$(_gitdir)
- [ "$g" ] && cat "$g/patches/$(_current_branch)/applied"
-}
-
-# List of all unapplied patches.
-_unapplied_patches ()
-{
- local g=$(_gitdir)
- [ "$g" ] && cat "$g/patches/$(_current_branch)/unapplied"
-}
-
-# List of all applied patches.
-_hidden_patches ()
-{
- local g=$(_gitdir)
- [ "$g" ] && cat "$g/patches/$(_current_branch)/hidden"
-}
-
-# List of all patches.
-_all_patches ()
-{
- local b=$(_current_branch)
- local g=$(_gitdir)
- [ "$g" ] && cat "$g/patches/$b/applied" "$g/patches/$b/unapplied"
-}
-
-# List of all patches except the current patch.
-_all_other_patches ()
-{
- local b=$(_current_branch)
- local g=$(_gitdir)
- [ "$g" ] && cat "$g/patches/$b/applied" "$g/patches/$b/unapplied" \
- | grep -v "^$(cat $g/patches/$b/current 2> /dev/null)$"
-}
-
-_all_branches ()
-{
- local g=$(_gitdir)
- [ "$g" ] && (cd $g/patches/ && echo *)
-}
-
-_conflicting_files ()
-{
- local g=$(_gitdir)
- [ "$g" ] && stg status --conflict
-}
-
-_dirty_files ()
-{
- local g=$(_gitdir)
- [ "$g" ] && stg status --modified --new --deleted
-}
-
-_unknown_files ()
-{
- local g=$(_gitdir)
- [ "$g" ] && stg status --unknown
-}
-
-_known_files ()
-{
- local g=$(_gitdir)
- [ "$g" ] && git ls-files
-}
-
-# List the command options
-_cmd_options ()
-{
- stg $1 --help 2>/dev/null | grep -e " --[A-Za-z]" | sed -e "s/.*\(--[^ =]\+\).*/\1/"
-}
-
-# Generate completions for patches and patch ranges from the given
-# patch list function, and options from the given list.
-_complete_patch_range ()
-{
- local patchlist="$1" options="$2"
- local pfx cur="${COMP_WORDS[COMP_CWORD]}"
- case "$cur" in
- *..*)
- pfx="${cur%..*}.."
- cur="${cur#*..}"
- COMPREPLY=($(compgen -P "$pfx" -W "$($patchlist)" -- "$cur"))
- ;;
- *)
- COMPREPLY=($(compgen -W "$options $($patchlist)" -- "$cur"))
- ;;
- esac
-}
-
-_complete_patch_range_options ()
-{
- local patchlist="$1" options="$2" patch_options="$3"
- local prev="${COMP_WORDS[COMP_CWORD-1]}"
- local cur="${COMP_WORDS[COMP_CWORD]}"
- local popt
- for popt in $patch_options; do
- if [ $prev == $popt ]; then
- _complete_patch_range $patchlist
- return
- fi
- done
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
-}
-
-_complete_branch ()
-{
- COMPREPLY=($(compgen -W "$(_cmd_options $1) $($2)" -- "${COMP_WORDS[COMP_CWORD]}"))
-}
-
-# Generate completions for options from the given list.
-_complete_options ()
-{
- local options="$1"
- COMPREPLY=($(compgen -W "$options" -- "${COMP_WORDS[COMP_CWORD]}"))
-}
-
-_complete_files ()
-{
- COMPREPLY=($(compgen -W "$(_cmd_options $1) $2" -- "${COMP_WORDS[COMP_CWORD]}"))
-}
-
-_stg_common ()
-{
- _complete_options "$(_cmd_options $1)"
-}
-
-_stg_patches ()
-{
- _complete_patch_range "$2" "$(_cmd_options $1)"
-}
-
-_stg_patches_options ()
-{
- _complete_patch_range_options "$2" "$(_cmd_options $1)" "$3"
-}
-
-_stg_help ()
-{
- _complete_options "$_stg_commands"
-}
-
-_stg ()
-{
- local i c=1 command
-
- while [ $c -lt $COMP_CWORD ]; do
- if [ $c == 1 ]; then
- command="${COMP_WORDS[c]}"
- fi
- c=$((++c))
- done
-
- # Complete name of subcommand.
- if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
- COMPREPLY=($(compgen \
- -W "--help --version copyright help $_stg_commands" \
- -- "${COMP_WORDS[COMP_CWORD]}"))
- return;
- fi
-
- # Complete arguments to subcommands.
- case "$command" in
- # generic commands
- help) _stg_help ;;
- # repository commands
- id) _stg_patches $command _all_patches ;;
- # stack commands
- coalesce) _stg_patches $command _applied_patches ;;
- float) _stg_patches $command _all_patches ;;
- goto) _stg_patches $command _all_other_patches ;;
- hide) _stg_patches $command _unapplied_patches ;;
- pop) _stg_patches $command _applied_patches ;;
- push) _stg_patches $command _unapplied_patches ;;
- series) _stg_patches $command _all_patches ;;
- sink) _stg_patches $command _all_patches ;;
- unhide) _stg_patches $command _hidden_patches ;;
- # patch commands
- delete) _stg_patches $command _all_patches ;;
- edit) _stg_patches $command _applied_patches ;;
- export) _stg_patches $command _all_patches ;;
- files) _stg_patches $command _all_patches ;;
- log) _stg_patches $command _all_patches ;;
- mail) _stg_patches $command _all_patches ;;
- pick) _stg_patches $command _unapplied_patches ;;
-# refresh)_stg_patches_options $command _applied_patches "-p --patch" ;;
- refresh) _complete_files $command "$(_dirty_files)" ;;
- rename) _stg_patches $command _all_patches ;;
- show) _stg_patches $command _all_patches ;;
- sync) _stg_patches $command _applied_patches ;;
- # working-copy commands
- diff) _stg_patches_options $command _applied_patches "-r --range" ;;
- resolved) _complete_files $command "$(_conflicting_files)" ;;
- # commands that usually raher accept branches
- branch) _complete_branch $command _all_branches ;;
- rebase) _complete_branch $command _all_branches ;;
- # all the other commands
- *) _stg_common $command ;;
- esac
-}
-
-complete -o default -F _stg stg
diff --git a/setup.py b/setup.py
index 81854d3..fb67958 100755
--- a/setup.py
+++ b/setup.py
@@ -59,8 +59,8 @@ def __run_setup():
('share/stgit/examples', glob.glob('examples/*.tmpl')),
('share/stgit/examples', ['examples/gitconfig']),
('share/stgit/contrib', ['contrib/diffcol.sh',
- 'contrib/stgbashprompt.sh',
- 'contrib/stgit-completion.bash']),
+ 'contrib/stgbashprompt.sh']),
+ ('share/stgit/completion', ['stgit-completion.bash'])
])
# Check the minimum versions required
diff --git a/stg-build b/stg-build
index 3c9dbfa..2af6523 100755
--- a/stg-build
+++ b/stg-build
@@ -2,7 +2,7 @@
# -*- python -*-
import optparse, sys
import stgit.main
-from stgit import argparse, commands
+from stgit import argparse, commands, completion
def main():
op = optparse.OptionParser()
@@ -14,6 +14,8 @@ def main():
help = 'Print asciidoc command list')
op.add_option('--py-cmd-list', action = 'store_true',
help = 'Write Python command list')
+ op.add_option('--bash-completion', action = 'store_true',
+ help = 'Write bash completion code')
options, args = op.parse_args()
if args:
op.error('Wrong number of arguments')
@@ -30,6 +32,8 @@ def main():
elif options.py_cmd_list:
commands.py_commands(commands.get_commands(allow_cached = False),
sys.stdout)
+ elif options.bash_completion:
+ completion.write_completion(sys.stdout)
else:
op.error('No command')
diff --git a/stgit/argparse.py b/stgit/argparse.py
index bd71817..406ada3 100644
--- a/stgit/argparse.py
+++ b/stgit/argparse.py
@@ -26,28 +26,27 @@ def _paragraphs(s):
class opt(object):
"""Represents a command-line flag."""
- def __init__(self, *args, **kwargs):
- self.args = args
+ def __init__(self, *pargs, **kwargs):
+ self.pargs = pargs
self.kwargs = kwargs
def get_option(self):
kwargs = dict(self.kwargs)
kwargs['help'] = kwargs['short']
- del kwargs['short']
- if 'long' in kwargs:
- del kwargs['long']
- return optparse.make_option(*self.args, **kwargs)
+ for k in ['short', 'long', 'args']:
+ kwargs.pop(k, None)
+ return optparse.make_option(*self.pargs, **kwargs)
def metavar(self):
o = self.get_option()
if not o.nargs:
return None
if o.metavar:
return o.metavar
- for flag in self.args:
+ for flag in self.pargs:
if flag.startswith('--'):
return utils.strip_prefix('--', flag).upper()
raise Exception('Cannot determine metavar')
def write_asciidoc(self, f):
- for flag in self.args:
+ for flag in self.pargs:
f.write(flag)
m = self.metavar()
if m:
@@ -60,6 +59,16 @@ class opt(object):
f.write('+\n')
for line in para:
f.write(line + '\n')
+ @property
+ def flags(self):
+ return self.pargs
+ @property
+ def args(self):
+ if self.kwargs.get('action', None) in ['store_true', 'store_false']:
+ default = []
+ else:
+ default = [files]
+ return self.kwargs.get('args', default)
def _cmd_name(cmd_mod):
return getattr(cmd_mod, 'name', cmd_mod.__name__.split('.')[-1])
@@ -103,11 +112,11 @@ def sign_options():
'--ack and --sign were both specified')
parser.values.sign_str = sign_str
return [
- opt('--sign', action = 'callback', dest = 'sign_str',
+ opt('--sign', action = 'callback', dest = 'sign_str', args = [],
callback = callback, callback_args = ('Signed-off-by',),
short = 'Add "Signed-off-by:" line', long = """
Add a "Signed-off-by:" to the end of the patch."""),
- opt('--ack', action = 'callback', dest = 'sign_str',
+ opt('--ack', action = 'callback', dest = 'sign_str', args = [],
callback = callback, callback_args = ('Acked-by',),
short = 'Add "Acked-by:" line', long = """
Add an "Acked-by:" line to the end of the patch.""")]
@@ -151,7 +160,7 @@ def message_options(save_template):
callback = msg_callback, dest = 'message', type = 'string',
short = 'Use MESSAGE instead of invoking the editor'),
opt('-f', '--file', action = 'callback', callback = file_callback,
- dest = 'message', type = 'string',
+ dest = 'message', type = 'string', args = [files],
short = 'Use FILE instead of invoking the editor', long = """
Use the contents of FILE instead of invoking the editor.
(If FILE is "-", write to stdout.)""")]
@@ -181,6 +190,7 @@ def diff_opts_option():
default = (config.get('stgit.diff-opts') or '').split(),
action = 'callback', callback = diff_opts_callback,
type = 'string', metavar = 'OPTIONS',
+ args = [strings('-M', '-C')],
short = 'Extra options to pass to "git diff"')]
def _person_opts(person, short):
@@ -212,3 +222,63 @@ def author_options():
def author_committer_options():
return _person_opts('author', 'auth') + _person_opts('committer', 'comm')
+
+class CompgenBase(object):
+ def actions(self, var): return set()
+ def words(self, var): return set()
+ def command(self, var):
+ cmd = ['compgen']
+ for act in self.actions(var):
+ cmd += ['-A', act]
+ words = self.words(var)
+ if words:
+ cmd += ['-W', '"%s"' % ' '.join(words)]
+ cmd += ['--', '"%s"' % var]
+ return ' '.join(cmd)
+
+class CompgenJoin(CompgenBase):
+ def __init__(self, a, b):
+ assert isinstance(a, CompgenBase)
+ assert isinstance(b, CompgenBase)
+ self.__a = a
+ self.__b = b
+ def words(self, var): return self.__a.words(var) | self.__b.words(var)
+ def actions(self, var): return self.__a.actions(var) | self.__b.actions(var)
+
+class Compgen(CompgenBase):
+ def __init__(self, words = frozenset(), actions = frozenset()):
+ self.__words = set(words)
+ self.__actions = set(actions)
+ def actions(self, var): return self.__actions
+ def words(self, var): return self.__words
+
+def compjoin(compgens):
+ comp = Compgen()
+ for c in compgens:
+ comp = CompgenJoin(comp, c)
+ return comp
+
+all_branches = Compgen(['$(_all_branches)'])
+stg_branches = Compgen(['$(_stg_branches)'])
+applied_patches = Compgen(['$(_applied_patches)'])
+other_applied_patches = Compgen(['$(_other_applied_patches)'])
+unapplied_patches = Compgen(['$(_unapplied_patches)'])
+hidden_patches = Compgen(['$(_hidden_patches)'])
+commit = Compgen(['$(_all_branches) $(_tags) $(_remotes)'])
+conflicting_files = Compgen(['$(_conflicting_files)'])
+dirty_files = Compgen(['$(_dirty_files)'])
+unknown_files = Compgen(['$(_unknown_files)'])
+known_files = Compgen(['$(_known_files)'])
+repo = Compgen(actions = ['directory'])
+dir = Compgen(actions = ['directory'])
+files = Compgen(actions = ['file'])
+def strings(*ss): return Compgen(ss)
+class patch_range(CompgenBase):
+ def __init__(self, *endpoints):
+ self.__endpoints = endpoints
+ def words(self, var):
+ words = set()
+ for e in self.__endpoints:
+ assert not e.actions(var)
+ words |= e.words(var)
+ return set(['$(_patch_range "%s" "%s")' % (' '.join(words), var)])
diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py
index ef71547..3d912fc 100644
--- a/stgit/commands/branch.py
+++ b/stgit/commands/branch.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git, basedir
+from stgit import argparse, stack, git, basedir
from stgit.lib import log
help = 'Branch operations: switch, list, create, rename, delete, ...'
@@ -45,6 +45,7 @@ within a git repository.
'stg branch' <branch>::
Switch to the given branch."""
+args = [argparse.all_branches]
options = [
opt('-l', '--list', action = 'store_true',
short = 'List the branches contained in this repository', long = """
diff --git a/stgit/commands/clean.py b/stgit/commands/clean.py
index 27a7716..9b48e7b 100644
--- a/stgit/commands/clean.py
+++ b/stgit/commands/clean.py
@@ -28,6 +28,7 @@ Delete the empty patches in the whole series or only those applied or
unapplied. A patch is considered empty if the two commit objects
representing its boundaries refer to the same tree object."""
+args = []
options = [
opt('-a', '--applied', action = 'store_true',
short = 'Delete the empty applied patches'),
diff --git a/stgit/commands/clone.py b/stgit/commands/clone.py
index 659712d..efb7198 100644
--- a/stgit/commands/clone.py
+++ b/stgit/commands/clone.py
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys, os
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Make a local clone of a remote repository'
kind = 'repo'
@@ -35,6 +35,7 @@ commands of stglink:branch[].
The target directory <dir> will be created by this command, and must
not already exist."""
+args = [argparse.repo, argparse.dir]
options = []
directory = DirectoryAnywhere(needs_current_series = False, log = False)
diff --git a/stgit/commands/coalesce.py b/stgit/commands/coalesce.py
index ef8e912..4b5c00a 100644
--- a/stgit/commands/coalesce.py
+++ b/stgit/commands/coalesce.py
@@ -34,6 +34,8 @@ If there are conflicts when reordering the patches to match the order
you specify, you will have to resolve them manually just as if you had
done a sequence of pushes and pops yourself."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [opt('-n', '--name', short = 'Name of coalesced patch')
] + argparse.message_options(save_template = True)
diff --git a/stgit/commands/commit.py b/stgit/commands/commit.py
index 99b7b5d..dd8d6e6 100644
--- a/stgit/commands/commit.py
+++ b/stgit/commands/commit.py
@@ -19,6 +19,7 @@ from stgit.argparse import opt
from stgit.commands import common
from stgit.lib import transaction
from stgit.out import *
+from stgit import argparse
help = 'Permanently store the applied patches into the stack base'
kind = 'stack'
@@ -40,6 +41,8 @@ The -n/--number option specifies the number of applied patches to
commit (counting from the bottom of the stack). If -a/--all is given,
all applied patches are committed."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
opt('-n', '--number', type = 'int',
short = 'Commit the specified number of patches'),
diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py
index b92a039..40cef3f 100644
--- a/stgit/commands/delete.py
+++ b/stgit/commands/delete.py
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from stgit.argparse import opt
from stgit.commands import common
from stgit.lib import transaction
+from stgit import argparse
help = 'Delete patches'
kind = 'patch'
@@ -28,8 +29,10 @@ Delete the patches passed as arguments.
Note that the 'delete' operation is irreversible."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch')]
directory = common.DirectoryHasRepositoryLib()
diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index 05f4f4c..7d2f719 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -38,8 +38,12 @@ representing the bottom of the current stack.
rev = '[branch:](<patch>|{base}) | <tree-ish>'"""
+args = [argparse.known_files, argparse.dirty_files]
options = [
opt('-r', '--range', metavar = 'rev1[..[rev2]]', dest = 'revs',
+ args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)],
short = 'Show the diff between revisions'),
opt('-s', '--stat', action = 'store_true',
short = 'Show the stat instead of the diff'),
diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index b370f5c..4904f68 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -54,6 +54,8 @@ If the patch diff is edited but does not apply, no changes are made to
the patch at all. The edited patch is saved to a file which you can
feed to "stg edit --file", once you have made sure it does apply."""
+args = [argparse.applied_patches, argparse.unapplied_patches,
+ argparse.hidden_patches]
options = [
opt('-d', '--diff', action = 'store_true',
short = 'Edit the patch diff'),
diff --git a/stgit/commands/export.py b/stgit/commands/export.py
index c7ed802..dfdcea1 100644
--- a/stgit/commands/export.py
+++ b/stgit/commands/export.py
@@ -47,8 +47,11 @@ file:
%(commname)s - committer's name
%(commemail)s - committer's e-mail"""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
- opt('-d', '--dir',
+ opt('-d', '--dir', args = [argparse.dir],
short = 'Export patches to DIR instead of the default'),
opt('-p', '--patch', action = 'store_true',
short = 'Append .patch to the patch names'),
@@ -56,9 +59,9 @@ options = [
short = 'Append .EXTENSION to the patch names'),
opt('-n', '--numbered', action = 'store_true',
short = 'Prefix the patch names with order numbers'),
- opt('-t', '--template', metavar = 'FILE',
+ opt('-t', '--template', metavar = 'FILE', args = [argparse.files],
short = 'Use FILE as a template'),
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch'),
opt('-s', '--stdout', action = 'store_true',
short = 'Dump the patches to the standard output'),
diff --git a/stgit/commands/files.py b/stgit/commands/files.py
index d63a33e..46d43c1 100644
--- a/stgit/commands/files.py
+++ b/stgit/commands/files.py
@@ -34,6 +34,8 @@ given patch. Note that this command doesn't show the files modified in
the working tree and not yet included in the patch by a 'refresh'
command. Use the 'diff' or 'status' commands for these files."""
+args = [argparse.applied_patches, argparse.unapplied_patches,
+ argparse.hidden_patches]
options = [
opt('-s', '--stat', action = 'store_true',
short = 'Show the diffstat'),
diff --git a/stgit/commands/float.py b/stgit/commands/float.py
index 93bb69b..7c3dcdf 100644
--- a/stgit/commands/float.py
+++ b/stgit/commands/float.py
@@ -20,7 +20,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Push patches to the top, even if applied'
kind = 'stack'
@@ -32,6 +32,8 @@ necessary pop and push operations will be performed to accomplish
this. The '--series' option can be used to rearrange the (top) patches
as specified by the given series file (or the standard input)."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
opt('-s', '--series', action = 'store_true',
short = 'Rearrange according to a series file')]
diff --git a/stgit/commands/fold.py b/stgit/commands/fold.py
index 165ff52..66a2dd9 100644
--- a/stgit/commands/fold.py
+++ b/stgit/commands/fold.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Integrate a GNU diff patch into the current patch'
kind = 'patch'
@@ -33,10 +33,11 @@ performed with the current top. With the --base option, the patch is
applied onto the specified base and a three-way merged is performed
with the current top."""
+args = [argparse.files]
options = [
opt('-t', '--threeway', action = 'store_true',
short = 'Perform a three-way merge with the current patch'),
- opt('-b', '--base',
+ opt('-b', '--base', args = [argparse.commit],
short = 'Use BASE instead of HEAD applying the patch')]
directory = DirectoryHasRepository(log = True)
diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py
index 0d4cd29..60a917e 100644
--- a/stgit/commands/goto.py
+++ b/stgit/commands/goto.py
@@ -17,6 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from stgit.commands import common
from stgit.lib import transaction
+from stgit import argparse
help = 'Push or pop patches to the given one'
kind = 'stack'
@@ -25,6 +26,7 @@ description = """
Push/pop patches to/from the stack until the one given on the command
line becomes current."""
+args = [argparse.other_applied_patches, argparse.unapplied_patches]
options = []
directory = common.DirectoryHasRepositoryLib()
diff --git a/stgit/commands/hide.py b/stgit/commands/hide.py
index 1bcb5f1..014febb 100644
--- a/stgit/commands/hide.py
+++ b/stgit/commands/hide.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Hide a patch in the series'
kind = 'stack'
@@ -29,8 +29,10 @@ description = """
Hide a range of unapplied patches so that they are no longer shown in
the plain 'series' command output."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch')]
directory = DirectoryHasRepository(log = True)
diff --git a/stgit/commands/id.py b/stgit/commands/id.py
index 857ec33..566edcc 100644
--- a/stgit/commands/id.py
+++ b/stgit/commands/id.py
@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from stgit.out import out
from stgit.commands import common
from stgit.lib import stack
+from stgit import argparse
help = 'Print the git hash value of a StGit reference'
kind = 'repo'
@@ -30,6 +31,8 @@ or the base of the stack. If no branch is specified, it defaults to the
current one. The bottom of a patch is accessible with the
'[<branch>:]<patch>^' format."""
+args = [argparse.applied_patches, argparse.unapplied_patches,
+ argparse.hidden_patches]
options = []
directory = common.DirectoryHasRepositoryLib()
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 9f2df05..de5e9a5 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -44,6 +44,7 @@ stack.
The patch description has to be separated from the data with a '---'
line."""
+args = [argparse.files]
options = [
opt('-m', '--mail', action = 'store_true',
short = 'Import the patch from a standard e-mail file'),
@@ -61,7 +62,7 @@ options = [
short = 'Ignore the applied patches in the series'),
opt('--replace', action = 'store_true',
short = 'Replace the unapplied patches in the series'),
- opt('-b', '--base',
+ opt('-b', '--base', args = [argparse.commit],
short = 'Use BASE instead of HEAD for file importing'),
opt('-e', '--edit', action = 'store_true',
short = 'Invoke an editor for the patch description'),
diff --git a/stgit/commands/init.py b/stgit/commands/init.py
index 67d20d1..6ffb93e 100644
--- a/stgit/commands/init.py
+++ b/stgit/commands/init.py
@@ -27,6 +27,7 @@ Initialise the current git branch to be used as an StGIT stack. The
branch (and the git repository it is in) must already exist and
contain at least one commit."""
+args = []
options = []
directory = common.DirectoryHasRepositoryLib()
diff --git a/stgit/commands/log.py b/stgit/commands/log.py
index 1f63ef5..39cdfe7 100644
--- a/stgit/commands/log.py
+++ b/stgit/commands/log.py
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os.path
from optparse import make_option
-from stgit import run
+from stgit import argparse, run
from stgit.argparse import opt
from stgit.commands import common
from stgit.lib import log
@@ -37,8 +37,11 @@ the named patches.
"stg undo" and "stg redo" let you step back and forth in the patch
stack. "stg reset" lets you go directly to any state."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default one'),
opt('-p', '--patch', action = 'store_true',
short = 'Show the refresh diffs'),
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index e0a5521..0b3157e 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -93,6 +93,9 @@ the following:
%(prefix)s - 'prefix ' string passed on the command line
%(shortdescr)s - the first line of the patch description"""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
opt('-a', '--all', action = 'store_true',
short = 'E-mail all the applied patches'),
@@ -134,7 +137,7 @@ options = [
short = 'Password for SMTP authentication'),
opt('-T', '--smtp-tls', action = 'store_true',
short = 'Use SMTP with TLS encryption'),
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch'),
opt('-m', '--mbox', action = 'store_true',
short = 'Generate an mbox file instead of sending')
diff --git a/stgit/commands/new.py b/stgit/commands/new.py
index 4117e4e..067882a 100644
--- a/stgit/commands/new.py
+++ b/stgit/commands/new.py
@@ -39,6 +39,7 @@ the patch, unless the '--message' flag already specified one. The
'patchdescr.tmpl' template file (if available) is used to pre-fill the
editor."""
+args = []
options = (argparse.author_committer_options()
+ argparse.message_options(save_template = True)
+ argparse.sign_options())
diff --git a/stgit/commands/patches.py b/stgit/commands/patches.py
index e877171..54fac21 100644
--- a/stgit/commands/patches.py
+++ b/stgit/commands/patches.py
@@ -21,7 +21,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Show the applied patches modifying a file'
kind = 'stack'
@@ -32,10 +32,11 @@ it shows the patches affected by the local tree modifications. The
'--diff' option also lists the patch log and the diff for the given
files."""
+args = [argparse.known_files]
options = [
opt('-d', '--diff', action = 'store_true',
short = 'Show the diff for the given files'),
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch')]
directory = DirectoryHasRepository(log = False)
diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py
index e1c531d..760918b 100644
--- a/stgit/commands/pick.py
+++ b/stgit/commands/pick.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
from stgit.stack import Series
help = 'Import a patch from a different branch or a commit object'
@@ -34,14 +34,17 @@ used as the name of the current patch. It can be overridden with the
option. The log and author information are those of the commit
object."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
opt('-n', '--name',
short = 'Use NAME as the patch name'),
- opt('-B', '--ref-branch',
+ opt('-B', '--ref-branch', args = [argparse.stg_branches],
short = 'Pick patches from BRANCH'),
opt('-r', '--reverse', action = 'store_true',
short = 'Reverse the commit object before importing'),
- opt('-p', '--parent', metavar = 'COMMITID',
+ opt('-p', '--parent', metavar = 'COMMITID', args = [argparse.commit],
short = 'Use COMMITID as parent'),
opt('-x', '--expose', action = 'store_true',
short = 'Append the imported commit id to the patch log'),
diff --git a/stgit/commands/pop.py b/stgit/commands/pop.py
index 855dc09..2c78ac2 100644
--- a/stgit/commands/pop.py
+++ b/stgit/commands/pop.py
@@ -20,7 +20,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Pop one or more patches from the stack'
kind = 'stack'
@@ -35,6 +35,7 @@ patches passed on the command line are popped from the stack. Some of
the push operations may fail because of conflicts ("stg undo" would
revert the last push operation)."""
+args = [argparse.patch_range(argparse.applied_patches)]
options = [
opt('-a', '--all', action = 'store_true',
short = 'Pop all the applied patches'),
diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index 82035c6..f6d1398 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -21,7 +21,7 @@ from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
from stgit.config import GitConfigException
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Pull changes from a remote repository'
kind = 'stack'
@@ -37,6 +37,7 @@ resolved and the patch pushed again.
Check the 'git fetch' documentation for the <repository> format."""
+args = [argparse.repo]
options = [
opt('-n', '--nopush', action = 'store_true',
short = 'Do not push the patches back after pulling'),
diff --git a/stgit/commands/push.py b/stgit/commands/push.py
index a7c7578..818e02d 100644
--- a/stgit/commands/push.py
+++ b/stgit/commands/push.py
@@ -21,7 +21,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Push one or more patches onto the stack'
kind = 'stack'
@@ -38,6 +38,7 @@ conflicting push with 'stg undo').
The command also notifies when the patch becomes empty (fully merged
upstream) or is modified (three-way merged) by the 'push' operation."""
+args = [argparse.patch_range(argparse.unapplied_patches)]
options = [
opt('-a', '--all', action = 'store_true',
short = 'Push all the unapplied patches'),
diff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py
index 60168ab..a4bc6e7 100644
--- a/stgit/commands/rebase.py
+++ b/stgit/commands/rebase.py
@@ -19,7 +19,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Move the stack base to another point in history'
kind = 'stack'
@@ -40,6 +40,7 @@ Or if you want to skip that patch:
$ stg undo --hard
$ stg push next-patch..top-patch"""
+args = [argparse.commit]
options = [
opt('-n', '--nopush', action = 'store_true',
short = 'Do not push the patches back after rebasing'),
diff --git a/stgit/commands/redo.py b/stgit/commands/redo.py
index 8e62a1d..eb8b20f 100644
--- a/stgit/commands/redo.py
+++ b/stgit/commands/redo.py
@@ -32,6 +32,7 @@ the effects of consecutive invocations of "stg undo".
It is an error to run "stg redo" if the last command was not an
undo."""
+args = []
options = [
opt('-n', '--number', type = 'int', metavar = 'N', default = 1,
short = 'Undo the last N undos'),
diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
index 3c82906..27cccc5 100644
--- a/stgit/commands/refresh.py
+++ b/stgit/commands/refresh.py
@@ -48,6 +48,7 @@ the patch stack log; this means that one undo step will undo the merge
between the other patch and the temp patch, and two undo steps will
additionally get rid of the temp patch."""
+args = [argparse.dirty_files]
options = [
opt('-u', '--update', action = 'store_true',
short = 'Only update the current patch files'),
@@ -55,7 +56,8 @@ options = [
short = 'Refresh from index instead of worktree', long = """
Instead of setting the patch top to the current contents of
the worktree, set it to the current contents of the index."""),
- opt('-p', '--patch',
+ opt('-p', '--patch', args = [argparse.other_applied_patches,
+ argparse.unapplied_patches],
short = 'Refresh (applied) PATCH instead of the top patch'),
opt('-e', '--edit', action = 'store_true',
short = 'Invoke an editor for the patch description'),
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index 7e0fbf5..8a593ac 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Rename a patch'
kind = 'patch'
@@ -29,8 +29,10 @@ description = """
Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not
given, the top-most patch will be renamed."""
+args = [argparse.applied_patches, argparse.unapplied_patches,
+ argparse.hidden_patches]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'use BRANCH instead of the default one')]
directory = DirectoryHasRepository(log = True)
diff --git a/stgit/commands/repair.py b/stgit/commands/repair.py
index ff9bb61..37c4bab 100644
--- a/stgit/commands/repair.py
+++ b/stgit/commands/repair.py
@@ -69,6 +69,7 @@ NOTE: If using git commands on the stack was a mistake, running "stg
repair" is _not_ what you want. In that case, what you want is option
(1) above."""
+args = []
options = []
directory = DirectoryGotoToplevel(log = True)
diff --git a/stgit/commands/reset.py b/stgit/commands/reset.py
index 3ccbf1b..7dfd4a0 100644
--- a/stgit/commands/reset.py
+++ b/stgit/commands/reset.py
@@ -21,6 +21,7 @@ from stgit.argparse import opt
from stgit.commands import common
from stgit.lib import git, log, transaction
from stgit.out import out
+from stgit import argparse
help = 'Reset the patch stack to an earlier state'
kind = 'stack'
@@ -33,6 +34,9 @@ a commit id from a stack log; "stg log" lets you view this log, and
If one or more patch names are given, reset only those patches, and
leave the rest alone."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
opt('--hard', action = 'store_true',
short = 'Discard changes in your index/worktree')]
diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py
index ce8630d..2ce7ec3 100644
--- a/stgit/commands/resolved.py
+++ b/stgit/commands/resolved.py
@@ -20,7 +20,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git, basedir
+from stgit import argparse, stack, git, basedir
from stgit.config import config, file_extensions
from stgit.gitmergeonefile import interactive_merge
@@ -32,10 +32,12 @@ Mark a merge conflict as resolved. The conflicts can be seen with the
'status' command, the corresponding files being prefixed with a
'C'."""
+args = [argparse.conflicting_files]
options = [
opt('-a', '--all', action = 'store_true',
short = 'Mark all conflicts as solved'),
opt('-r', '--reset', metavar = '(ancestor|current|patched)',
+ args = [argparse.strings('ancestor', 'current', 'patched')],
short = 'Reset the file(s) to the given state'),
opt('-i', '--interactive', action = 'store_true',
short = 'Run the interactive merging tool')]
diff --git a/stgit/commands/series.py b/stgit/commands/series.py
index e9d148a..95196d3 100644
--- a/stgit/commands/series.py
+++ b/stgit/commands/series.py
@@ -21,6 +21,7 @@ from stgit.commands import common
from stgit.commands.common import parse_patches
from stgit.out import out
from stgit.config import config
+from stgit import argparse
help = 'Print the patch series'
kind = 'stack'
@@ -31,8 +32,11 @@ range. The applied patches are prefixed with a '+', the unapplied ones
with a '-' and the hidden ones with a '!'. The current patch is
prefixed with a '>'. Empty patches are prefixed with a '0'."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch'),
opt('-a', '--all', action = 'store_true',
short = 'Show all patches, including the hidden ones'),
@@ -42,7 +46,7 @@ options = [
short = 'Show the unapplied patches only'),
opt('-H', '--hidden', action = 'store_true',
short = 'Show the hidden patches only'),
- opt('-m', '--missing', metavar = 'BRANCH',
+ opt('-m', '--missing', metavar = 'BRANCH', args = [argparse.stg_branches],
short = 'Show patches in BRANCH missing in current'),
opt('-c', '--count', action = 'store_true',
short = 'Print the number of patches in the series'),
diff --git a/stgit/commands/show.py b/stgit/commands/show.py
index e08551b..9a1f48b 100644
--- a/stgit/commands/show.py
+++ b/stgit/commands/show.py
@@ -28,8 +28,11 @@ description = """
Show the commit log and the diff corresponding to the given patches.
The output is similar to that generated by 'git show'."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches,
+ argparse.hidden_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch'),
opt('-a', '--applied', action = 'store_true',
short = 'Show the applied patches'),
diff --git a/stgit/commands/sink.py b/stgit/commands/sink.py
index 34f81c9..d4561ed 100644
--- a/stgit/commands/sink.py
+++ b/stgit/commands/sink.py
@@ -20,7 +20,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Send patches deeper down the stack'
kind = 'stack'
@@ -41,12 +41,14 @@ including <target patch>), then pushing the patches to sink, and then
(unless '--nopush' is also given) pushing back into place the
formerly-applied patches."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
opt('-n', '--nopush', action = 'store_true',
short = 'Do not push the patches back after sinking', long = """
Do not push back on the stack the formerly-applied patches.
Only the patches to sink are pushed."""),
- opt('-t', '--to', metavar = 'TARGET',
+ opt('-t', '--to', metavar = 'TARGET', args = [argparse.applied_patches],
short = 'Sink patches below the TARGET patch', long = """
Specify a target patch to place the patches below, instead of
sinking them to the bottom of the stack.""")]
diff --git a/stgit/commands/status.py b/stgit/commands/status.py
index c78bc1b..730b47c 100644
--- a/stgit/commands/status.py
+++ b/stgit/commands/status.py
@@ -20,7 +20,7 @@ import sys, os
from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Show the tree status'
kind = 'wc'
@@ -39,6 +39,7 @@ under revision control. The files are prefixed as follows:
An 'stg refresh' command clears the status of the modified, new and
deleted files."""
+args = [argparse.files]
options = [
opt('-m', '--modified', action = 'store_true',
short = 'Show modified files only'),
diff --git a/stgit/commands/sync.py b/stgit/commands/sync.py
index 966ac55..ea949d6 100644
--- a/stgit/commands/sync.py
+++ b/stgit/commands/sync.py
@@ -21,7 +21,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Synchronise patches with a branch or a series'
kind = 'patch'
@@ -33,12 +33,14 @@ for keeping patches on several branches in sync. Note that the
operation may fail for some patches because of conflicts. The patches
in the series must apply cleanly."""
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
options = [
opt('-a', '--all', action = 'store_true',
short = 'Synchronise all the applied patches'),
- opt('-B', '--ref-branch',
+ opt('-B', '--ref-branch', args = [argparse.stg_branches],
short = 'Syncronise patches with BRANCH'),
- opt('-s', '--series',
+ opt('-s', '--series', args = [argparse.files],
short = 'Syncronise patches with SERIES')]
directory = DirectoryGotoToplevel(log = True)
diff --git a/stgit/commands/top.py b/stgit/commands/top.py
index 523afa4..4ec37b4 100644
--- a/stgit/commands/top.py
+++ b/stgit/commands/top.py
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from stgit.argparse import opt
from stgit.commands import common
from stgit.out import out
+from stgit import argparse
help = 'Print the name of the top patch'
kind = 'stack'
@@ -26,8 +27,9 @@ usage = ['']
description = """
Print the name of the current (topmost) patch."""
+args = []
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch')]
directory = common.DirectoryHasRepositoryLib()
diff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py
index b9950ca..bcc8bac 100644
--- a/stgit/commands/uncommit.py
+++ b/stgit/commands/uncommit.py
@@ -21,7 +21,7 @@ from stgit.argparse import opt
from stgit.commands import common
from stgit.lib import transaction
from stgit.out import *
-from stgit import utils
+from stgit import argparse, utils
help = 'Turn regular git commits into StGit patches'
kind = 'stack'
@@ -49,10 +49,12 @@ given commit should be uncommitted.
Only commits with exactly one parent can be uncommitted; in other
words, you can't uncommit a merge."""
+args = []
options = [
opt('-n', '--number', type = 'int',
short = 'Uncommit the specified number of commits'),
- opt('-t', '--to', short = 'Uncommit to the specified commit'),
+ opt('-t', '--to', args = [argparse.commit],
+ short = 'Uncommit to the specified commit'),
opt('-x', '--exclusive', action = 'store_true',
short = 'Exclude the commit specified by the --to option')]
diff --git a/stgit/commands/undo.py b/stgit/commands/undo.py
index b7b1b73..6a04363 100644
--- a/stgit/commands/undo.py
+++ b/stgit/commands/undo.py
@@ -29,6 +29,7 @@ description = """
Reset the patch stack to the previous state. Consecutive invocations
of "stg undo" will take you ever further into the past."""
+args = []
options = [
opt('-n', '--number', type = 'int', metavar = 'N', default = 1,
short = 'Undo the last N commands'),
diff --git a/stgit/commands/unhide.py b/stgit/commands/unhide.py
index acfef29..0c0832a 100644
--- a/stgit/commands/unhide.py
+++ b/stgit/commands/unhide.py
@@ -20,7 +20,7 @@ from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
-from stgit import stack, git
+from stgit import argparse, stack, git
help = 'Unhide a hidden patch'
kind = 'stack'
@@ -29,8 +29,9 @@ description = """
Unhide a hidden range of patches so that they are shown in the plain
'stg series' command output."""
+args = [argparse.patch_range(argparse.hidden_patches)]
options = [
- opt('-b', '--branch',
+ opt('-b', '--branch', args = [argparse.stg_branches],
short = 'Use BRANCH instead of the default branch')]
directory = DirectoryHasRepository(log = True)
diff --git a/stgit/completion.py b/stgit/completion.py
new file mode 100644
index 0000000..e461e3b
--- /dev/null
+++ b/stgit/completion.py
@@ -0,0 +1,140 @@
+import textwrap
+import stgit.commands
+from stgit import argparse
+
+def fun(name, *body):
+ return ['%s ()' % name, '{', list(body), '}']
+
+def fun_desc(name, desc, *body):
+ return ['# %s' % desc] + fun(name, *body)
+
+def flatten(stuff, sep):
+ r = stuff[0]
+ for s in stuff[1:]:
+ r.append(sep)
+ r.extend(s)
+ return r
+
+def write(f, stuff, indent = 0):
+ for s in stuff:
+ if isinstance(s, str):
+ f.write((' '*4*indent + s).rstrip() + '\n')
+ else:
+ write(f, s, indent + 1)
+
+def patch_list_fun(type):
+ return fun('_%s_patches' % type, 'local g=$(_gitdir)',
+ 'test "$g" && cat "$g/patches/$(_current_branch)/%s"' % type)
+
+def file_list_fun(name, cmd):
+ return fun('_%s_files' % name, 'local g=$(_gitdir)',
+ 'test "$g" && %s' % cmd)
+
+def ref_list_fun(name, prefix):
+ return fun(name, 'local g=$(_gitdir)',
+ ("test \"$g\" && git show-ref | grep ' %s/' | sed 's,.* %s/,,'"
+ % (prefix, prefix)))
+
+def util():
+ r = [fun_desc('_gitdir',
+ "The path to .git, or empty if we're not in a repository.",
+ 'echo "$(git rev-parse --git-dir 2>/dev/null)"'),
+ fun_desc('_current_branch',
+ "Name of the current branch, or empty if there isn't one.",
+ 'local b=$(git symbolic-ref HEAD 2>/dev/null)',
+ 'echo ${b#refs/heads/}'),
+ fun_desc('_other_applied_patches',
+ 'List of all applied patches except the current patch.',
+ 'local b=$(_current_branch)',
+ 'local g=$(_gitdir)',
+ ('test "$g" && cat "$g/patches/$b/applied" | grep -v'
+ ' "^$(tail -n 1 $g/patches/$b/applied 2> /dev/null)$"')),
+ fun('_patch_range', 'local patches="$1"', 'local cur="$2"',
+ 'case "$cur" in', [
+ '*..*)', ['local pfx="${cur%..*}.."', 'cur="${cur#*..}"',
+ 'compgen -P "$pfx" -W "$patches" -- "$cur"', ';;'],
+ '*)', ['compgen -W "$patches" -- "$cur"', ';;']],
+ 'esac'),
+ fun('_stg_branches',
+ 'local g=$(_gitdir)', 'test "$g" && (cd $g/patches/ && echo *)'),
+ ref_list_fun('_all_branches', 'refs/heads'),
+ ref_list_fun('_tags', 'refs/tags'),
+ ref_list_fun('_remotes', 'refs/remotes')]
+ for type in ['applied', 'unapplied', 'hidden']:
+ r.append(patch_list_fun(type))
+ for name, cmd in [('conflicting',
+ r"git ls-files --unmerged | sed 's/.*\t//g' | sort -u"),
+ ('dirty', 'git diff-index --name-only HEAD'),
+ ('unknown', 'git ls-files --others --exclude-standard'),
+ ('known', 'git ls-files')]:
+ r.append(file_list_fun(name, cmd))
+ return flatten(r, '')
+
+def command_list(commands):
+ return ['_stg_commands="%s"\n' % ' '.join(sorted(commands.iterkeys()))]
+
+def command_fun(cmd, modname):
+ mod = stgit.commands.get_command(modname)
+ def cg(args, flags):
+ return argparse.compjoin(list(args) + [argparse.strings(*flags)]
+ ).command('$cur')
+ return fun(
+ '_stg_%s' % cmd,
+ 'local flags="%s"' % ' '.join(sorted(
+ flag for opt in mod.options
+ for flag in opt.flags if flag.startswith('--'))),
+ 'local prev="${COMP_WORDS[COMP_CWORD-1]}"',
+ 'local cur="${COMP_WORDS[COMP_CWORD]}"',
+ 'case "$prev" in', [
+ '%s) COMPREPLY=($(%s)) ;;' % ('|'.join(opt.flags), cg(opt.args, []))
+ for opt in mod.options if opt.args] + [
+ '*) COMPREPLY=($(%s)) ;;' % cg(mod.args, ['$flags'])],
+ 'esac')
+
+def main_switch(commands):
+ return fun(
+ '_stg',
+ 'local i',
+ 'local c=1',
+ 'local command',
+ '',
+ 'while test $c -lt $COMP_CWORD; do', [
+ 'if test $c == 1; then', [
+ 'command="${COMP_WORDS[c]}"'],
+ 'fi',
+ 'c=$((++c))'],
+ 'done',
+ '',
+ ('# Complete name of subcommand if the user has not finished'
+ ' typing it yet.'),
+ 'if test $c -eq $COMP_CWORD -a -z "$command"; then', [
+ ('COMPREPLY=($(compgen -W "$_stg_commands" --'
+ ' "${COMP_WORDS[COMP_CWORD]}"))'),
+ 'return'],
+ 'fi',
+ '',
+ '# Complete arguments to subcommands.',
+ 'case "$command" in', [
+ '%s) _stg_%s ;;' % (cmd, cmd)
+ for cmd in sorted(commands.iterkeys())],
+ 'esac')
+
+def install():
+ return ['complete -o default -F _stg stg']
+
+def write_completion(f):
+ commands = stgit.commands.get_commands(allow_cached = False)
+ r = [["""# -*- shell-script -*-
+# bash completion script for StGit (automatically generated)
+#
+# To use these routines:
+#
+# 1. Copy this file to somewhere (e.g. ~/.stgit-completion.bash).
+#
+# 2. Add the following line to your .bashrc:
+# . ~/.stgit-completion.bash"""]]
+ r += [util(), command_list(commands)]
+ for cmd, (modname, _, _) in sorted(commands.iteritems()):
+ r.append(command_fun(cmd, modname))
+ r += [main_switch(commands), install()]
+ write(f, flatten(r, ''))
^ permalink raw reply related
* Re: Re* [RFC/PATCH] extend meaning of "--root" option to index comparisons
From: Anatol Pomozov @ 2008-09-21 15:58 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, sverre, Git Mailing List
In-Reply-To: <20080921135616.GA25238@sigill.intra.peff.net>
Hi,
Jeff mostly explained what I expect from 'git log' and I agree with
him. We ('git log' 'git rev-parse' ...) should separate cases when
revision is broken (like we have a junk in the HEAD file) from the
case when "branch is not created yet" (which is part of normal
workflow).
What about following algorithm. HEAD points to ref and ref is not
created yet. Additional check could be
a) there are no other refs
or/and b) object database is empty
>> - argc = setup_revisions(argc, argv, rev, "HEAD");
>> + argc = setup_revisions(argc, argv, rev, NULL);
>> + if (!rev->pending.nr) {
>> + add_head_to_pending(rev);
>> + if (!rev->pending.nr) {
>> + printf("No commits (yet).\n");
>> + exit(0);
>> + }
>> + }
>
> I like the idea of an improved message, but such a message should
> definitely not go to stdout; it would feed nonsense to a command like
> "git log | my_log_filter".
+1 here. By default 'git log' should not output anything in this case,
even "No commits yet". Although such message would be fine for
something like "git log --verbose"
--
anatol
^ permalink raw reply
* [PATCH 1/7] Windows: Add workaround for MSYS' path conversion
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-1-git-send-email-prohaska@zib.de>
MSYS' automatic path conversion causes problems when passing paths as
defines ('-D' arguments to the compiler). MSYS tries to be smart and
converts absolute paths to native Windows paths, e.g. if MSYS sees
"/bin" it converts it to "c:/msysgit/bin". But we want completely
unmodified paths; e.g. if we set bindir in the Makefile to "/bin", the
define BINDIR shall expand to "/bin". Conversion to absolute Windows
path will takes place later, during runtime.
This commit adds a workaround by replacing "/" with its octal
representation "\057", effectively hiding the path from MSYS' path
conversion mechanism. MSYS does no longer see the absolute path and
therefore leaves it alone.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
Makefile | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 3c0664a..140a2b2 100644
--- a/Makefile
+++ b/Makefile
@@ -1066,6 +1066,12 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
htmldir_SQ = $(subst ','\'',$(htmldir))
prefix_SQ = $(subst ','\'',$(prefix))
+ETC_GITCONFIG_SQ_C = $(subst /,\057,$(ETC_GITCONFIG_SQ))
+bindir_SQ_C = $(subst /,\057,$(bindir_SQ))
+gitexecdir_SQ_C = $(subst /,\057,$(gitexecdir_SQ))
+htmldir_SQ_C = $(subst /,\057,$(htmldir_SQ))
+template_dir_SQ_C = $(subst /,\057,$(template_dir_SQ))
+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
@@ -1117,7 +1123,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
- '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
+ '-DGIT_HTML_PATH="$(htmldir_SQ_C)"' \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
@@ -1224,12 +1230,12 @@ git.o git.spec \
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
exec_cmd.o: exec_cmd.c GIT-CFLAGS
- $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
+ $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ_C)"' -DBINDIR='"$(bindir_SQ_C)"' $<
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
- $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
+ $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ_C)"' $<
config.o: config.c GIT-CFLAGS
- $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
+ $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ_C)"' $<
http.o: http.c GIT-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
--
1.6.0.2.GIT
^ 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