-------------------------
In stand-alone mode, StGIT is used in conjunction with a GIT repository
- that is already initialised (using 'git-init-db'). StGIT cannot be used
+ that is already initialised (using 'git init'). StGIT cannot be used
outside of a GIT repository.
Any branch in a GIT repository may be managed by StGIT. Each branch
managed by StGIT contains an independent series of StGIT patches.
stg files
The 'stg refresh' command automatically notes changes to files that
-already exist in the working directory, but you have to tell StGIT
-explicitly if you add, remove, or rename files.
-To record the addition or deletion of files in your new patch:
+already exist in the working directory (it also notices if you remove
+them), but you have to tell StGIT explicitly if you add or rename a
+file:
- stg add [<file>*]
- stg rm [<file>*]
+ git add new-file
-To record the renaming of a file in your new patch, issue both of these
-commands:
+to add a file, and
- stg rm <oldfilename>
- stg add <newfilename>
+ mv old-file new-file
+ git add new-file
+
+or simply
+
+ git mv old-file new-file
+
+to move a file.
Stack manipulation: managing multiple patches
#autoresolved = no
# SMTP server for sending patches
+ #smtpserver = /usr/sbin/sendmail -t -i
#smtpserver = localhost:25
# Set to 'yes' to use SMTP over TLS
#pager = filterdiff --annotate | colordiff | less -FRX
# GIT pull and fetch commands (should take the same arguments as
- # git-fetch or git-pull). By default:
- #pullcmd = git-pull
- #fetchcmd = git-fetch
+ # git fetch or git pull). By default:
+ #pullcmd = git pull
+ #fetchcmd = git fetch
# Rebase command. Note that this command is internally implemented in
# a different way. Only define this option if a different rebase
# is needed (i.e. 'git svn rebase')
- #rebasecmd = git-reset
+ #rebasecmd = git reset
# "stg pull" policy. This is the repository default, which can be
# overriden on a per-branch basis using branch.*.stgit.pull-policy
# To support local parent branches:
#pull-policy = rebase
- # The three-way merge tool. Note that the 'output' file contains the
- # same data as 'branch1'. This is useful for tools that do not take an
- # output parameter
- #merger = diff3 -L current -L ancestor -L patched -m -E \
- # \"%(branch1)s\" \"%(ancestor)s\" \"%(branch2)s\" \
- # > \"%(output)s\"
-
# Interactive two/three-way merge tool. It is executed by the
# 'resolved --interactive' command
#i3merge = xxdiff --title1 current --title2 ancestor --title3 patched \
# The maximum length of an automatically generated patch name
#namelenth = 30
+ # Extra options to pass to "git diff" (extend/override with
+ # -O/--diff-opts). For example, -M turns on rename detection.
+ #diff-opts = -M
+
[mail "alias"]
# E-mail aliases used with the 'mail' command
git = git@vger.kernel.org
if options.fold:
out.start('Folding commit %s' % commit_id)
- # try a direct git-apply first
+ # try a direct git apply first
if not git.apply_diff(bottom, top):
- git.merge(bottom, git.get_head(), top, recursive = True)
+ git.merge_recursive(bottom, git.get_head(), top)
out.done()
elif options.update:
- rev1 = git_id(crt_series, '//bottom')
- rev2 = git_id(crt_series, '//top')
+ rev1 = git_id(crt_series, 'HEAD^')
+ rev2 = git_id(crt_series, 'HEAD')
files = git.barefiles(rev1, rev2).split('\n')
out.start('Updating with commit %s' % commit_id)
patchname = newpatch.get_name()
# find a patchlog to fork from
- (refpatchname, refbranchname, refpatchid) = parse_rev(patchname)
- if refpatchname and not refpatchid and \
- (not refpatchid or refpatchid == 'top'):
- # FIXME: should also support picking //top.old
+ refbranchname, refpatchname = parse_rev(patchname)
+ if refpatchname:
if refbranchname:
# assume the refseries is OK, since we already resolved
# commit_str to a git_id
the tests.
*** t0000-basic.sh ***
- * ok 1: .git/objects should be empty after git-init-db in an empty repo.
+ * ok 1: .git/objects should be empty after git init in an empty repo.
* ok 2: .git/objects should have 256 subdirectories.
- * ok 3: git-update-index without --add should fail adding.
+ * ok 3: git update-index without --add should fail adding.
...
- * ok 23: no diff after checkout and git-update-index --refresh.
+ * ok 23: no diff after checkout and git update-index --refresh.
* passed all 23 test(s)
*** t0100-environment-names.sh ***
* ok 1: using old names should issue warnings.
this:
$ sh ./t3001-ls-files-killed.sh
- * ok 1: git-update-index --add to add various paths.
- * ok 2: git-ls-files -k to show killed files.
- * ok 3: validate git-ls-files -k output.
+ * ok 1: git update-index --add to add various paths.
+ * ok 2: git ls-files -k to show killed files.
+ * ok 3: validate git ls-files -k output.
* passed all 3 test(s)
You can pass --verbose (or -v), --debug (or -d), and --immediate
test_description='xxx test (option --frotz)
This test registers the following structure in the cache
- and tries to run git-ls-files with option --frotz.'
+ and tries to run git ls-files with option --frotz.'
Source 'test-lib.sh'
Example:
test_expect_success \
- 'git-write-tree should be able to write an empty tree.' \
- 'tree=$(git-write-tree)'
+ 'git write-tree should be able to write an empty tree.' \
+ 'tree=$(git write-tree)'
- test_expect_failure <message> <script>
yields success, test is considered a failure.
This should _not_ be used for tests that succeed when their
- commands fail -- use test_expect_success and shell negation (!) for
- that. test_expect_failure is for cases when a test is known to be
- broken.
+ commands fail -- use test_expect_success and one of general_error,
+ command_error, and conflict for that. test_expect_failure is for
+ cases when a test is known to be broken.
- test_debug <script>
stg clone foo bar &&
(
cd bar && stg new p1 -m p1 &&
- printf "a\nc\n" > file && stg add file && stg refresh &&
+ printf "a\nc\n" > file && git add file && stg refresh &&
stg new p2 -m p2 &&
printf "a\nb\nc\n" > file && stg refresh &&
- [ "$(echo $(stg applied))" = "p1 p2" ] &&
- [ "$(echo $(stg unapplied))" = "" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
)
'
'Port those patches to orig tree' '
(
cd foo &&
- GIT_DIR=../bar/.git git-format-patch --stdout \
- $(cd ../bar && stg id master:{base})..HEAD | git-am -3 -k
+ GIT_DIR=../bar/.git git format-patch --stdout \
- $(cd ../bar && stg id base@master)..HEAD | git am -3 -k
++ $(cd ../bar && stg id master:{base})..HEAD | git am -3 -k
)
'
test_expect_success \
'Attempt to push the first of those patches without --merged' \
- "(cd bar && ! stg push
+ "(cd bar && conflict_old stg push
)
"
'Rollback the push' '
(
cd bar && stg push --undo &&
- [ "$(echo $(stg applied))" = "" ] &&
- [ "$(echo $(stg unapplied))" = "p1 p2" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
)
'
'Push those patches while checking they were merged upstream' '
(
cd bar && stg push --merged --all
- [ "$(echo $(stg applied))" = "p1 p2" ] &&
- [ "$(echo $(stg unapplied))" = "" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
)
'
test_expect_success \
'Port those patches to orig tree' \
'(cd foo &&
- GIT_DIR=../bar/.git git-format-patch --stdout \
+ GIT_DIR=../bar/.git git format-patch --stdout \
- $(cd ../bar && stg id base@master)..HEAD |
+ $(cd ../bar && stg id master:{base})..HEAD |
- git-am -3 -k
+ git am -3 -k
)
'
test_expect_success \
'Check that all went well' \
- "diff -u foo/file bar/file
+ "test_cmp foo/file bar/file
"
test_done
for i in 0 1 2 3 4; do
stg new p$i -m p$i;
done &&
- [ "$(echo $(stg applied))" = "p0 p1 p2 p3 p4" ] &&
- [ "$(echo $(stg unapplied))" = "" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'
- test_expect_success 'Pop two patches with git-reset' '
+ test_expect_success 'Pop two patches with git reset' '
git reset --hard HEAD~2 &&
- ! stg refresh &&
+ command_error stg refresh &&
stg repair &&
stg refresh &&
- [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
- [ "$(echo $(stg unapplied))" = "p3 p4" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ]
'
test_expect_success 'Create a new patch' '
stg new q0 -m q0 &&
- [ "$(echo $(stg applied))" = "p0 p1 p2 q0" ] &&
- [ "$(echo $(stg unapplied))" = "p3 p4" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 q0" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ]
'
- test_expect_success 'Go to an unapplied patch with with git-reset' '
+ test_expect_success 'Go to an unapplied patch with with git reset' '
git reset --hard $(stg id p3) &&
- ! stg refresh &&
+ command_error stg refresh &&
stg repair &&
stg refresh &&
- [ "$(echo $(stg applied))" = "p0 p1 p2 p3" ] &&
- [ "$(echo $(stg unapplied))" = "q0 p4" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "q0 p4" ]
'
- test_expect_success 'Go back to below the stack base with git-reset' '
+ test_expect_success 'Go back to below the stack base with git reset' '
git reset --hard foo-tag &&
stg repair &&
- [ "$(echo $(stg applied))" = "" ] &&
- [ "$(echo $(stg unapplied))" = "p0 p1 p2 p3 q0 p4" ]
+ [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
+ [ "$(echo $(stg series --unapplied --noprefix))" = "p0 p1 p2 p3 q0 p4" ]
'
test_done
--- /dev/null
- test_expect_success 'git-rm a file' '
+#!/bin/sh
+
+test_description='"stg refresh" with removed files'
+
+. ./test-lib.sh
+
+# Ignore our own temp files.
+cat >> .git/info/exclude <<EOF
+expected*.txt
+files*.txt
+status*.txt
+EOF
+
+reset () {
+ stg pop -a > /dev/null
+ git reset --hard > /dev/null
+}
+
+test_expect_success 'Initialize StGit stack' '
+ stg init &&
+ echo x > x.txt &&
+ echo y > y.txt &&
+ git add x.txt y.txt &&
+ git commit -m "Add some files"
+'
+
+cat > expected0.txt <<EOF
+D y.txt
+EOF
+printf '' > expected1.txt
- test_expect_success 'git-rm a file together with other changes' '
++test_expect_success 'git rm a file' '
+ stg new -m p0 &&
+ git rm y.txt &&
+ stg status > status0.txt &&
+ test_cmp expected0.txt status0.txt &&
+ stg refresh &&
+ stg status > status1.txt &&
+ test_cmp expected1.txt status1.txt &&
+ stg files | sort > files.txt &&
+ test_cmp expected0.txt files.txt
+'
+
+reset
+
+cat > expected0.txt <<EOF
+D y.txt
+M x.txt
+EOF
+printf '' > expected1.txt
++test_expect_success 'git rm a file together with other changes' '
+ stg new -m p1 &&
+ echo x2 >> x.txt &&
+ git rm y.txt &&
+ stg status > status0.txt &&
+ test_cmp expected0.txt status0.txt &&
+ stg refresh &&
+ stg status > status1.txt &&
+ test_cmp expected1.txt status1.txt &&
+ stg files | sort > files.txt &&
+ test_cmp expected0.txt files.txt
+'
+
+reset
+
+cat > expected0.txt <<EOF
+D y.txt
+EOF
+printf '' > expected1.txt
+test_expect_success 'rm a file' '
+ stg new -m p2 &&
+ rm y.txt &&
+ stg status > status0.txt &&
+ test_cmp expected0.txt status0.txt &&
+ stg refresh &&
+ stg status > status1.txt &&
+ test_cmp expected1.txt status1.txt &&
+ stg files | sort > files.txt &&
+ test_cmp expected0.txt files.txt
+'
+
+reset
+
+cat > expected0.txt <<EOF
+D y.txt
+M x.txt
+EOF
+printf '' > expected1.txt
+test_expect_success 'rm a file together with other changes' '
+ stg new -m p3 &&
+ echo x2 >> x.txt &&
+ rm y.txt &&
+ stg status > status0.txt &&
+ test_cmp expected0.txt status0.txt &&
+ stg refresh &&
+ stg status > status1.txt &&
+ test_cmp expected1.txt status1.txt &&
+ stg files | sort > files.txt &&
+ test_cmp expected0.txt files.txt
+'
+
+test_done