Git development
 help / color / mirror / Atom feed
* Re: [PATCH 1/4] git-gui i18n: Add more words to glossary.
From: Johannes Schindelin @ 2007-10-07 23:31 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Christian Stimming, git
In-Reply-To: <20071007231231.GD2137@spearce.org>

Hi,

On Sun, 7 Oct 2007, Shawn O. Pearce wrote:

> If you are sending a series like that and its all po translation stuff 
> that is unlikely to need commenting on feel free to just dump it all out 
> as a single mbox (`git format-patch --stdout`) and attach it to the 
> email.  Less chance of the MUA mangling the message.

In this case, I suggest just pushing it to git-gui-i18n.git, maybe as a 
temporary branch "for-shawn", and send a pull request.  That's the best 
way to ensure that nothing gets mangled.

Ciao,
Dscho

P.S.: Yeah, I haven't been really good with i18n recently; will try to put 
more work into it soon.

^ permalink raw reply

* Re: [PATCH] git-gui: offer a list of recent repositories on startup
From: Shawn O. Pearce @ 2007-10-07 23:30 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: git, msysgit
In-Reply-To: <11917925011987-git-send-email-prohaska@zib.de>

Steffen Prohaska <prohaska@zib.de> wrote:
> If git-gui is started outside a work tree the repository
> chooser will offer a list of recently opend repositories.
> Clicking on an entry directly opens the repository.
> 
> The list of recently opened repositories is stored in the
> config as gui.recentrepos. If the list grows beyond 10
> entries it will be truncated.
> 
> Note, only repositories that are opened through the
> repository chooser will get added to the recent list.
> Repositories opened from the shell will not yet be added.

I think that all makes a lot of sense.  Three comments below about
this patch in particular.
 
> I'd suggest to reduce the number of clicks needed to open or
> clone an existing directory that is not in the list of
> recent repositories. First choosing from the radiobuttons
> and then clicking next is one click to much. There are no
> options to combine. Choosing from the list should
> immediately trigger the action.
> 
> We could either put 'Create/Clone/Open New Repository' into
> the Repository menu and only present the recent repository
> list. Or we could offer push buttons for the other actions.

I agree entirely.  That "Next" button is stupid stupid stupid.
What was I smoking that day?  :-)

I'm concerned about putting them into the Repository menu only
as then the main window is competely void and users are sort of
wondering what they should do next.  I think we should actually
do both.  Put them into the menu and as push buttons on the window.

> +	label $w_body.space
> +	label $w_body.recentlabel \
> +		-anchor w \
> +		-text "Select Recent Repository:"

This string needs to be i18n'd with [mc ...].

> +	listbox $w_body.recentlist \

Please make a field in this class called say "w_recentlist"
so you can use that field name instead of $w_body.recentlist.
This simplifies the code if we ever have to change the actual path
that the widget resides at, such as to alter the layout.

> +proc _append_recentrepos {path} {
> +	set recent [get_config gui.recentrepos]
> +	if {[lsearch $recent $path] < 0} {
> +		lappend recent $path
> +	}
> +	if {[llength $recent] > 10} {
> +		set recent [lrange $recent 1 end]
> +	}
> +	regsub -all "\[{}\]" $recent {"} recent
> +	git config --global gui.recentrepos $recent
> +}

Why treat this as a Tcl list in a single value?  Why not make it
a true multi-value configuration entry in ~/.gitconfig, like how
remote.$name.fetch is a multi-value entry?  Does Windows allow
you to put " in a path name?  Because the above regex will make
a list of paths that contains " in one of the entries invalid.

I think you also want to have this function return back immediately
if [lsearch $recent $path] >= 0 as then you don't invoke git-config
to perform a no-op change in the configuration file.  As you well
know forking on Windows is a major cost.  We shouldn't run git-config
just because the user opened a recent repository.

-- 
Shawn.

^ permalink raw reply

* StGit kha safe branch updated
From: Karl Hasselström @ 2007-10-07 23:29 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

These are the assimilate patches, plus the two new series I just
mailed out.

The following changes since commit 764d110156e4951ca5671a700ee2402fa3597734:
  Yann Dirson (1):
        Better diagnostic for wrong branch configuration.

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git safe

Karl Hasselström (16):
      Teach "stg assimilate" to repair patch reachability
      Test the new powers of "stg assimilate"
      Let "stg assimilate" handle missing patches
      Add --ack/--sign options to "stg new"
      New test: "stg pop --keep"
      Fix up the help text for "stg edit"
      Don't split long and short description in "stg edit"
      Make a common superclass for all StGit exceptions
      Simplify debug level error checking
      Discard stderr output from git-rev-parse
      Remove the --force flag to "stg rebase" and "stg pull"
      Infrastructure for current directory handling
      New test: Try "stg push" in a subdirectory
      Make "stg push" subdirectory safe
      New test: try "stg refresh" in a subdirectory
      Make "stg refresh" subdirectory safe

 stgit/commands/add.py         |    1 +
 stgit/commands/applied.py     |    1 +
 stgit/commands/assimilate.py  |  199 +++++++++++++++++++++++++++++++----------
 stgit/commands/branch.py      |    1 +
 stgit/commands/clean.py       |    1 +
 stgit/commands/clone.py       |    1 +
 stgit/commands/commit.py      |    1 +
 stgit/commands/common.py      |   88 +++++++++++++++---
 stgit/commands/copy.py        |    1 +
 stgit/commands/delete.py      |    1 +
 stgit/commands/diff.py        |    1 +
 stgit/commands/edit.py        |   34 ++++----
 stgit/commands/export.py      |    1 +
 stgit/commands/files.py       |    1 +
 stgit/commands/float.py       |    1 +
 stgit/commands/fold.py        |    1 +
 stgit/commands/goto.py        |    1 +
 stgit/commands/hide.py        |    1 +
 stgit/commands/id.py          |    1 +
 stgit/commands/imprt.py       |    1 +
 stgit/commands/init.py        |    1 +
 stgit/commands/log.py         |    1 +
 stgit/commands/mail.py        |    1 +
 stgit/commands/new.py         |    7 +-
 stgit/commands/patches.py     |    1 +
 stgit/commands/pick.py        |    1 +
 stgit/commands/pop.py         |    1 +
 stgit/commands/pull.py        |    6 +-
 stgit/commands/push.py        |    1 +
 stgit/commands/rebase.py      |    6 +-
 stgit/commands/refresh.py     |    1 +
 stgit/commands/rename.py      |    1 +
 stgit/commands/resolved.py    |    1 +
 stgit/commands/rm.py          |    1 +
 stgit/commands/series.py      |    1 +
 stgit/commands/show.py        |    1 +
 stgit/commands/sink.py        |    1 +
 stgit/commands/status.py      |    1 +
 stgit/commands/sync.py        |    1 +
 stgit/commands/top.py         |    1 +
 stgit/commands/unapplied.py   |    1 +
 stgit/commands/uncommit.py    |    1 +
 stgit/commands/unhide.py      |    1 +
 stgit/config.py               |    3 +-
 stgit/exception.py            |    3 +
 stgit/git.py                  |    6 +-
 stgit/gitmergeonefile.py      |    3 +-
 stgit/main.py                 |   17 ++---
 stgit/run.py                  |    5 +-
 stgit/stack.py                |   20 +++-
 stgit/utils.py                |    3 +-
 t/t1204-pop-keep.sh           |   42 +++++++++
 t/t1205-push-subdir.sh        |   55 +++++++++++
 t/t1301-assimilate.sh         |   12 +--
 t/t1302-assimilate-interop.sh |   59 ++++++++++++
 t/t2100-pull-policy-fetch.sh  |   14 ---
 t/t2102-pull-policy-rebase.sh |   24 -----
 t/t2300-refresh-subdir.sh     |   27 ++++++
 58 files changed, 514 insertions(+), 156 deletions(-)
 create mode 100644 stgit/exception.py
 create mode 100755 t/t1204-pop-keep.sh
 create mode 100755 t/t1205-push-subdir.sh
 create mode 100755 t/t1302-assimilate-interop.sh
 create mode 100755 t/t2300-refresh-subdir.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: Trying to use git-filter-branch to compress history by removing large, obsolete binary files
From: Johannes Schindelin @ 2007-10-07 23:28 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Frank Lichtenheld, git
In-Reply-To: <51419b2c0710071624v79dc02d2g35a265add50dd46d@mail.gmail.com>

Hi,

On Sun, 7 Oct 2007, Elijah Newren wrote:

> On 10/7/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > On Sun, 7 Oct 2007, Elijah Newren wrote:
> >
> > > So...how do I fix the reflog, and then repack to have a pack under 
> > > 11MB in size?
> >
> > Just clone it.  The clone will be much smaller.
> 
> $ git clone test test2
> <snip>
> $ du -hs test
> 11M     test
> $ du -hs test2
> 11M     test2
> 
> Any other ideas?

Yep.  Maybe it is necessary to run "git gc" in test2.

Ciao,
Dscho

^ permalink raw reply

* Re: git fetch -- double fetch
From: Johannes Schindelin @ 2007-10-07 23:25 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: git
In-Reply-To: <20071007214433.GA30833@shadowen.org>

Hi,

On Sun, 7 Oct 2007, Andy Whitcroft wrote:

> On Sun, Oct 07, 2007 at 05:29:38PM +0100, Johannes Schindelin wrote:
>
> > On Sat, 6 Oct 2007, Andy Whitcroft wrote:
> > 
> > > I have recently been seeing repeated fetching of some branches.  I 
> > > feel this has happened in at least three of my repos on three 
> > > distinct projects:
> > > 
> > > apw@pinky$ git fetch origin
> > > remote: Generating pack...
> > > remote: Done counting 5 objects.
> > > remote: Deltifying 5 objects...
> > > remote:  100% (5/5) done
> > > Unpacking 5 objects...
> > > remote: Total 5 (delta 0), reused 0 (delta 0)
> > >  100% (5/5) done
> > > * refs/remotes/origin/master: fast forward to branch 'master' of ssh://git@abat-dev/var/www/git/abat
> > >   old..new: ce046f0..41c9dde
> > > * refs/remotes/origin/master: fast forward to branch 'master' of ssh://git@abat-dev/var/www/git/abat
> > >   old..new: ce046f0..41c9dde
> > 
> > What does "git config --get-all remote.origin.fetch" say?
> 
> apw@pinky$ git config --get-all remote.origin.fetch
> +refs/heads/master:refs/remotes/origin/master
> +refs/heads/*:refs/remotes/origin/*
> apw@pinky$
> 
> I don't think that I did anything to this config, I think that is what 
> the clone setup for me.

Actually, I am quite certain that git clone does not produce the first 
line; But I think that it was necessary to put in some line like that in 
older git, where the first ref was the one being merged by a pull.

But as I suspected, and Daniel replied, too, your issue is that both lines 
match "master".

You might want to delete the first line, and use "branch.<name>.remote" 
and "branch.<name>.merge" to force pull to merge "master" instead.

In the long run, it might be a good idea to cull duplicates in git-fetch, 
but for the moment I have enough other stuff to do ;-)

Ciao,
Dscho

^ permalink raw reply

* [StGit PATCH 5/5] Make "stg refresh" subdirectory safe
From: Karl Hasselström @ 2007-10-07 23:25 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231949.13070.49517.stgit@yoghurt>

Make "stg refresh" subdirectory safe by letting it internally cd up to
the top of the worktree. This is possibly not the best long-term fix;
one could argue that the refresh subroutine should instead be safe to
run from a subdirectory. However, refreshing from a subdirectory
currently only refreshes changes that are in the index, and not
changes in the working directory, and that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/refresh.py |    2 +-
 t/t2300-refresh-subdir.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
index b283892..f032375 100644
--- a/stgit/commands/refresh.py
+++ b/stgit/commands/refresh.py
@@ -37,7 +37,7 @@ options. The '--force' option is useful when a commit object was
 created with a different tool but the changes need to be included in
 the current patch."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryGotoToplevel()
 options = [make_option('-f', '--force',
                        help = 'force the refresh even if HEAD and '\
                        'top differ',
diff --git a/t/t2300-refresh-subdir.sh b/t/t2300-refresh-subdir.sh
index d1c7168..bdd27c5 100755
--- a/t/t2300-refresh-subdir.sh
+++ b/t/t2300-refresh-subdir.sh
@@ -15,7 +15,7 @@ test_expect_success 'Refresh from a subdirectory' '
     [ "$(stg status)" = "" ]
 '
 
-test_expect_failure 'Refresh again' '
+test_expect_success 'Refresh again' '
     echo foo2 >> foo.txt &&
     echo bar2 >> bar/bar.txt &&
     cd bar &&

^ permalink raw reply related

* [StGit PATCH 4/5] New test: try "stg refresh" in a subdirectory
From: Karl Hasselström @ 2007-10-07 23:25 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231949.13070.49517.stgit@yoghurt>

Currently, it doesn't work. Or rather, it does work for changes that
are already in the index, which is the case for newly added files; but
it doesn't work for changes that aren't in the index.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 t/t2300-refresh-subdir.sh |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100755 t/t2300-refresh-subdir.sh


diff --git a/t/t2300-refresh-subdir.sh b/t/t2300-refresh-subdir.sh
new file mode 100755
index 0000000..d1c7168
--- /dev/null
+++ b/t/t2300-refresh-subdir.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+test_description='Test the refresh command from a subdirectory'
+. ./test-lib.sh
+stg init
+
+test_expect_success 'Refresh from a subdirectory' '
+    stg new foo -m foo &&
+    echo foo >> foo.txt &&
+    mkdir bar &&
+    echo bar >> bar/bar.txt &&
+    stg add foo.txt bar/bar.txt &&
+    cd bar &&
+    stg refresh &&
+    cd .. &&
+    [ "$(stg status)" = "" ]
+'
+
+test_expect_failure 'Refresh again' '
+    echo foo2 >> foo.txt &&
+    echo bar2 >> bar/bar.txt &&
+    cd bar &&
+    stg refresh &&
+    cd .. &&
+    [ "$(stg status)" = "" ]
+'
+
+test_done

^ permalink raw reply related

* [StGit PATCH 3/5] Make "stg push" subdirectory safe
From: Karl Hasselström @ 2007-10-07 23:24 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231949.13070.49517.stgit@yoghurt>

Make "stg push" subdirectory safe by letting it internally cd up to
the top of the worktree. This is possibly not the best long-term fix;
one could argue that the push subroutine should instead be safe to run
from a subdirectory. However, pushing from a subdirectory currently
erases the parts of a patch that doesn't touch that subdirectory, and
that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/push.py |    2 +-
 t/t1205-push-subdir.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/stgit/commands/push.py b/stgit/commands/push.py
index b91bc5e..4d5de26 100644
--- a/stgit/commands/push.py
+++ b/stgit/commands/push.py
@@ -39,7 +39,7 @@ command run.
 The command also notifies when the patch becomes empty (fully merged
 upstream) or is modified (three-way merged) by the 'push' operation."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryGotoToplevel()
 options = [make_option('-a', '--all',
                        help = 'push all the unapplied patches',
                        action = 'store_true'),
diff --git a/t/t1205-push-subdir.sh b/t/t1205-push-subdir.sh
index 6502c20..f9a84f6 100755
--- a/t/t1205-push-subdir.sh
+++ b/t/t1205-push-subdir.sh
@@ -27,7 +27,7 @@ test_expect_success 'Fast-forward push from a subdir' '
     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
 '
 
-test_expect_failure 'Modifying push from a subdir' '
+test_expect_success 'Modifying push from a subdir' '
     stg pop &&
     [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
     [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
@@ -42,7 +42,7 @@ test_expect_failure 'Modifying push from a subdir' '
     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
 '
 
-test_expect_failure 'Conflicting push from subdir' '
+test_expect_success 'Conflicting push from subdir' '
     stg pop p1 p2 &&
     [ "$(echo $(cat x.txt))" = "x0" ] &&
     [ "$(echo $(cat foo/y.txt))" = "y0" ] &&

^ permalink raw reply related

* [StGit PATCH 2/5] New test: Try "stg push" in a subdirectory
From: Karl Hasselström @ 2007-10-07 23:24 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231949.13070.49517.stgit@yoghurt>

This currently fails for the non-fast-forward cases.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 t/t1205-push-subdir.sh |   55 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100755 t/t1205-push-subdir.sh


diff --git a/t/t1205-push-subdir.sh b/t/t1205-push-subdir.sh
new file mode 100755
index 0000000..6502c20
--- /dev/null
+++ b/t/t1205-push-subdir.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+test_description='Test the push command from a subdirectory'
+. ./test-lib.sh
+stg init
+
+test_expect_success 'Create some patches' '
+    mkdir foo
+    for i in 0 1 2; do
+        stg new p$i -m p$i &&
+        echo x$i >> x.txt &&
+        echo y$i >> foo/y.txt &&
+        stg add x.txt foo/y.txt &&
+        stg refresh
+    done &&
+    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg unapplied))" = "" ]
+'
+
+test_expect_success 'Fast-forward push from a subdir' '
+    stg pop &&
+    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
+    cd foo &&
+    stg push &&
+    cd .. &&
+    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
+'
+
+test_expect_failure 'Modifying push from a subdir' '
+    stg pop &&
+    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
+    stg new extra -m extra &&
+    echo extra >> extra.txt &&
+    stg add extra.txt &&
+    stg refresh &&
+    cd foo &&
+    stg push &&
+    cd .. &&
+    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
+'
+
+test_expect_failure 'Conflicting push from subdir' '
+    stg pop p1 p2 &&
+    [ "$(echo $(cat x.txt))" = "x0" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0" ] &&
+    cd foo &&
+    ! stg push p2 &&
+    cd .. &&
+    [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ]
+'
+
+test_done

^ permalink raw reply related

* [StGit PATCH 1/5] Infrastructure for current directory handling
From: Karl Hasselström @ 2007-10-07 23:24 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231949.13070.49517.stgit@yoghurt>

Add infrastructure to allow commands to specify if they need a git
repository, if they need to be called from within the working tree,
and if they should cd to the root of the working tree before doing
anything else.

For now, all commands are set to just require a repository (except
"stg clone", which is set to require nothing), which means the only
thing that's added is some very light error checking. The idea is to
tighten this for commands that turn out to need it.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/add.py        |    1 +
 stgit/commands/applied.py    |    1 +
 stgit/commands/assimilate.py |    1 +
 stgit/commands/branch.py     |    1 +
 stgit/commands/clean.py      |    1 +
 stgit/commands/clone.py      |    1 +
 stgit/commands/commit.py     |    1 +
 stgit/commands/common.py     |   68 ++++++++++++++++++++++++++++++++++++++++++
 stgit/commands/copy.py       |    1 +
 stgit/commands/delete.py     |    1 +
 stgit/commands/diff.py       |    1 +
 stgit/commands/edit.py       |    1 +
 stgit/commands/export.py     |    1 +
 stgit/commands/files.py      |    1 +
 stgit/commands/float.py      |    1 +
 stgit/commands/fold.py       |    1 +
 stgit/commands/goto.py       |    1 +
 stgit/commands/hide.py       |    1 +
 stgit/commands/id.py         |    1 +
 stgit/commands/imprt.py      |    1 +
 stgit/commands/init.py       |    1 +
 stgit/commands/log.py        |    1 +
 stgit/commands/mail.py       |    1 +
 stgit/commands/new.py        |    1 +
 stgit/commands/patches.py    |    1 +
 stgit/commands/pick.py       |    1 +
 stgit/commands/pop.py        |    1 +
 stgit/commands/pull.py       |    1 +
 stgit/commands/push.py       |    1 +
 stgit/commands/rebase.py     |    1 +
 stgit/commands/refresh.py    |    1 +
 stgit/commands/rename.py     |    1 +
 stgit/commands/resolved.py   |    1 +
 stgit/commands/rm.py         |    1 +
 stgit/commands/series.py     |    1 +
 stgit/commands/show.py       |    1 +
 stgit/commands/sink.py       |    1 +
 stgit/commands/status.py     |    1 +
 stgit/commands/sync.py       |    1 +
 stgit/commands/top.py        |    1 +
 stgit/commands/unapplied.py  |    1 +
 stgit/commands/uncommit.py   |    1 +
 stgit/commands/unhide.py     |    1 +
 stgit/main.py                |    2 +
 44 files changed, 112 insertions(+), 0 deletions(-)


diff --git a/stgit/commands/add.py b/stgit/commands/add.py
index fc9c5a7..264ab9f 100644
--- a/stgit/commands/add.py
+++ b/stgit/commands/add.py
@@ -31,6 +31,7 @@ Add the files or directories passed as arguments to the
 repository. When a directory name is given, all the files and
 subdirectories are recursively added."""
 
+directory = DirectoryHasRepository()
 options = []
 
 
diff --git a/stgit/commands/applied.py b/stgit/commands/applied.py
index b9bb716..45d0926 100644
--- a/stgit/commands/applied.py
+++ b/stgit/commands/applied.py
@@ -32,6 +32,7 @@ List the patches from the series which were already pushed onto the
 stack.  They are listed in the order in which they were pushed, the
 last one being the current (topmost) patch."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-c', '--count',
diff --git a/stgit/commands/assimilate.py b/stgit/commands/assimilate.py
index 43672fd..db8a95c 100644
--- a/stgit/commands/assimilate.py
+++ b/stgit/commands/assimilate.py
@@ -53,6 +53,7 @@ Note that these are "inconsistencies", not "errors"; furthermore,
 with the way "assimilate" handles them, you have no reason to avoid
 causing them in the first place if that is convenient for you."""
 
+directory = DirectoryHasRepository()
 options = []
 
 class Commit(object):
diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py
index c16fc69..6e0a6d8 100644
--- a/stgit/commands/branch.py
+++ b/stgit/commands/branch.py
@@ -40,6 +40,7 @@ When displaying the branches, the names can be prefixed with
 
 If not given any options, switch to the named branch."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-c', '--create',
                        help = 'create a new development branch',
                        action = 'store_true'),
diff --git a/stgit/commands/clean.py b/stgit/commands/clean.py
index 2e3b202..d8bbe71 100644
--- a/stgit/commands/clean.py
+++ b/stgit/commands/clean.py
@@ -31,6 +31,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."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--applied',
                        help = 'delete the empty applied patches',
                        action = 'store_true'),
diff --git a/stgit/commands/clone.py b/stgit/commands/clone.py
index 15139c8..a150010 100644
--- a/stgit/commands/clone.py
+++ b/stgit/commands/clone.py
@@ -29,6 +29,7 @@ usage = """%prog [options] <repository> <dir>
 Clone a GIT <repository> into the local <dir> and initialise the
 patch stack."""
 
+directory = DirectoryAnywhere()
 options = []
 
 
diff --git a/stgit/commands/commit.py b/stgit/commands/commit.py
index 0b76c56..2b45c0d 100644
--- a/stgit/commands/commit.py
+++ b/stgit/commands/commit.py
@@ -32,6 +32,7 @@ remove them from the series while advancing the base.
 Use this command only if you want to permanently store the applied
 patches and no longer manage them with StGIT."""
 
+directory = DirectoryHasRepository()
 options = []
 
 
diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index 9815400..27ef465 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -24,6 +24,7 @@ from optparse import OptionParser, make_option
 from stgit.exception import *
 from stgit.utils import *
 from stgit.out import *
+from stgit.run import *
 from stgit import stack, git, basedir
 from stgit.config import config, file_extensions
 
@@ -480,3 +481,70 @@ def parse_patch(fobj):
     # we don't yet have an agreed place for the creation date.
     # Just return None
     return (descr, authname, authemail, authdate, diff)
+
+def readonly_constant_property(f):
+    """Decorator that converts a function that computes a value to an
+    attribute that returns the value. The value is computed only once,
+    the first time it is accessed."""
+    def new_f(self):
+        n = '__' + f.__name__
+        if not hasattr(self, n):
+            setattr(self, n, f(self))
+        return getattr(self, n)
+    return property(new_f)
+
+class DirectoryException(StgException):
+    pass
+
+class _Directory(object):
+    @readonly_constant_property
+    def git_dir(self):
+        try:
+            return Run('git-rev-parse', '--git-dir'
+                       ).discard_stderr().output_one_line()
+        except RunException:
+            raise DirectoryException('No git repository found')
+    @readonly_constant_property
+    def __topdir_path(self):
+        try:
+            lines = Run('git-rev-parse', '--show-cdup'
+                        ).discard_stderr().output_lines()
+            if len(lines) == 0:
+                return '.'
+            elif len(lines) == 1:
+                return lines[0]
+            else:
+                raise RunException('Too much output')
+        except RunException:
+            raise DirectoryException('No git repository found')
+    @readonly_constant_property
+    def is_inside_git_dir(self):
+        return { 'true': True, 'false': False
+                 }[Run('git-rev-parse', '--is-inside-git-dir'
+                       ).output_one_line()]
+    @readonly_constant_property
+    def is_inside_worktree(self):
+        return { 'true': True, 'false': False
+                 }[Run('git-rev-parse', '--is-inside-work-tree'
+                       ).output_one_line()]
+    def cd_to_topdir(self):
+        os.chdir(self.__topdir_path)
+
+class DirectoryAnywhere(_Directory):
+    def setup(self):
+        pass
+
+class DirectoryHasRepository(_Directory):
+    def setup(self):
+        self.git_dir # might throw an exception
+
+class DirectoryInWorktree(DirectoryHasRepository):
+    def setup(self):
+        DirectoryHasRepository.setup(self)
+        if not self.is_inside_worktree:
+            raise DirectoryException('Not inside a git worktree')
+
+class DirectoryGotoToplevel(DirectoryInWorktree):
+    def setup(self):
+        DirectoryInWorktree.setup(self)
+        self.cd_to_topdir()
diff --git a/stgit/commands/copy.py b/stgit/commands/copy.py
index 76e3bf9..e94dd66 100644
--- a/stgit/commands/copy.py
+++ b/stgit/commands/copy.py
@@ -30,6 +30,7 @@ usage = """%prog [options] [<file/dir> <newname> | <files/dirs...> <dir>]
 Copy of the files and dirs passed as arguments under another name or
 location inside the same repository."""
 
+directory = DirectoryHasRepository()
 options = []
 
 def func(parser, options, args):
diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py
index 2121015..8462857 100644
--- a/stgit/commands/delete.py
+++ b/stgit/commands/delete.py
@@ -36,6 +36,7 @@ patches are deleted, they are popped from the stack.
 
 Note that the 'delete' operation is irreversible."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index aeca4ab..f3b0ea2 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -42,6 +42,7 @@ rev = '([patch][//[bottom | top]]) | <tree-ish> | base'
 If neither bottom nor top are given but a '//' is present, the command
 shows the specified patch (defaulting to the current one)."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-r', '--range',
                        metavar = 'rev1[..[rev2]]', dest = 'revs',
                        help = 'show the diff between revisions'),
diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index 223c628..02970bc 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -57,6 +57,7 @@ rejected patch is stored in the .stgit-failed.patch file (and also in
 these files using the '--file' and '--diff' options.
 """
 
+directory = DirectoryHasRepository()
 options = [make_option('-d', '--diff',
                        help = 'edit the patch diff',
                        action = 'store_true'),
diff --git a/stgit/commands/export.py b/stgit/commands/export.py
index 62be394..d8ce86d 100644
--- a/stgit/commands/export.py
+++ b/stgit/commands/export.py
@@ -49,6 +49,7 @@ file:
   %(commemail)s   - committer's e-mail
 """
 
+directory = DirectoryHasRepository()
 options = [make_option('-d', '--dir',
                        help = 'export patches to DIR instead of the default'),
            make_option('-p', '--patch',
diff --git a/stgit/commands/files.py b/stgit/commands/files.py
index 1a10023..07cc955 100644
--- a/stgit/commands/files.py
+++ b/stgit/commands/files.py
@@ -34,6 +34,7 @@ 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."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-s', '--stat',
                        help = 'show the diff stat',
                        action = 'store_true'),
diff --git a/stgit/commands/float.py b/stgit/commands/float.py
index 0e32f6b..d5299fb 100644
--- a/stgit/commands/float.py
+++ b/stgit/commands/float.py
@@ -31,6 +31,7 @@ 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)."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-s', '--series',
                        help = 'rearrange according to a series file',
                        action = 'store_true')]
diff --git a/stgit/commands/fold.py b/stgit/commands/fold.py
index d97185e..6e43101 100644
--- a/stgit/commands/fold.py
+++ b/stgit/commands/fold.py
@@ -34,6 +34,7 @@ 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."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-t', '--threeway',
                        help = 'perform a three-way merge with the current patch',
                        action = 'store_true'),
diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py
index a4427fa..9e008a9 100644
--- a/stgit/commands/goto.py
+++ b/stgit/commands/goto.py
@@ -31,6 +31,7 @@ line becomes current. This is a shortcut for the 'push --to' or 'pop
 --to' commands. There is no '--undo' option for 'goto'. Use the 'push'
 command for this."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-k', '--keep',
                        help = 'keep the local changes when popping patches',
                        action = 'store_true')]
diff --git a/stgit/commands/hide.py b/stgit/commands/hide.py
index de19c19..1a38907 100644
--- a/stgit/commands/hide.py
+++ b/stgit/commands/hide.py
@@ -30,6 +30,7 @@ usage = """%prog [options] <patch-range>
 Hide a range of unapplied patches so that they are no longer shown in
 the plain 'series' command output."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/commands/id.py b/stgit/commands/id.py
index f72d2f3..3e28f2f 100644
--- a/stgit/commands/id.py
+++ b/stgit/commands/id.py
@@ -33,6 +33,7 @@ the standard GIT id's like heads and tags, this command also accepts
 'top' or 'bottom' are passed and <patch> is a valid patch name, 'top'
 will be used by default."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 717f373..045f185 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."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-m', '--mail',
                        help = 'import the patch from a standard e-mail file',
                        action = 'store_true'),
diff --git a/stgit/commands/init.py b/stgit/commands/init.py
index 46562d0..475a4ce 100644
--- a/stgit/commands/init.py
+++ b/stgit/commands/init.py
@@ -31,6 +31,7 @@ Initialise the current GIT branch to be used as an StGIT stack. Note
 that you must already be in a GIT repository and .git/HEAD must point
 to a valid file in refs/heads/."""
 
+directory = DirectoryHasRepository()
 options = []
 
 
diff --git a/stgit/commands/log.py b/stgit/commands/log.py
index 4d6b022..f8337f9 100644
--- a/stgit/commands/log.py
+++ b/stgit/commands/log.py
@@ -43,6 +43,7 @@ represent the changes to the entire base of the current
 patch. Conflicts reset the patch content and a subsequent 'refresh'
 will show the entire patch."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-p', '--patch',
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index c32894e..4a4158a 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -88,6 +88,7 @@ the following:
   %(prefix)s       - 'prefix ' string passed on the command line
   %(shortdescr)s   - the first line of the patch description"""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--all',
                        help = 'e-mail all the applied patches',
                        action = 'store_true'),
diff --git a/stgit/commands/new.py b/stgit/commands/new.py
index 59671ab..ccc8141 100644
--- a/stgit/commands/new.py
+++ b/stgit/commands/new.py
@@ -38,6 +38,7 @@ needed for this.
 If no name is given for the new patch, one is generated from the first
 line of the commit message."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-m', '--message',
                        help = 'use MESSAGE as the patch description'),
            make_option('-s', '--showpatch',
diff --git a/stgit/commands/patches.py b/stgit/commands/patches.py
index fb65b62..0b618fe 100644
--- a/stgit/commands/patches.py
+++ b/stgit/commands/patches.py
@@ -33,6 +33,7 @@ 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."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-d', '--diff',
                        help = 'show the diff for the given files',
                        action = 'store_true'),
diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py
index 1c3ef11..3acec32 100644
--- a/stgit/commands/pick.py
+++ b/stgit/commands/pick.py
@@ -34,6 +34,7 @@ the name of the current patch. It can be overridden with the '--name'
 option. A commit object can be reverted with the '--reverse'
 option. The log and author information are those of the commit object."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-n', '--name',
                        help = 'use NAME as the patch name'),
            make_option('-r', '--reverse',
diff --git a/stgit/commands/pop.py b/stgit/commands/pop.py
index 0dfaad9..a1d73e4 100644
--- a/stgit/commands/pop.py
+++ b/stgit/commands/pop.py
@@ -36,6 +36,7 @@ patches passed on the command line are popped from the stack. Some of
 the push operations may fail because of conflicts (push --undo would
 revert the last push operation)."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--all',
                        help = 'pop all the applied patches',
                        action = 'store_true'),
diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index 237bdd9..5fcf2cc 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -38,6 +38,7 @@ resolved and the patch pushed again.
 
 Check the 'git fetch' documentation for the <repository> format."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-n', '--nopush',
                        help = 'do not push the patches back after pulling',
                        action = 'store_true'),
diff --git a/stgit/commands/push.py b/stgit/commands/push.py
index 53cdb8f..b91bc5e 100644
--- a/stgit/commands/push.py
+++ b/stgit/commands/push.py
@@ -39,6 +39,7 @@ command run.
 The command also notifies when the patch becomes empty (fully merged
 upstream) or is modified (three-way merged) by the 'push' operation."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--all',
                        help = 'push all the unapplied patches',
                        action = 'store_true'),
diff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py
index 513729a..bbb3e12 100644
--- a/stgit/commands/rebase.py
+++ b/stgit/commands/rebase.py
@@ -29,6 +29,7 @@ usage = """%prog [options] <new-base-id>
 Pop all patches from current stack, move the stack base to the given
 <new-base-id> and push the patches back."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-n', '--nopush',
                        help = 'do not push the patches back after rebasing',
                        action = 'store_true'),
diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
index 241f065..b283892 100644
--- a/stgit/commands/refresh.py
+++ b/stgit/commands/refresh.py
@@ -37,6 +37,7 @@ options. The '--force' option is useful when a commit object was
 created with a different tool but the changes need to be included in
 the current patch."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-f', '--force',
                        help = 'force the refresh even if HEAD and '\
                        'top differ',
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index 2830e72..e2b0fa4 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -29,6 +29,7 @@ usage = """%prog [options] <oldpatch> <newpatch>
 
 Rename <oldpatch> into <newpatch> in a series."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py
index 1130641..c2ef678 100644
--- a/stgit/commands/resolved.py
+++ b/stgit/commands/resolved.py
@@ -34,6 +34,7 @@ Mark a merge conflict as resolved. The conflicts can be seen with the
 'C'. This command also removes any <file>.{ancestor,current,patched}
 files."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--all',
                        help = 'mark all conflicts as solved',
                        action = 'store_true'),
diff --git a/stgit/commands/rm.py b/stgit/commands/rm.py
index 91908a1..59d098b 100644
--- a/stgit/commands/rm.py
+++ b/stgit/commands/rm.py
@@ -30,6 +30,7 @@ usage = """%prog [options] <files...>
 Remove given files from the repository. The command doesn't remove the
 working copy of the file."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-f', '--force',
                        help = 'force removing even if the file exists',
                        action = 'store_true')]
diff --git a/stgit/commands/series.py b/stgit/commands/series.py
index 00a3372..2c75876 100644
--- a/stgit/commands/series.py
+++ b/stgit/commands/series.py
@@ -34,6 +34,7 @@ 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'."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-a', '--all',
diff --git a/stgit/commands/show.py b/stgit/commands/show.py
index 45ca253..7efb4e1 100644
--- a/stgit/commands/show.py
+++ b/stgit/commands/show.py
@@ -30,6 +30,7 @@ Show the commit log and the diff corresponding to the given
 patches. The output is similar to that generated by the 'git show'
 command."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-a', '--applied',
diff --git a/stgit/commands/sink.py b/stgit/commands/sink.py
index 2a18ebc..737dde0 100644
--- a/stgit/commands/sink.py
+++ b/stgit/commands/sink.py
@@ -32,6 +32,7 @@ push the specified <patches> (the current patch by default), and
 then push back into place the formerly-applied patches (unless -n
 is also given)."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-n', '--nopush',
                        help = 'do not push the patches back after sinking',
                        action = 'store_true'),
diff --git a/stgit/commands/status.py b/stgit/commands/status.py
index b2835ab..a688f7e 100644
--- a/stgit/commands/status.py
+++ b/stgit/commands/status.py
@@ -40,6 +40,7 @@ under revision control. The files are prefixed as follows:
 A 'refresh' command clears the status of the modified, new and deleted
 files."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-m', '--modified',
                        help = 'show modified files only',
                        action = 'store_true'),
diff --git a/stgit/commands/sync.py b/stgit/commands/sync.py
index 580b5bd..8a31c29 100644
--- a/stgit/commands/sync.py
+++ b/stgit/commands/sync.py
@@ -36,6 +36,7 @@ in the series must apply cleanly.
 
 The sync operation can be reverted for individual patches with --undo."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-a', '--all',
                        help = 'synchronise all the patches',
                        action = 'store_true'),
diff --git a/stgit/commands/top.py b/stgit/commands/top.py
index 1a9267a..e7cb275 100644
--- a/stgit/commands/top.py
+++ b/stgit/commands/top.py
@@ -30,6 +30,7 @@ usage = """%prog [options]
 
 Print the name of the current (topmost) patch."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/commands/unapplied.py b/stgit/commands/unapplied.py
index c6408a3..d5bb43e 100644
--- a/stgit/commands/unapplied.py
+++ b/stgit/commands/unapplied.py
@@ -31,6 +31,7 @@ usage = """%prog [options]
 List the patches from the series which are not pushed onto the stack.
 They are listed in the reverse order in which they were popped."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-c', '--count',
diff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py
index c22d3ea..a23ae20 100644
--- a/stgit/commands/uncommit.py
+++ b/stgit/commands/uncommit.py
@@ -48,6 +48,7 @@ given commit should be uncommitted.
 Only commits with exactly one parent can be uncommitted; in other
 words, you can't uncommit a merge."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-n', '--number', type = 'int',
                        help = 'uncommit the specified number of commits'),
            make_option('-t', '--to',
diff --git a/stgit/commands/unhide.py b/stgit/commands/unhide.py
index 0a1dcaf..665d664 100644
--- a/stgit/commands/unhide.py
+++ b/stgit/commands/unhide.py
@@ -30,6 +30,7 @@ usage = """%prog [options] <patch-range>
 Unhide a hidden range of patches so that they are shown in the plain
 'series' command output."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one')]
 
diff --git a/stgit/main.py b/stgit/main.py
index 19ba2bd..15582dd 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -252,6 +252,7 @@ def main():
     usage = command.usage.split('\n')[0].strip()
     parser = OptionParser(usage = usage, option_list = command.options)
     options, args = parser.parse_args()
+    directory = command.directory
 
     # These modules are only used from this point onwards and do not
     # need to be imported earlier
@@ -267,6 +268,7 @@ def main():
         sys.exit(1)
 
     try:
+        directory.setup()
         config_setup()
 
         # 'clone' doesn't expect an already initialised GIT tree. A Series

^ permalink raw reply related

* [StGit PATCH 0/5] Make push and refresh subdirectory safe
From: Karl Hasselström @ 2007-10-07 23:24 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

This series makes push and refresh safe to use from subdirectories, by
using the infrastructure of the first patch to cd to the top of the
worktree.

As stated in the commit messages, this may not be an optimal long-term
solution, but we need to fix this quick. And the infrastructure isn't
good only for cd'ing to the top of the worktree.

This series is also available from

  git://repo.or.cz/stgit/kha.git safe

---

Karl Hasselström (5):
      Make "stg refresh" subdirectory safe
      New test: try "stg refresh" in a subdirectory
      Make "stg push" subdirectory safe
      New test: Try "stg push" in a subdirectory
      Infrastructure for current directory handling


 stgit/commands/add.py        |    1 +
 stgit/commands/applied.py    |    1 +
 stgit/commands/assimilate.py |    1 +
 stgit/commands/branch.py     |    1 +
 stgit/commands/clean.py      |    1 +
 stgit/commands/clone.py      |    1 +
 stgit/commands/commit.py     |    1 +
 stgit/commands/common.py     |   68 ++++++++++++++++++++++++++++++++++++++++++
 stgit/commands/copy.py       |    1 +
 stgit/commands/delete.py     |    1 +
 stgit/commands/diff.py       |    1 +
 stgit/commands/edit.py       |    1 +
 stgit/commands/export.py     |    1 +
 stgit/commands/files.py      |    1 +
 stgit/commands/float.py      |    1 +
 stgit/commands/fold.py       |    1 +
 stgit/commands/goto.py       |    1 +
 stgit/commands/hide.py       |    1 +
 stgit/commands/id.py         |    1 +
 stgit/commands/imprt.py      |    1 +
 stgit/commands/init.py       |    1 +
 stgit/commands/log.py        |    1 +
 stgit/commands/mail.py       |    1 +
 stgit/commands/new.py        |    1 +
 stgit/commands/patches.py    |    1 +
 stgit/commands/pick.py       |    1 +
 stgit/commands/pop.py        |    1 +
 stgit/commands/pull.py       |    1 +
 stgit/commands/push.py       |    1 +
 stgit/commands/rebase.py     |    1 +
 stgit/commands/refresh.py    |    1 +
 stgit/commands/rename.py     |    1 +
 stgit/commands/resolved.py   |    1 +
 stgit/commands/rm.py         |    1 +
 stgit/commands/series.py     |    1 +
 stgit/commands/show.py       |    1 +
 stgit/commands/sink.py       |    1 +
 stgit/commands/status.py     |    1 +
 stgit/commands/sync.py       |    1 +
 stgit/commands/top.py        |    1 +
 stgit/commands/unapplied.py  |    1 +
 stgit/commands/uncommit.py   |    1 +
 stgit/commands/unhide.py     |    1 +
 stgit/main.py                |    2 +
 t/t1205-push-subdir.sh       |   55 ++++++++++++++++++++++++++++++++++
 t/t2300-refresh-subdir.sh    |   27 +++++++++++++++++
 46 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100755 t/t1205-push-subdir.sh
 create mode 100755 t/t2300-refresh-subdir.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: Trying to use git-filter-branch to compress history by removing large, obsolete binary files
From: Elijah Newren @ 2007-10-07 23:24 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Frank Lichtenheld, git
In-Reply-To: <Pine.LNX.4.64.0710080018270.4174@racer.site>

On 10/7/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Sun, 7 Oct 2007, Elijah Newren wrote:
>
> > So...how do I fix the reflog, and then repack to have a pack under 11MB
> > in size?
>
> Just clone it.  The clone will be much smaller.

$ git clone test test2
<snip>
$ du -hs test
11M     test
$ du -hs test2
11M     test2

Any other ideas?

^ permalink raw reply

* Re: Trying to use git-filter-branch to compress history by removing large, obsolete binary files
From: Johannes Schindelin @ 2007-10-07 23:19 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Frank Lichtenheld, git
In-Reply-To: <51419b2c0710071500x318ee734n9db6ca9e6daa3196@mail.gmail.com>

Hi,

On Sun, 7 Oct 2007, Elijah Newren wrote:

> So...how do I fix the reflog, and then repack to have a pack under 11MB 
> in size?

Just clone it.  The clone will be much smaller.

Ciao,
Dscho

^ permalink raw reply

* [StGit PATCH 8/8] Remove the --force flag to "stg rebase" and "stg pull"
From: Karl Hasselström @ 2007-10-07 23:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

Instead, always behave as if the force flag was given; that is, don't
check if rebasing would leave a dangling commit behind. Reasons:

  * The check for this was very strict and caused a lot of false
    positives.

  * Everything is recorded in the reflog, so we can't actually lose
    commits.

This fixes bug 9181.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/common.py      |    9 +--------
 stgit/commands/pull.py        |    5 +----
 stgit/commands/rebase.py      |    5 +----
 stgit/stack.py                |    1 -
 t/t2100-pull-policy-fetch.sh  |   14 --------------
 t/t2102-pull-policy-rebase.sh |   24 ------------------------
 6 files changed, 3 insertions(+), 55 deletions(-)


diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index 27a616f..9815400 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -318,14 +318,7 @@ def address_or_alias(addr_str):
                  for addr in addr_str.split(',')]
     return ', '.join([addr for addr in addr_list if addr])
 
-def prepare_rebase(force=None):
-    if not force:
-        # Be sure we won't loose results of stg-(un)commit by error.
-        # Do not require an existing orig-base for compatibility with 0.12 and earlier.
-        origbase = crt_series._get_field('orig-base')
-        if origbase and crt_series.get_base() != origbase:
-            raise CmdException, 'Rebasing would possibly lose data'
-
+def prepare_rebase():
     # pop all patches
     applied = crt_series.get_applied()
     if len(applied) > 0:
diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index 070db99..237bdd9 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -43,9 +43,6 @@ options = [make_option('-n', '--nopush',
                        action = 'store_true'),
            make_option('-m', '--merged',
                        help = 'check for patches merged upstream',
-                       action = 'store_true'),
-           make_option('--force',
-                       help = 'force rebase even if the stack based was moved by (un)commits',
                        action = 'store_true')]
 
 def func(parser, options, args):
@@ -81,7 +78,7 @@ def func(parser, options, args):
     if policy not in ['pull', 'fetch-rebase', 'rebase']:
         raise GitConfigException, 'Unsupported pull-policy "%s"' % policy
 
-    applied = prepare_rebase(force=options.force)
+    applied = prepare_rebase()
 
     # pull the remote changes
     if policy == 'pull':
diff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py
index c68f8e7..513729a 100644
--- a/stgit/commands/rebase.py
+++ b/stgit/commands/rebase.py
@@ -34,9 +34,6 @@ options = [make_option('-n', '--nopush',
                        action = 'store_true'),
            make_option('-m', '--merged',
                        help = 'check for patches merged upstream',
-                       action = 'store_true'),
-           make_option('--force',
-                       help = 'force rebase even if the stack based was moved by (un)commits',
                        action = 'store_true')]
 
 def func(parser, options, args):
@@ -56,7 +53,7 @@ def func(parser, options, args):
     if git_id(args[0]) == None:
         raise GitException, 'Unknown revision: %s' % args[0]
         
-    applied = prepare_rebase(force=options.force)
+    applied = prepare_rebase()
     rebase(args[0])
     post_rebase(applied, options.nopush, options.merged)
 
diff --git a/stgit/stack.py b/stgit/stack.py
index bdb4e38..94856b8 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -623,7 +623,6 @@ class Series(PatchSet):
 
         self.create_empty_field('applied')
         self.create_empty_field('unapplied')
-        self._set_field('orig-base', git.get_head())
 
         config.set(self.format_version_key(), str(FORMAT_VERSION))
 
diff --git a/t/t2100-pull-policy-fetch.sh b/t/t2100-pull-policy-fetch.sh
index 1f50069..28901b1 100755
--- a/t/t2100-pull-policy-fetch.sh
+++ b/t/t2100-pull-policy-fetch.sh
@@ -55,18 +55,4 @@ test_expect_success \
     test `wc -l <clone/file2` = 3
     '
 
-# this one exercises the guard against commits
-# (use a new file to avoid mistaking a conflict for a success)
-test_expect_success \
-    'New upstream commit and commit a patch in clone' \
-    '
-    (cd upstream && stg new u2 -m u2 &&
-     echo a > file3 && stg add file3 && stg refresh) &&
-    (cd clone && stg commit && stg new c2 -m c2 &&
-     echo a >> file && stg refresh)
-    '
-test_expect_success \
-    'Try to  and commit a patch in clone' \
-    '(cd clone && ! stg pull)'
-
 test_done
diff --git a/t/t2102-pull-policy-rebase.sh b/t/t2102-pull-policy-rebase.sh
index b2fbfcf..ce2e32f 100755
--- a/t/t2102-pull-policy-rebase.sh
+++ b/t/t2102-pull-policy-rebase.sh
@@ -36,28 +36,4 @@ test_expect_success \
     test `wc -l <file2` = 2
     '
 
-# this one exercises the guard against commits
-# (use a new file to avoid mistaking a conflict for a success)
-test_expect_success \
-    'New commit in parent and commit a patch in stack' \
-    '
-    stg branch parent && stg new u2 -m u2 &&
-     echo c > file3 && stg add file3 && stg refresh &&
-    stg branch stack && stg commit && stg new c2 -m c2 &&
-     echo a >> file && stg refresh
-    '
-test_expect_success \
-    'Try to pull/rebase now that stack base has moved' \
-    '! stg pull'
-
-test_expect_success \
-    'Force the pull/rebase, but do not push yet' \
-    'stg pull --force --nopush'
-test_expect_success \
-    '...check we lost the committed patch' \
-    '! test -e file'
-test_expect_success \
-    '...and check we get a conflict while pushing' \
-    '! stg push'
-
 test_done

^ permalink raw reply related

* [StGit PATCH 7/8] Discard stderr output from git-rev-parse
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

This gets rid of the annoying "fatal: Needed a single revision"
messages that were printed in addition to StGit's own error message.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/git.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/stgit/git.py b/stgit/git.py
index 0026fd8..812b77a 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -301,7 +301,8 @@ def rev_parse(git_id):
     """Parse the string and return a verified SHA1 id
     """
     try:
-        return GRun('git-rev-parse', '--verify', git_id).output_one_line()
+        return GRun('git-rev-parse', '--verify', git_id
+                    ).discard_stderr().output_one_line()
     except GitRunException:
         raise GitException, 'Unknown revision: %s' % git_id
 

^ permalink raw reply related

* [StGit PATCH 6/8] Simplify debug level error checking
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/main.py |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)


diff --git a/stgit/main.py b/stgit/main.py
index f54330d..19ba2bd 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -261,9 +261,7 @@ def main():
     from stgit.stack import Series
 
     try:
-        debug_level = int(os.environ['STGIT_DEBUG_LEVEL'])
-    except KeyError:
-        debug_level = 0
+        debug_level = int(os.environ.get('STGIT_DEBUG_LEVEL', 0))
     except ValueError:
         out.error('Invalid STGIT_DEBUG_LEVEL environment variable')
         sys.exit(1)

^ permalink raw reply related

* [StGit PATCH 5/8] Make a common superclass for all StGit exceptions
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

This makes it easier to catch them all. (Indeed, the very long list of
exceptions to catch in main.py was missing some of the exceptions.)

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/common.py |    5 +++--
 stgit/config.py          |    3 ++-
 stgit/exception.py       |    3 +++
 stgit/git.py             |    3 ++-
 stgit/gitmergeonefile.py |    3 ++-
 stgit/main.py            |   11 +++--------
 stgit/run.py             |    5 +++--
 stgit/stack.py           |    3 ++-
 stgit/utils.py           |    3 ++-
 9 files changed, 22 insertions(+), 17 deletions(-)
 create mode 100644 stgit/exception.py


diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index 0fc157a..27a616f 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 import sys, os, os.path, re
 from optparse import OptionParser, make_option
 
+from stgit.exception import *
 from stgit.utils import *
 from stgit.out import *
 from stgit import stack, git, basedir
@@ -30,11 +31,11 @@ crt_series = None
 
 
 # Command exception class
-class CmdException(Exception):
+class CmdException(StgException):
     pass
 
 # Utility functions
-class RevParseException(Exception):
+class RevParseException(StgException):
     """Revision spec parse error."""
     pass
 
diff --git a/stgit/config.py b/stgit/config.py
index 51818bd..3eabc8c 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -20,9 +20,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 import os, re
 from stgit import basedir
+from stgit.exception import *
 from stgit.run import *
 
-class GitConfigException(Exception):
+class GitConfigException(StgException):
     pass
 
 class GitConfig:
diff --git a/stgit/exception.py b/stgit/exception.py
new file mode 100644
index 0000000..9933e64
--- /dev/null
+++ b/stgit/exception.py
@@ -0,0 +1,3 @@
+class StgException(Exception):
+    """Base class for all StGit exceptions."""
+    pass
diff --git a/stgit/git.py b/stgit/git.py
index a0493bc..0026fd8 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 import sys, os, re, gitmergeonefile
 from shutil import copyfile
 
+from stgit.exception import *
 from stgit import basedir
 from stgit.utils import *
 from stgit.out import *
@@ -28,7 +29,7 @@ from stgit.run import *
 from stgit.config import config
 
 # git exception class
-class GitException(Exception):
+class GitException(StgException):
     pass
 
 # When a subprocess has a problem, we want the exception to be a
diff --git a/stgit/gitmergeonefile.py b/stgit/gitmergeonefile.py
index 2aa5ef8..058b6ac 100644
--- a/stgit/gitmergeonefile.py
+++ b/stgit/gitmergeonefile.py
@@ -19,13 +19,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
 import sys, os
+from stgit.exception import *
 from stgit import basedir
 from stgit.config import config, file_extensions, ConfigOption
 from stgit.utils import append_string
 from stgit.out import *
 from stgit.run import *
 
-class GitMergeException(Exception):
+class GitMergeException(StgException):
     pass
 
 
diff --git a/stgit/main.py b/stgit/main.py
index 2c8716b..f54330d 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -255,13 +255,10 @@ def main():
 
     # These modules are only used from this point onwards and do not
     # need to be imported earlier
+    from stgit.exception import StgException
     from stgit.config import config_setup
     from ConfigParser import ParsingError, NoSectionError
-    from stgit.stack import Series, StackException
-    from stgit.git import GitException
-    from stgit.commands.common import CmdException
-    from stgit.gitmergeonefile import GitMergeException
-    from stgit.utils import EditorException
+    from stgit.stack import Series
 
     try:
         debug_level = int(os.environ['STGIT_DEBUG_LEVEL'])
@@ -284,9 +281,7 @@ def main():
             stgit.commands.common.crt_series = command.crt_series
 
         command.func(parser, options, args)
-    except (IOError, ParsingError, NoSectionError, CmdException,
-            StackException, GitException, GitMergeException,
-            EditorException), err:
+    except (StgException, IOError, ParsingError, NoSectionError), err:
         print >> sys.stderr, '%s %s: %s' % (prog, cmd, err)
         if debug_level > 0:
             raise
diff --git a/stgit/run.py b/stgit/run.py
index 7986f3b..989bb27 100644
--- a/stgit/run.py
+++ b/stgit/run.py
@@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 import datetime, os, subprocess
 
-from  stgit.out import *
+from stgit.exception import *
+from stgit.out import *
 
-class RunException(Exception):
+class RunException(StgException):
     """Thrown when something bad happened when we tried to run the
     subprocess."""
     pass
diff --git a/stgit/stack.py b/stgit/stack.py
index 4d1a066..bdb4e38 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 import sys, os, re
 from email.Utils import formatdate
 
+from stgit.exception import *
 from stgit.utils import *
 from stgit.out import *
 from stgit.run import *
@@ -30,7 +31,7 @@ from shutil import copyfile
 
 
 # stack exception class
-class StackException(Exception):
+class StackException(StgException):
     pass
 
 class FilterUntil:
diff --git a/stgit/utils.py b/stgit/utils.py
index 857c0f0..3a480c0 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -2,6 +2,7 @@
 """
 
 import errno, optparse, os, os.path, re, sys
+from stgit.exception import *
 from stgit.config import config
 from stgit.out import *
 
@@ -166,7 +167,7 @@ def rename(basedir, file1, file2):
         # file1's parent dir may not be empty after move
         pass
 
-class EditorException(Exception):
+class EditorException(StgException):
     pass
 
 def call_editor(filename):

^ permalink raw reply related

* [StGit PATCH 4/8] Don't split long and short description in "stg edit"
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

"stg edit" used to present the patch information like this:

  Short description

  From: ...
  Date: ...

  Long description

If the project follows the git convention with a single-line short
description and follwed by a blank line and the rest of the
description, this merely looks a little odd. However, for projects
that don't follow that convention, presenting the first line
separately is actively inconvenient; for example, it breaks emacs's
fill-paragraph command.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/edit.py |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)


diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index e968e25..223c628 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -36,12 +36,10 @@ diff.
 
 The editor is invoked with the following contents:
 
-  Patch short description
-
   From: A U Thor <author@example.com>
   Date: creation date
 
-  Patch long description
+  Patch description
 
 If --diff was specified, the diff appears at the bottom, after a
 separator:
@@ -135,22 +133,15 @@ def __edit_update_patch(pname, options):
 
     # generate the file to be edited
     descr = patch.get_description().strip()
-    descr_lines = descr.split('\n')
     authdate = patch.get_authdate()
 
-    short_descr = descr_lines[0].rstrip()
-    long_descr = reduce(lambda x, y: x + '\n' + y,
-                        descr_lines[1:], '').strip()
-
-    tmpl = '%(shortdescr)s\n\n' \
-           'From: %(authname)s <%(authemail)s>\n'
+    tmpl = 'From: %(authname)s <%(authemail)s>\n'
     if authdate:
         tmpl += 'Date: %(authdate)s\n'
-    tmpl += '\n%(longdescr)s\n'
+    tmpl += '\n%(descr)s\n'
 
     tmpl_dict = {
-        'shortdescr': short_descr,
-        'longdescr': long_descr,
+        'descr': descr,
         'authname': patch.get_authname(),
         'authemail': patch.get_authemail(),
         'authdate': patch.get_authdate()

^ permalink raw reply related

* [StGit PATCH 3/8] Fix up the help text for "stg edit"
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

The sentence structure was strange, and the example format was
somewhat misleading (StGit doesn't care about sign-off lines, for
example).

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/edit.py |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)


diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index 63c710b..e968e25 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -30,19 +30,25 @@ from stgit import stack, git
 help = 'edit a patch description or diff'
 usage = """%prog [options] [<patch>]
 
-Edit the given patch (defaulting to the current one) description,
-author information or its diff (if the '--diff' option is
-passed). Without any other option, the command invokes the editor with
-the patch description and diff in the form below:
+Edit the description and author information of the given patch (or the
+current patch if no patch name was given). With --diff, also edit the
+diff.
 
-  Subject line
+The editor is invoked with the following contents:
 
-  From: author information
+  Patch short description
+
+  From: A U Thor <author@example.com>
   Date: creation date
 
-  Patch description
+  Patch long description
+
+If --diff was specified, the diff appears at the bottom, after a
+separator:
+
+  ---
 
-  Signed-off-by: author
+  Diff text
 
 Command-line options can be used to modify specific information
 without invoking the editor.
@@ -54,7 +60,7 @@ these files using the '--file' and '--diff' options.
 """
 
 options = [make_option('-d', '--diff',
-                       help = 'allow the editing of the patch diff',
+                       help = 'edit the patch diff',
                        action = 'store_true'),
            make_option('-f', '--file',
                        help = 'use FILE instead of invoking the editor'),

^ permalink raw reply related

* [StGit PATCH 2/8] New test: "stg pop --keep"
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 t/t1204-pop-keep.sh |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
 create mode 100755 t/t1204-pop-keep.sh


diff --git a/t/t1204-pop-keep.sh b/t/t1204-pop-keep.sh
new file mode 100755
index 0000000..40cd2a2
--- /dev/null
+++ b/t/t1204-pop-keep.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='Test "stg pop -keep"'
+. ./test-lib.sh
+stg init
+
+test_expect_success 'Create a few patches' '
+    for i in 0 1 2; do
+        stg new p$i -m p$i &&
+        echo "patch$i" >> patch$i.txt &&
+        stg add patch$i.txt &&
+        stg refresh
+    done &&
+    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg unapplied))" = "" ]
+'
+
+test_expect_success 'Make some non-conflicting local changes' '
+    echo "local" >> patch0.txt
+'
+
+test_expect_success 'Pop two patches, keeping local changes' '
+    stg pop -n 2 --keep &&
+    [ "$(echo $(stg applied))" = "p0" ] &&
+    [ "$(echo $(stg unapplied))" = "p1 p2" ] &&
+    [ "$(echo $(ls patch?.txt))" = "patch0.txt" ] &&
+    [ "$(echo $(cat patch0.txt))" = "patch0 local" ]
+'
+
+test_expect_success 'Reset and push patches again' '
+    git reset --hard &&
+    stg push -a
+'
+
+test_expect_success 'Pop a patch without local changes' '
+    stg pop --keep &&
+    [ "$(echo $(stg applied))" = "p0 p1" ] &&
+    [ "$(echo $(stg unapplied))" = "p2" ] &&
+    [ "$(echo $(ls patch?.txt))" = "patch0.txt patch1.txt" ]
+'
+
+test_done

^ permalink raw reply related

* [StGit PATCH 1/8] Add --ack/--sign options to "stg new"
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20071007231446.12626.14259.stgit@yoghurt>

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/new.py |    6 ++++--
 stgit/stack.py        |   10 +++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)


diff --git a/stgit/commands/new.py b/stgit/commands/new.py
index f192e34..59671ab 100644
--- a/stgit/commands/new.py
+++ b/stgit/commands/new.py
@@ -54,7 +54,8 @@ options = [make_option('-m', '--message',
            make_option('--commname',
                        help = 'use COMMNAME as the committer name'),
            make_option('--commemail',
-                       help = 'use COMMEMAIL as the committer e-mail')]
+                       help = 'use COMMEMAIL as the committer e-mail')
+           ] + make_sign_options()
 
 
 def func(parser, options, args):
@@ -79,4 +80,5 @@ def func(parser, options, args):
                          author_email = options.authemail,
                          author_date = options.authdate,
                          committer_name = options.commname,
-                         committer_email = options.commemail)
+                         committer_email = options.commemail,
+                         sign_str = options.sign_str)
diff --git a/stgit/stack.py b/stgit/stack.py
index d889f37..4d1a066 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -847,7 +847,7 @@ class Series(PatchSet):
                   top = None, bottom = None, commit = True,
                   author_name = None, author_email = None, author_date = None,
                   committer_name = None, committer_email = None,
-                  before_existing = False):
+                  before_existing = False, sign_str = None):
         """Creates a new patch, either pointing to an existing commit object,
         or by creating a new commit object.
         """
@@ -865,13 +865,17 @@ class Series(PatchSet):
 
         # TODO: move this out of the stgit.stack module, it is really
         # for higher level commands to handle the user interaction
+        def sign(msg):
+            return add_sign_line(msg, sign_str,
+                                 committer_name or git.committer().name,
+                                 committer_email or git.committer().email)
         if not message and can_edit:
             descr = edit_file(
-                self, None,
+                self, sign(''),
                 'Please enter the description for the patch above.',
                 show_patch)
         else:
-            descr = message
+            descr = sign(message)
 
         head = git.get_head()
 

^ permalink raw reply related

* [StGit PATCH 0/8] Miscellaneous fixes and improvements
From: Karl Hasselström @ 2007-10-07 23:17 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Also available from

  git://repo.or.cz/stgit/kha.git safe

---

Karl Hasselström (8):
      Remove the --force flag to "stg rebase" and "stg pull"
      Discard stderr output from git-rev-parse
      Simplify debug level error checking
      Make a common superclass for all StGit exceptions
      Don't split long and short description in "stg edit"
      Fix up the help text for "stg edit"
      New test: "stg pop --keep"
      Add --ack/--sign options to "stg new"


 stgit/commands/common.py      |   14 ++++----------
 stgit/commands/edit.py        |   33 +++++++++++++++-----------------
 stgit/commands/new.py         |    6 ++++--
 stgit/commands/pull.py        |    5 +----
 stgit/commands/rebase.py      |    5 +----
 stgit/config.py               |    3 ++-
 stgit/exception.py            |    3 +++
 stgit/git.py                  |    6 ++++--
 stgit/gitmergeonefile.py      |    3 ++-
 stgit/main.py                 |   15 ++++-----------
 stgit/run.py                  |    5 +++--
 stgit/stack.py                |   14 +++++++++-----
 stgit/utils.py                |    3 ++-
 t/t1204-pop-keep.sh           |   42 +++++++++++++++++++++++++++++++++++++++++
 t/t2100-pull-policy-fetch.sh  |   14 --------------
 t/t2102-pull-policy-rebase.sh |   24 -----------------------
 16 files changed, 96 insertions(+), 99 deletions(-)
 create mode 100644 stgit/exception.py
 create mode 100755 t/t1204-pop-keep.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: git fetch -- double fetch
From: Daniel Barkalow @ 2007-10-07 23:14 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Johannes Schindelin, git
In-Reply-To: <20071007214433.GA30833@shadowen.org>

On Sun, 7 Oct 2007, Andy Whitcroft wrote:

> On Sun, Oct 07, 2007 at 05:29:38PM +0100, Johannes Schindelin wrote:
> > Hi,
> > 
> > On Sat, 6 Oct 2007, Andy Whitcroft wrote:
> > 
> > > I have recently been seeing repeated fetching of some branches.  I feel
> > > this has happened in at least three of my repos on three distinct
> > > projects:
> > > 
> > > apw@pinky$ git fetch origin
> > > remote: Generating pack...
> > > remote: Done counting 5 objects.
> > > remote: Deltifying 5 objects...
> > > remote:  100% (5/5) done
> > > Unpacking 5 objects...
> > > remote: Total 5 (delta 0), reused 0 (delta 0)
> > >  100% (5/5) done
> > > * refs/remotes/origin/master: fast forward to branch 'master' of ssh://git@abat-dev/var/www/git/abat
> > >   old..new: ce046f0..41c9dde
> > > * refs/remotes/origin/master: fast forward to branch 'master' of ssh://git@abat-dev/var/www/git/abat
> > >   old..new: ce046f0..41c9dde
> > 
> > What does "git config --get-all remote.origin.fetch" say?
> 
> apw@pinky$ git config --get-all remote.origin.fetch
> +refs/heads/master:refs/remotes/origin/master
> +refs/heads/*:refs/remotes/origin/*
> apw@pinky$
> 
> I don't think that I did anything to this config, I think that is what
> the clone setup for me.

Ah, both the first line and the pattern match, and there's nothing at that 
stage to filter out duplicates.

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply

* Re: [PATCH 1/4] git-gui i18n: Add more words to glossary.
From: Shawn O. Pearce @ 2007-10-07 23:12 UTC (permalink / raw)
  To: Christian Stimming; +Cc: Johannes Schindelin, git
In-Reply-To: <200710072242.26288.stimming@tuhh.de>

Christian Stimming <stimming@tuhh.de> wrote:
> Am Sonntag, 7. Oktober 2007 20:05 schrieb Shawn O. Pearce:
> > Christian Stimming <stimming@tuhh.de> wrote:
> > > Signed-off-by: Christian Stimming <stimming@tuhh.de>
> > >
> > > ---
> > >  po/glossary/git-gui-glossary.pot |   12 ++++++++++--
> > >  po/glossary/git-gui-glossary.txt |    2 ++
> > >  2 files changed, 12 insertions(+), 2 deletions(-)
> >
> > What version is this series applied to?  It rejects against my
> > currently published master on repo.or.cz.
> 
> It rejects? The patch were intended against master on git-gui.git on 
> repo.or.cz; the base for the patches was 
> 1952aa1d5735ccbedd832620e43db3e03fc77088

Right, that's what I tried to apply them to.
 
> I might have messed up some line wrappings... if that is the case, I can of 
> course resend and try harder to send them correctly.

If you are sending a series like that and its all po translation
stuff that is unlikely to need commenting on feel free to just dump
it all out as a single mbox (`git format-patch --stdout`) and attach
it to the email.  Less chance of the MUA mangling the message.

I'd rather not to this for code however, as myself or others may
want to reply with comments.  Having it inline makes this task
much easier.

-- 
Shawn.

^ permalink raw reply

* Re: Many gits are offline this week
From: Shawn O. Pearce @ 2007-10-07 23:09 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Daniel Barkalow, Randal L. Schwartz, Paolo Ciarrocchi, git
In-Reply-To: <Pine.LNX.4.64.0710072331050.4174@racer.site>

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Sun, 7 Oct 2007, Daniel Barkalow wrote:
> 
> > For that matter, gitweb is essentially a limited porcelain. And this 
> > points out that all VCSes have alternative porcelains, but git is 
> > unusual in having convenient plumbing to support and encourage this.
> 
> I do not consider viewers "porcelain".  And gitweb is essentially just a 
> viewer.

So you don't consider gitk to be porcelain?  I do.  The plumbing
output of git-rev-list is uh, ugly.  gitk may still not be the best
looking application on the internet but it sure beats looking at
rev-list output by eye.

Porcelain is really anything that calls plumbing to make the task
of invoking or processing the output of plumbing easier on the
human using it.  That's it.  Obviously you can work Git by just the
plumbing.  Just like you can compute SHA-1 by hand.  You just choose
not to as the time it would take is more than you want to invest.
Or have left in this mortal existance...

I almost always forget about the web interfaces.  There's a number
of them and I don't use them often enough to really think about it.
I don't know why I always forget about them.  I never forget about
StGit or qgit, and yet I never use those either...

-- 
Shawn.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox