RFC: Introducing git-test, git-atomic, git-base and git-work
Subsystems (2)
cover RFC: Introducing git-test, git-atomic, git-base and git-work
This series is posted in order to solicit feedback about some commands I'd like to propose for inclusion in git.
The commands are:
git test
git atomic
git base
git work
git work
========
git work depends on the other 3 commands.
git work is the command I have been using every day myself for the last 8 months. It is the primary means I use to manage my working tree.
The basic idea of git work is to help manage a private working tree using the following principles:
* all dependencies received from others are merged into the 'base' of the working tree
git work merge some-dependency
- merges some-dependency into $(git base) producing (1)
- rebases $(git base)..HEAD onto (1) producing (2)
- resets the current branch to (2)
- updates $(git base) to refer to (1)
* all unpublished work is managed as a linear sequence of commits on top of the 'base' of the working tree
so,
git work --as-refs # shows you a symbolic range for your current work git work # shows you a SHA1 range for your current work gitk $(git work) # shows you your unpublished work
git diff $(git work) # shows you the diff of your current work
* prior to publishing work, you rebase it onto an appropriate base commit
so,
git branch topic upstream/master # choose the base commit for the topic
git work update topic HEAD~3 # pull the top 3 commits off the working tree onto the topic
- rebases HEAD~3..HEAD onto topic to produce (1)
- merges topic into $(git base) to produce (2)
- rebases $(git base)..HEAD~3 onto (2) to produce (3)
- resets the current branch to (3)
- resets $(git base) to (2)
The nice thing about managing your work tree this way is that your working tree remains relatively stable (it always contains everything you have recently been working on) and your topic branches remain clean (i.e. they never contain any other cruft from your working tree).
git base
========
git base is a command that is heavily relied on by git work, and is occasionally used by the user to reset the base of their working tree.
git base tries to automagically maintain the base of the working tree by maintaining an invariant that the path between the base and the tip of the current branch should never traverse a merge. If it ever finds the invariant violated, it calls 'git base reset' to attempt to restore the invariant.
For more information about git base, refer to the Documentation/git-base.txt
git atomic
==========
git atomic is more an experiment than anything else. The idea is to run another git operation "atomically". The git operation either succeeds or it fails. If it fails, git branch attempts to restore the working tree and current branch to the state they were in to their original state prior to the comamnd being run.
The reason I need something like this is that git work performs several operations in sequence some of which I can't guarantee will work. I don't want the user to work out what they have to do to recover, so I try to restore to the state they were originally in.
Note: the current implementation doesn't handle rebase failures properly and would probably needed to be cleaned up a little before being accepted into the mainline.
git test
========
This is another experiment. The idea is to provide a uniform way to test for various conditions into the working tree, index and repo. For example:
git test --not-unstaged --branch-exists foobar
will fail if there are unstaged files in the working tree or the branch foobar does not exist.
As I say, git atomic and git test are somewhat experimental. I don't really care about those commands and if the consensus is that git doesn't need them, I am happy to rework git base and git work to not use them.
However, I would like to propose git base and git work as being very useful additions to the git toolset.
Let me know if the consensus is that I should proceed with a submission and I will prepare one.
Jon Seymour (23):
Introduce git-test.sh and git-test-lib.sh
Introduce --unstaged.
Introduce --staged
Introduce --untracked.
Introduce --conflicted
Introduce --rebasing
Introduce --detached
Introduce --branch-exists
Introduce --tag-exists
Introduce --ref-exists
Introduce --commit-exists.
Introduce --checked-out
Introduce --reachable
Introduce --tree-same.
Introduce --same
misc
whitespace fix.
tests --conflicted.
rebasing: add tests
test: git test cleanups.
Introduce git-atomic.
Introduce git base.
Introduce support for the git-work command.
.gitignore | 7 + Documentation/config.txt | 10 + Documentation/git-atomic.txt | 92 ++++++++ Documentation/git-base.txt | 216 ++++++++++++++++++ Documentation/git-test.txt | 182 +++++++++++++++ Documentation/git-work.txt | 163 ++++++++++++++ Makefile | 7 + git-atomic-lib.sh | 58 +++++ git-atomic.sh | 5 + git-base.sh | 378 +++++++++++++++++++++++++++++++ git-conditions-lib.sh | 176 +++++++++++++++ git-test-lib.sh | 188 ++++++++++++++++ git-test.sh | 11 + git-work.sh | 323 +++++++++++++++++++++++++++ t/t1520-test.sh | 506 ++++++++++++++++++++++++++++++++++++++++++ t/t3418-base.sh | 214 ++++++++++++++++++ t/t3419-atomic.sh | 59 +++++ t/t3421-work.sh | 174 +++++++++++++++ 18 files changed, 2769 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-atomic.txt create mode 100644 Documentation/git-base.txt create mode 100644 Documentation/git-test.txt create mode 100644 Documentation/git-work.txt create mode 100644 git-atomic-lib.sh create mode 100755 git-atomic.sh create mode 100644 git-base.sh create mode 100644 git-conditions-lib.sh create mode 100644 git-test-lib.sh create mode 100755 git-test.sh create mode 100644 git-work.sh create mode 100755 t/t1520-test.sh create mode 100755 t/t3418-base.sh create mode 100755 t/t3419-atomic.sh create mode 100755 t/t3421-work.sh
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 1/23 Introduce git-test.sh and git-test-lib.sh
This command is intended provide a uniform command line interface to a suite of assertions that can be made about the state of the working tree, index and repository.
This commit introduces the core assert infrastructure. Subsequent commits will introduce check functions that extend the infrastructure in a modular way with additional tests.
Replace environment with git configuration.
test_must_fail: core
--- .gitignore | 3 + Documentation/git-test.txt | 154 ++++++++++++++++++++++++++++++++++++ Makefile | 3 + git-conditions-lib.sh | 12 +++ git-test-lib.sh | 187 ++++++++++++++++++++++++++++++++++++++++++++ git-test.sh | 11 +++ t/t1520-test.sh | 185 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 555 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-test.txt create mode 100644 git-conditions-lib.sh create mode 100644 git-test-lib.sh create mode 100755 git-test.sh create mode 100755 t/t1520-test.sh
.gitignore +3 -0
@@ -27,6 +27,7 @@ /git-clone /git-commit /git-commit-tree +/git-conditions-lib /git-config /git-count-objects /git-cvsexportcommit
@@ -141,6 +142,8 @@ /git-symbolic-ref /git-tag /git-tar-tree +/git-test +/git-test-lib /git-unpack-file /git-unpack-objects /git-update-index
Documentation/git-test.txt new file +154 -0
154 lines not on this page · raw message
Makefile +3 -0
@@ -376,11 +376,14 @@ SCRIPT_SH += git-repack.sh SCRIPT_SH += git-request-pull.sh SCRIPT_SH += git-stash.sh SCRIPT_SH += git-submodule.sh +SCRIPT_SH += git-test.sh SCRIPT_SH += git-web--browse.sh +SCRIPT_LIB += git-conditions-lib SCRIPT_LIB += git-mergetool--lib SCRIPT_LIB += git-parse-remote SCRIPT_LIB += git-sh-setup +SCRIPT_LIB += git-test-lib SCRIPT_PERL += git-add--interactive.perl SCRIPT_PERL += git-difftool.perl
git-conditions-lib.sh new file +12 -0
@@ -0,0 +1,12 @@ +#!/bin/sh +# +# (c) Copyright Jon Seymour 2010 +# +if test -z "${__GIT_CONDITIONS_LIB_INCLUDED}" +then +__GIT_CONDITIONS_LIB_INCLUDED=t +# +# Provides a function that enables the evaluation of assertions. +# + +fi
git-test-lib.sh new file +187 -0
187 lines not on this page · raw message
git-test.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# +# (c) Copyright Jon Seymour 2010 +# +SUBDIRECTORY_OK=true +. git-sh-setup +. git-test-lib + +require_condition_libs + +assert "$@"
t/t1520-test.sh new file +185 -0
185 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 2/23 Introduce --unstaged.
In reply to Jon Seymourtest_must_fail: unstaged
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 11 +++++++++++ t/t1520-test.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -64,6 +64,8 @@ OPTIONS CONDITIONS ---------- +'--unstaged'|'--not-unstaged':: + Tests if there are (not) any unstaged changes in the working tree. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -8,5 +8,16 @@ __GIT_CONDITIONS_LIB_INCLUDED=t # # Provides a function that enables the evaluation of assertions. # +check_unstaged_0() +{ + if test $(git diff-files --name-only | wc -l) -ne 0 + then + echo "There are unstaged files." + else + echo "There are no unstaged files." + false + fi +} + fi
t/t1520-test.sh +35 -0
@@ -181,5 +181,40 @@ test_expect_success 'git test --not-always-fails-0' \ ' git test --not-always-fails-0 ' + +test_expect_success 'git test --unstaged # should fail' \ +' + test_must_fail git test --unstaged +' + +test_expect_success 'git test --not-unstaged' \ +' + git test --not-unstaged +' + +test_expect_success 'git test --unstaged # when there are unstaged files' \ +' + test_when_finished "git reset --hard HEAD && git checkout master" && + git checkout -f M^0 && + git stash apply --index STASH_UNSTAGED && + git test --unstaged +' + +test_expect_success 'git test --not-unstaged # when there are unstaged files - should fail' \ +' + test_when_finished "git reset --hard HEAD && git checkout master" && + git checkout -f M^0 && + git stash apply --index STASH_UNSTAGED && + test_must_fail git test --not-unstaged +' + +test_expect_success 'git test --unstaged # when there are only staged files' \ +' + test_when_finished "git reset --hard HEAD && git checkout master" && + git checkout -f M^0 && + git stash apply --index STASH_STAGED && + git test --not-unstaged +' + ' test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 3/23 Introduce --staged
In reply to Jon Seymourtest_must_fail: --not-staged
--- Documentation/git-test.txt | 3 ++ git-conditions-lib.sh | 11 ++++++++++ t/t1520-test.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 0 deletions(-)
Documentation/git-test.txt +3 -0
@@ -66,6 +66,9 @@ CONDITIONS ---------- '--unstaged'|'--not-unstaged':: Tests if there are (not) any unstaged changes in the working tree. +'--staged'|'--not-staged':: + Tests if there are (not) any staged changes in the index. + EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -19,5 +19,16 @@ check_unstaged_0() fi } +check_staged_0() +{ + if test $(git diff-index --cached --name-only HEAD | wc -l) -ne 0 + then + echo "There are staged files." + else + echo "There are no staged files." + false + fi +} + fi
t/t1520-test.sh +45 -0
50 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 4/23 Introduce --untracked.
In reply to Jon SeymourAdd tests for --untracked, --not-untracked.
--- Documentation/git-test.txt | 3 ++- git-conditions-lib.sh | 11 +++++++++++ t/t1520-test.sh | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletions(-)
Documentation/git-test.txt +2 -1
@@ -68,7 +68,8 @@ CONDITIONS Tests if there are (not) any unstaged changes in the working tree. '--staged'|'--not-staged':: Tests if there are (not) any staged changes in the index. - +'--untracked'|'--not-untracked':: + Tests if there are (not) any untracked files in the working tree. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -30,5 +30,16 @@ check_staged_0() fi } +check_untracked_0() +{ + if test $(git ls-files -o --exclude-standard | wc -l) -ne 0 + then + echo "There are untracked files." + else + echo "There are no untracked files." + false + fi +} + fi
t/t1520-test.sh +24 -0
@@ -250,6 +250,30 @@ test_expect_success 'git test --staged # when there are only unstaged files' \ git test --not-staged ' +test_expect_success 'git test --untracked # should fail' \ +' + test_must_fail git test --untracked +' + +test_expect_success 'git test --not-untracked' \ +' + git test --not-untracked +' + +test_expect_success 'git test --untracked # when there are untracked files' \ +' + test_when_finished "git clean -fd" && + :> untracked && + git test --untracked +' + +test_expect_success 'git test --not-untracked # when there are untracked files - should fail' \ +' + test_when_finished "git clean -fd" && + :> untracked && + test_must_fail git test --not-untracked +' + ' test_when_finished "git reset --hard HEAD && git checkout master" && git test --not-staged --not-unstaged &&
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 5/23 Introduce --conflicted
In reply to Jon Seymour--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -70,6 +70,8 @@ CONDITIONS Tests if there are (not) any staged changes in the index. '--untracked'|'--not-untracked':: Tests if there are (not) any untracked files in the working tree. +'--conflicted'|'--not-conflicted':: + Tests if there are (not) any merge conflicts in the index. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +12 -0
@@ -41,5 +41,17 @@ check_untracked_0() fi } +check_conflicted_0() +{ + if test $(git ls-files --unmerged | wc -l) -ne 0 + then + echo "There are unmerged files." + else + echo "There are no unmerged files." + false + fi + +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 6/23 Introduce --rebasing
In reply to Jon Seymour--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -72,6 +72,8 @@ CONDITIONS Tests if there are (not) any untracked files in the working tree. '--conflicted'|'--not-conflicted':: Tests if there are (not) any merge conflicts in the index. +'--rebasing'|'--not-rebasing':: + Tests if a rebase is (not) in progress. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -53,5 +53,16 @@ check_conflicted_0() } +check_rebasing_0() +{ + if test -d "$(git rev-parse --git-dir)/rebase-apply" + then + echo "A rebase is in progress." + else + echo "There is no rebase in progress." + false + fi +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 7/23 Introduce --detached
In reply to Jon Seymourdetached
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 11 +++++++++++ t/t1520-test.sh | 30 +++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 9 deletions(-)
Documentation/git-test.txt +2 -0
@@ -74,6 +74,8 @@ CONDITIONS Tests if there are (not) any merge conflicts in the index. '--rebasing'|'--not-rebasing':: Tests if a rebase is (not) in progress. +'--detached'|'--not-detached':: + Tests if the head is (not) detached. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -64,5 +64,16 @@ check_rebasing_0() fi } +check_detached_0() +{ + if ! git symbolic-ref -q HEAD >/dev/null + then + echo "HEAD is detached." + else + echo "HEAD is not detached." + false + fi +} + fi
t/t1520-test.sh +21 -9
@@ -274,16 +274,28 @@ test_expect_success 'git test --not-untracked # when there are untracked files - test_must_fail git test --not-untracked ' +test_expect_success 'git test --not-detached' \ ' - test_when_finished "git reset --hard HEAD && git checkout master" && - git test --not-staged --not-unstaged && - ! git test --staged && - ! git test --unstaged && - git checkout M^0 && - git stash apply --index STASH_STAGED && - git test --not-unstaged --staged && - ! git test --unstaged && - ! git test --not-staged + git test --not-detached +' + +test_expect_success 'git test --detached # should fail' \ +' + test_must_fail git test --detached +' + +test_expect_success 'git test --not-detached # when detached, should fail' \ +' + test_when_finished "git checkout -f master" && + git checkout HEAD^0 && + test_must_fail git test --not-detached +' + +test_expect_success 'git test --detached # when detached' \ +' + test_when_finished "git checkout -f master" && + git checkout HEAD^0 && + git test --detached ' test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 8/23 Introduce --branch-exists
In reply to Jon Seymourtweak branch
tweak branch
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -76,6 +76,8 @@ CONDITIONS Tests if a rebase is (not) in progress. '--detached'|'--not-detached':: Tests if the head is (not) detached. +'--branch-exists'|'--not-branch-exists branch':: + Tests if the specified branch does (not) exist. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +12 -0
@@ -75,5 +75,17 @@ check_detached_0() fi } +check_branch_exists_1() +{ + symbolic=$(git rev-parse --quiet --symbolic-full-name --verify "$1") + if test "${symbolic#refs/heads/}" != "${symbolic}" + then + echo "Branch '$1' exists." + else + echo "Branch '$1' does not exist." + false + fi +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 9/23 Introduce --tag-exists
In reply to Jon Seymourtweak tag
tweak tag
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -78,6 +78,8 @@ CONDITIONS Tests if the head is (not) detached. '--branch-exists'|'--not-branch-exists branch':: Tests if the specified branch does (not) exist. +'--tag-exists'|'--not-tag-exists tag':: + Tests if the specified tag does (not) exist. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +12 -0
@@ -87,5 +87,17 @@ check_branch_exists_1() fi } +check_tag_exists_1() +{ + symbolic=$(git rev-parse --quiet --symbolic-full-name --verify "$1") + if test "${symbolic#refs/tags/}" != "${symbolic}" + then + echo "Tag '$1' exists." + else + echo "Tag '$1' does not exist." + false + fi +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 10/23 Introduce --ref-exists
In reply to Jon Seymourtweak ref
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -80,6 +80,8 @@ CONDITIONS Tests if the specified branch does (not) exist. '--tag-exists'|'--not-tag-exists tag':: Tests if the specified tag does (not) exist. +'--ref-exists'|'--not-ref-exists tag':: + Tests if the specified reference does (not) exist. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +12 -0
@@ -99,5 +99,17 @@ check_tag_exists_1() fi } +check_ref_exists_1() +{ + symbolic=$(git rev-parse --quiet --symbolic-full-name --verify "$1") + if test "${symbolic#refs/}" != "${symbolic}" + then + echo "Reference '$1' exists." + else + echo "Reference '$1' does not exist." + false + fi +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 11/23 Introduce --commit-exists.
In reply to Jon Seymourtweak commit
--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -82,6 +82,8 @@ CONDITIONS Tests if the specified tag does (not) exist. '--ref-exists'|'--not-ref-exists tag':: Tests if the specified reference does (not) exist. +'--commit-exists'|'--not-commit-exists commit':: + Tests if the specified commit does (not) exist. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +11 -0
@@ -111,5 +111,16 @@ check_ref_exists_1() fi } +check_commit_exists_1() +{ + if test "$(git cat-file -t "$1")" = 'commit' + then + echo "Commit '$1' exists." + else + echo "Commit '$1' does not exist." + false + fi +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 12/23 Introduce --checked-out
In reply to Jon Seymour--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -84,6 +84,8 @@ CONDITIONS Tests if the specified reference does (not) exist. '--commit-exists'|'--not-commit-exists commit':: Tests if the specified commit does (not) exist. +'--checked-out'|'--not-checked-out branch':: + Tests if the specified branch is (not) checked out. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +14 -0
@@ -122,5 +122,19 @@ check_commit_exists_1() fi } +check_checked_out_1() +{ + branch="$(git rev-parse --quiet --symbolic-full-name --verify "$1")" + headref="$(git symbolic-ref HEAD)" + if test "${headref}" = "${branch}" -a -n "${branch}" + then + echo "'$1' is checked out." + else + echo "'$1' is not checked out." + false + fi + +} + fi
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 13/23 Introduce --reachable
In reply to Jon Seymourreachable
--- Documentation/git-test.txt | 2 + git-conditions-lib.sh | 14 ++++++ t/t1520-test.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -86,6 +86,8 @@ CONDITIONS Tests if the specified commit does (not) exist. '--checked-out'|'--not-checked-out branch':: Tests if the specified branch is (not) checked out. +'--reachable'|'--not-reachable' first second:: + Tests if the first commit is (not) reachable from the second. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +14 -0
@@ -136,5 +136,19 @@ check_checked_out_1() } +check_reachable_2() +{ + first=$(git rev-parse --quiet --verify "$1" 2>/dev/null) || die "'$1' is not a commit" + second=$(git rev-parse --quiet --verify "$2" 2>/dev/null) || die "'$2' is not a commit" + if test "$first" = "$second" \ + -o -z "$(git rev-list -n1 "$first" ^"$second")" + then + echo "'$1' is reachable from '$2'." + else + echo "'$1' is not reachable from '$2'." + false + fi +} + fi
t/t1520-test.sh +101 -0
105 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 14/23 Introduce --tree-same.
In reply to Jon Seymour--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 12 ++++++++++++ t/t1520-test.sh | 9 +++++++++ 3 files changed, 23 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -88,6 +88,8 @@ CONDITIONS Tests if the specified branch is (not) checked out. '--reachable'|'--not-reachable' first second:: Tests if the first commit is (not) reachable from the second. +'--tree-same'|'--not-tree-same' first second:: + Tests if the first commit is (not) tree-same to the second commit. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +12 -0
@@ -150,5 +150,17 @@ check_reachable_2() fi } +check_tree_same_2() +{ + if git diff-tree --quiet "$1" "$2" + then + echo "'$1' has the same tree as '$2'." + else + echo "'$1' does not have the same tree as '$2'." + false + fi + +} + fi
t/t1520-test.sh +9 -0
@@ -399,4 +399,13 @@ test_expect_success 'git test --not-reachable F C' \ git test --not-reachable F C ' +test_expect_success 'tree-same' \ +' + git test \ + --tree-same master HEAD \ + --tree-same D D1 \ + --not-tree-same C D + +' + test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 15/23 Introduce --same
In reply to Jon Seymour--- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 10 ++++++++++ t/t1520-test.sh | 8 ++++++++ 3 files changed, 20 insertions(+), 0 deletions(-)
Documentation/git-test.txt +2 -0
@@ -90,6 +90,8 @@ CONDITIONS Tests if the first commit is (not) reachable from the second. '--tree-same'|'--not-tree-same' first second:: Tests if the first commit is (not) tree-same to the second commit. +'--same'|'--not-same' first second:: + Tests if the first object has (does not have) the same SHA1 has as the second object. EXTENDING THE CONDITION LIBRARY -------------------------------
git-conditions-lib.sh +10 -0
@@ -162,5 +162,15 @@ check_tree_same_2() } +check_same_2() +{ + if test "$(git rev-parse "$1")" = "$(git rev-parse "$2")" + then + echo "'$1' is the same as '$2'." + else + echo "'$1' is not the same as '$2'." + false + fi +} fi
t/t1520-test.sh +8 -0
@@ -408,4 +408,12 @@ test_expect_success 'tree-same' \ ' +test_expect_success 'same' \ +' + git test \ + --same master HEAD \ + --not-same D D1 \ + --not-same C D +' + test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 16/23 misc
In reply to Jon Seymour--- t/t1520-test.sh | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
t/t1520-test.sh +26 -0
@@ -416,4 +416,30 @@ test_expect_success 'same' \ --not-same C D ' +test_expect_success 'clean' \ +' + git test \ + --not-staged \ + --not-unstaged \ + --not-detached \ + --not-untracked \ + --not-rebasing \ + --not-conflicted +' + +test_expect_success 'existence' \ +' + git test \ + --commit-exists M \ + --not-commit-exists N \ + --ref-exists refs/tags/M \ + --not-ref-exists refs/tags/N \ + --branch-exists master \ + --not-branch-exists N \ + --tag-exists D \ + --not-tag-exists N \ + --not-tag-exists master \ + --not-branch-exists A + ' + test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 17/23 whitespace fix.
In reply to Jon Seymour--- t/t1520-test.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
t/t1520-test.sh +1 -1
@@ -440,6 +440,6 @@ test_expect_success 'existence' \ --not-tag-exists N \ --not-tag-exists master \ --not-branch-exists A - ' +' test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 18/23 tests --conflicted.
In reply to Jon Seymour--- t/t1520-test.sh | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
t/t1520-test.sh +26 -0
@@ -442,4 +442,30 @@ test_expect_success 'existence' \ --not-branch-exists A ' +test_expect_success 'git test --conflicted # should fail' \ +' + test_must_fail git test --conflicted +' + +test_expect_success 'git test --not-conflicted' \ +' + git test --not-conflicted +' + +test_expect_success 'git test --conflicted' \ +' + test_when_finished "git reset --hard HEAD" && + ! git merge F && + git test --conflicted + +' + +test_expect_success 'git test --not-conflicted # should fail when there are conflcted files' \ +' + test_when_finished "git reset --hard HEAD" && + ! git merge F && + test_must_fail git test --not-conflicted + +' + test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 19/23 rebasing: add tests
In reply to Jon Seymour--- t/t1520-test.sh | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-)
t/t1520-test.sh +35 -0
@@ -468,4 +468,39 @@ test_expect_success 'git test --not-conflicted # should fail when there are conf ' +test_expect_success 'git test --rebasing # should fail' \ +' + test_must_fail git test --rebasing +' + +test_expect_success 'git test --not-rebasing' \ +' + git test --not-rebasing +' + +test_expect_success 'git test --rebasing' \ +' + test_when_finished " + git reset --hard HEAD && + git checkout -f master && + git branch -D rebase + " && + git branch rebase F && + ! git rebase --onto D F~1 F + git test --rebasing + +' + +test_expect_success 'git test --not-rebasing' \ +' + test_when_finished " + git reset --hard HEAD && + git checkout -f master && + git branch -D rebase + " && + git branch rebase F && + ! git rebase --onto D F~1 F + test_must_fail git test --not-rebasing +' + test_done
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 20/23 test: git test cleanups.
In reply to Jon Seymour--- Documentation/git-test.txt | 48 +++++++++++++++++++++--------------------- git-conditions-lib.sh | 4 +- git-test-lib.sh | 11 +++++---- t/t1520-test.sh | 50 ++++++++++++++++++++++---------------------- 4 files changed, 57 insertions(+), 56 deletions(-)
Documentation/git-test.txt +24 -24
@@ -7,7 +7,7 @@ git-test - evaluates one or more conditions about the state of the git working t SYNOPSIS -------- -The git test API is available in the form of a command and also as a shell library. +The git test API is available in the form of a command and also as a shell library. COMMAND SYNOPSIS ----------------
@@ -27,28 +27,28 @@ DESCRIPTION `git test` provides a uniform, extensible API for evaluating various conditions that pertain to the state of a git working tree, index and repository. -Specified conditions are evaluated from left to right. If any condition evaluates to false, -the command conditionally prints a diagnostic message to stderr and sets a -non-zero status code. Otherwise, sets a status code of zero. +Specified conditions are evaluated from left to right. If any condition evaluates to false, +the command conditionally prints a diagnostic message to stderr and sets a +non-zero status code. Otherwise, sets a status code of zero. The message used to report a assertion failure may be overidden by specifying the --message option. -Diagnostic output resulting from an assertion failure may be suppressed with the -q option. -Note that the -q option does not suppress diagnostic output that results from the failure to +Diagnostic output resulting from an assertion failure may be suppressed with the -q option. +Note that the -q option does not suppress diagnostic output that results from the failure to successfully parse the arguments that configure the test API. -The `assert` and `test_condition` functions differ according to how they handle failing conditions. +The `assert` and `test_condition` functions differ according to how they handle failing conditions. -The `assert` function behaves like the test command but assertion failures will cause +The `assert` function behaves like the test command but assertion failures will cause the current shell to exit with a non-zero status code. To prevent this occurring, invoke the `assert` function within a subshell or use the `test_condition` function instead. The `test_condition` function will not exit the current shell in the event that an assertion failure -is detected nor will it generate diagnostic relating to an assertion failure to stderr. +is detected nor will it generate diagnostic relating to an assertion failure to stderr. -Note, however, that `test_condition` may still exit the current shell with a non-zero status code -if it is unable to successfully parse the arguments presented to it. Callers who need to protect -against this possibility either guarantee that the required arguments are available or +Note, however, that `test_condition` may still exit the current shell with a non-zero status code +if it is unable to successfully parse the arguments presented to it. Callers who need to protect +against this possibility either guarantee that the required arguments are available or imbed calls to `test_condition` within a subshell. The `require_condition_libs` function may be used to include any condition libs listed
@@ -77,7 +77,7 @@ CONDITIONS '--detached'|'--not-detached':: Tests if the head is (not) detached. '--branch-exists'|'--not-branch-exists branch':: - Tests if the specified branch does (not) exist. + Tests if the specified branch does (not) exist. '--tag-exists'|'--not-tag-exists tag':: Tests if the specified tag does (not) exist. '--ref-exists'|'--not-ref-exists tag'::
@@ -95,15 +95,15 @@ CONDITIONS EXTENDING THE CONDITION LIBRARY ------------------------------- -The library of conditions that the assert API can process may be extended by -adding functions of the form check_\{dehyphenated_condition_name\}_N to the -shell environment, where \{dehyphenated_condition_name\} is the result of -replacing any occurrence of \'-\' in the condition name with \'_\' and +The library of conditions that the assert API can process may be extended by +adding functions of the form check_\{dehyphenated_condition_name\}_N to the +shell environment, where \{dehyphenated_condition_name\} is the result of +replacing any occurrence of \'-\' in the condition name with \'_\' and N is the number of arguments that need to be passed to the function. -For example, suppose you are writing a script, foo.sh, that includes the git test library -and that you want to add a new, 1-argument, condition, foo-X to the library of -conditions that can be tested by the git testion framework. +For example, suppose you are writing a script, foo.sh, that includes the git test library +and that you want to add a new, 1-argument, condition, foo-X to the library of +conditions that can be tested by the git testion framework. --------- #/bin/sh
@@ -133,8 +133,8 @@ executes without generating any output on stdout. The resulting state will then be interpreted as condition evaluation failure rather than an assertion failure. -To make such conditions available to the git test command line, put the -function in a file called ~/foo-lib,sh add a reference +To make such conditions available to the git test command line, put the +function in a file called ~/foo-lib,sh add a reference to the library to the git configuration, like so: ---------
@@ -163,9 +163,9 @@ git test --not-staged --not-unstaged && git reset --hard another-commit ----------- . $(git --exec-path)/git-test-lib assert --not-staged # die if there are any staged files -assert --message "there are staged files" --not-staged # die with an alternative message +assert --message "there are staged files" --not-staged # die with an alternative message # if there are any staged files -test_condition --not-staged || echo "there are staged files" # check whether there are staged files, +test_condition --not-staged || echo "there are staged files" # check whether there are staged files, # but do not die if there are -----------
git-conditions-lib.sh +2 -2
@@ -141,13 +141,13 @@ check_reachable_2() first=$(git rev-parse --quiet --verify "$1" 2>/dev/null) || die "'$1' is not a commit" second=$(git rev-parse --quiet --verify "$2" 2>/dev/null) || die "'$2' is not a commit" if test "$first" = "$second" \ - -o -z "$(git rev-list -n1 "$first" ^"$second")" + -o -z "$(git rev-list -n1 "$first" ^"$second")" then echo "'$1' is reachable from '$2'." else echo "'$1' is not reachable from '$2'." false - fi + fi } check_tree_same_2()
git-test-lib.sh +6 -5
@@ -34,7 +34,7 @@ require_lib() require_condition_libs() { eval $( git config --get-all condition.lib | while read lib - do + do echo "require_lib \"$lib\" \;" done )
@@ -42,7 +42,7 @@ require_condition_libs() { assertion_failed() { rc=$1 - shift + shift message="${MESSAGE:-$*}" if ! ${QUIET:-false} then
@@ -98,6 +98,7 @@ impl() { shift case $word in --message) + test $# -gt 0 || die "--message requires the following argument to be a message" MESSAGE=$1 shift continue
@@ -106,7 +107,7 @@ impl() { test $# -gt 0 || die "can't shift 1 argument for --include option" test -f "$1" || die "'$1' must be a file" require_lib "$1" - shift + shift continue ;; -q)
@@ -143,7 +144,7 @@ impl() { exprs="${exprs}${exprs:+ }${negation}${negation:+ }$word $try check_${dehyphenated}_$try $args" - done + done set -- $exprs while test $# -gt 0
@@ -158,7 +159,7 @@ impl() { word=$1 nargs=$2 shift 2 - message=$(eval $negation "$@") + message=$(eval $negation "$@") rc=$? if test $rc -ne 0 then
t/t1520-test.sh +25 -25
177 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 21/23 Introduce git-atomic.
In reply to Jon Seymourgit atomic is intended to provide a simple way to for porcelains to execute atomic operations on the git repository.
An atomic operation either completes successfully or the working tree, index and selected references are returned to their original state.
--- .gitignore | 2 + Documentation/git-atomic.txt | 92 ++++++++++++++++++++++++++++++++++++++++++ Makefile | 2 + git-atomic-lib.sh | 58 ++++++++++++++++++++++++++ git-atomic.sh | 5 ++ t/t3419-atomic.sh | 59 +++++++++++++++++++++++++++ 6 files changed, 218 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-atomic.txt create mode 100644 git-atomic-lib.sh create mode 100755 git-atomic.sh create mode 100755 t/t3419-atomic.sh
.gitignore +2 -0
@@ -11,6 +11,8 @@ /git-apply /git-archimport /git-archive +/git-atomic +/git-atomic-lib /git-bisect /git-bisect--helper /git-blame
Documentation/git-atomic.txt new file +92 -0
92 lines not on this page · raw message
Makefile +2 -0
@@ -360,6 +360,7 @@ TEST_PROGRAMS_NEED_X = unexport CDPATH SCRIPT_SH += git-am.sh +SCRIPT_SH += git-atomic.sh SCRIPT_SH += git-bisect.sh SCRIPT_SH += git-difftool--helper.sh SCRIPT_SH += git-filter-branch.sh
@@ -379,6 +380,7 @@ SCRIPT_SH += git-submodule.sh SCRIPT_SH += git-test.sh SCRIPT_SH += git-web--browse.sh +SCRIPT_LIB += git-atomic-lib SCRIPT_LIB += git-conditions-lib SCRIPT_LIB += git-mergetool--lib SCRIPT_LIB += git-parse-remote
git-atomic-lib.sh new file +58 -0
58 lines not on this page · raw message
git-atomic.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/sh +SUBDIRECTORY_OK=true +. git-sh-setup +. git-atomic-lib +atomic "$@"
t/t3419-atomic.sh new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 22/23 Introduce git base.
In reply to Jon Seymourgit base is intended to provide a way to track the 'base' of the current branch, where the base is one of several possible commits that satisfies the following invariant.
The base is reachable from the head the output
git rev-list base..head --merges is empty.
git base is intended to provide a sane way to keep track of the commit at the base of the current branch and thereby simplify the process of rebasing, or more generally, dependency managment.
For example of how it is used, see the following git-work command.
--- .gitignore | 1 + Documentation/config.txt | 10 ++ Documentation/git-base.txt | 216 +++++++++++++++++++++++++ Makefile | 1 + git-base.sh | 378 ++++++++++++++++++++++++++++++++++++++++++++ t/t3418-base.sh | 214 +++++++++++++++++++++++++ 6 files changed, 820 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-base.txt create mode 100644 git-base.sh create mode 100755 t/t3418-base.sh
.gitignore +1 -0
@@ -13,6 +13,7 @@ /git-archive /git-atomic /git-atomic-lib +/git-base /git-bisect /git-bisect--helper /git-blame
Documentation/config.txt +10 -0
@@ -636,6 +636,16 @@ branch.autosetuprebase:: branch to track another branch. This option defaults to never. +branch.<name>.baseresetoptions:: + The options passed to 'git base set' when 'git base' detects + that the current base reference is either not set or no longer + satisfies the base invariant. + See the description of the `init` command in linkgit:git-base[1] + for details of how this value is initialized. + See the description of the `set` command in linkgit:git-base[1] + for details about this value is interpreted. + Defaults to --fail unless set. + branch.<name>.remote:: When in branch <name>, it tells 'git fetch' and 'git push' which remote to fetch from/push to. It defaults to `origin` if no remote is
Documentation/git-base.txt new file +216 -0
216 lines not on this page · raw message
Makefile +1 -0
@@ -361,6 +361,7 @@ unexport CDPATH SCRIPT_SH += git-am.sh SCRIPT_SH += git-atomic.sh +SCRIPT_SH += git-base.sh SCRIPT_SH += git-bisect.sh SCRIPT_SH += git-difftool--helper.sh SCRIPT_SH += git-filter-branch.sh
git-base.sh new file +378 -0
378 lines not on this page · raw message
t/t3418-base.sh new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
PATCH 23/23 Introduce support for the git-work command.
In reply to Jon SeymourThe git work command uses the implicit base defined by git base to help perform dependency management on a working branch.
See the Documentation for a description of the philosophy underlying git-work.
--- .gitignore | 1 + Documentation/git-work.txt | 163 ++++++++++++++++++++++ Makefile | 1 + git-work.sh | 323 ++++++++++++++++++++++++++++++++++++++++++++ t/t3421-work.sh | 174 ++++++++++++++++++++++++ 5 files changed, 662 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-work.txt create mode 100644 git-work.sh create mode 100755 t/t3421-work.sh
.gitignore +1 -0
@@ -159,6 +159,7 @@ /git-verify-tag /git-web--browse /git-whatchanged +/git-work /git-write-tree /git-core-*/?* /gitk-git/gitk-wish
Documentation/git-work.txt new file +163 -0
163 lines not on this page · raw message
Makefile +1 -0
@@ -380,6 +380,7 @@ SCRIPT_SH += git-stash.sh SCRIPT_SH += git-submodule.sh SCRIPT_SH += git-test.sh SCRIPT_SH += git-web--browse.sh +SCRIPT_SH += git-work.sh SCRIPT_LIB += git-atomic-lib SCRIPT_LIB += git-conditions-lib
git-work.sh new file +323 -0
323 lines not on this page · raw message
t/t3421-work.sh new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.7.5.rc1.23.g7f622
Quoted 48 lines · Jon Seymour
This series is posted in order to solicit feedback about some commands I'd like to propose for inclusion in git.
The commands are:
git test
git atomic
git base
git workgit work
========git work depends on the other 3 commands.
git work is the command I have been using every day myself for the last 8 months. It is the primary means I use to manage my working tree.
The basic idea of git work is to help manage a private working tree using the following principles:
* all dependencies received from others are merged into the 'base' of the working tree
git work merge some-dependency
- merges some-dependency into $(git base) producing (1)
- rebases $(git base)..HEAD onto (1) producing (2)
- resets the current branch to (2)
- updates $(git base) to refer to (1)* all unpublished work is managed as a linear sequence of commits on top of the 'base' of the working tree
so,
git work --as-refs # shows you a symbolic range for your current work git work # shows you a SHA1 range for your current work gitk $(git work) # shows you your unpublished work
git diff $(git work) # shows you the diff of your current work* prior to publishing work, you rebase it onto an appropriate base commit
so,
git branch topic upstream/master # choose the base commit for the topic
git work update topic HEAD~3 # pull the top 3 commits off the working tree onto the topic- rebases HEAD~3..HEAD onto topic to produce (1)
- merges topic into $(git base) to produce (2)
- rebases $(git base)..HEAD~3 onto (2) to produce (3)
- resets the current branch to (3)
- resets $(git base) to (2)
Quoted 4 lines
The nice thing about managing your work tree this way is that your working tree remains relatively stable (it always contains everything you have recently been working on) and your topic branches remain clean (i.e. they never contain any other cruft from your working tree).
Reading this I have to admit I don't fully grok it, but it *sounds* like a solution to my problematic workflow. Perhaps you can supply some examples, because reading the unit tests for git work hasn't enlightened me.
Ok, let me explain what I am aiming for:
I am stuck with git-svn (our customer is not yet ready to use git) and therefore have a remote branch remotes/trunk tracking the trunk in SVN. Then there is at least one debug branch which contains several commits only used to debug problems or to speed up testing (e.g. avoid popping up error dialogs that some hardware is missing on one of our test platforms, or to add more logging statements not suitable for the mainline). Furthermore, there are several feature branches, lets call them topic{1, ...N}
. - q - q <- topic3
/
. -s - s - s <- topic2
/
/ t - t - t <- topic1
/ /
/ / o - o - o - o - o - o - o <- remotes/trunk, master \
d - d <- debug
If I want to deploy the software onto our target machine, I want to have the code of several branches merged/combined to test them in integration. If I suspect problems in one of the topics, I at least must have the topicX, debug and the upstream branch remotes/trunk.
So my workflow would have been - if it weren't clumsy - the following
git checkout master
git merge debug topic1 topic2 topic3
... compile ... deploy ... test
. - q - q -. <- topic3
/ \
. -s - s - s ---. \ <- topic2
/ \|
/ t - t - t - - -\ <- topic1
/ / m <- master
/ / / | o - o - o - o - o - o - o | <- remotes/trunk
\ /
d - d - - <- debug
Having fond a small error, I can't commit it directly on the merge m, because It is actually a fix a topic branch. Running git checkout topicX before doing any change is also not an option, because I often forget to checkout the topic before commiting. And rebasing afterwards is also not that easy, because there is merge m in between. So this isn't what I actually use, but would be *iff* there where some sort of tool support to help me.
What I end up doing is the following:
- o - o <- remotes/trunk
\
d - d <- debug
\
t - t -t <- topic1
\
s - s -s <- topic2
\
q - q <- topic3, masterThe topic branches are just there for illustration, I normally do not track those explicitly with git branches, as master is rebase often on top of trunk, thanks to git-svn. Now if I do want to commit a topic branch to SVN, I rebase
so that my history is now trunk - topic1 - debug - topic2 - topic3, master
and then run git checkout topic1; git svn dcommit to make sure only the commits in topic1 are commited.
All in all, this workflow is not perfect, but at least it sort of works.
Now back to my initial question:
Could your new "git work" command help me to adjust my workflow and ease the pain?
Greetings,
Peter
Quoted 111 lines
git base
========git base is a command that is heavily relied on by git work, and is occasionally used by the user to reset the base of their working tree.
git base tries to automagically maintain the base of the working tree by maintaining an invariant that the path between the base and the tip of the current branch should never traverse a merge. If it ever finds the invariant violated, it calls 'git base reset' to attempt to restore the invariant.
For more information about git base, refer to the
Documentation/git-base.txtgit atomic
==========
git atomic is more an experiment than anything else. The idea is to run another git operation "atomically". The git operation either succeeds or it fails. If it fails, git branch attempts to restore the working tree and current branch to the state they were in to their original state prior to the comamnd being run.The reason I need something like this is that git work performs several operations in sequence some of which I can't guarantee will work. I don't want the user to work out what they have to do to recover, so I try to restore to the state they were originally in.
Note: the current implementation doesn't handle rebase failures properly and would probably needed to be cleaned up a little before being accepted into the mainline.
git test
========
This is another experiment. The idea is to provide a uniform way to test for various conditions into the working tree, index and repo. For example:git test --not-unstaged --branch-exists foobarwill fail if there are unstaged files in the working tree or the branch foobar does not exist.
As I say, git atomic and git test are somewhat experimental. I don't really care about those commands and if the consensus is that git doesn't need them, I am happy to rework git base and git work to not use them.
However, I would like to propose git base and git work as being very useful additions to the git toolset.
Let me know if the consensus is that I should proceed with a submission and I will prepare one.
Jon Seymour (23):
Introducegit-test.shandgit-test-lib.sh
Introduce --unstaged.
Introduce --staged
Introduce --untracked.
Introduce --conflicted
Introduce --rebasing
Introduce --detached
Introduce --branch-exists
Introduce --tag-exists
Introduce --ref-exists
Introduce --commit-exists.
Introduce --checked-out
Introduce --reachable
Introduce --tree-same.
Introduce --same
misc
whitespace fix.
tests --conflicted.
rebasing: add tests
test: git test cleanups.
Introduce git-atomic.
Introduce git base.
Introduce support for the git-work command..gitignore | 7 + Documentation/config.txt | 10 + Documentation/git-atomic.txt | 92 ++++++++ Documentation/git-base.txt | 216 ++++++++++++++++++ Documentation/git-test.txt | 182 +++++++++++++++ Documentation/git-work.txt | 163 ++++++++++++++ Makefile | 7 + git-atomic-lib.sh | 58 +++++ git-atomic.sh | 5 + git-base.sh | 378 +++++++++++++++++++++++++++++++ git-conditions-lib.sh | 176 +++++++++++++++ git-test-lib.sh | 188 ++++++++++++++++ git-test.sh | 11 + git-work.sh | 323 +++++++++++++++++++++++++++ t/t1520-test.sh | 506 ++++++++++++++++++++++++++++++++++++++++++ t/t3418-base.sh | 214 ++++++++++++++++++ t/t3419-atomic.sh | 59 +++++ t/t3421-work.sh | 174 +++++++++++++++ 18 files changed, 2769 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-atomic.txt create mode 100644 Documentation/git-base.txt create mode 100644 Documentation/git-test.txt create mode 100644 Documentation/git-work.txt create mode 100644 git-atomic-lib.sh create mode 100755 git-atomic.sh create mode 100644 git-base.sh create mode 100644 git-conditions-lib.sh create mode 100644 git-test-lib.sh create mode 100755 git-test.sh create mode 100644 git-work.sh create mode 100755 t/t1520-test.sh create mode 100755 t/t3418-base.sh create mode 100755 t/t3419-atomic.sh create mode 100755 t/t3421-work.shSignature · 6 lines
1.7.5.rc1.23.g7f622 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 43 lines · Peter Baumann
On Sat, Apr 23, 2011 at 05:22:29PM +1000, Jon Seymour
git checkout master
git merge debug topic1 topic2 topic3
... compile ... deploy ... test. - q - q -. <- topic3 / \
. -s - s - s ---. \ <- topic2 / \|
/ t - t - t - - -\ <- topic1 / / m <- master / / / |
o - o - o - o - o - o - o | <- remotes/trunk \ /
d - d - - <- debugHaving fond a small error, I can't commit it directly on the merge m, because It is actually a fix a topic branch. Running git checkout topicX before doing any change is also not an option, because I often forget to checkout the topic before commiting. And rebasing afterwards is also not that easy, because there is merge m in between. So this isn't what I actually use, but would be *iff* there where some sort of tool support to help me.
What I end up doing is the following:
- o - o <- remotes/trunk
\
d - d <- debug
\
t - t -t <- topic1
\
s - s -s <- topic2
\
q - q <- topic3, masterThe topic branches are just there for illustration, I normally do not track those explicitly with git branches, as master is rebase often on top of trunk, thanks to git-svn. Now if I do want to commit a topic branch to SVN, I rebase so that my history is now trunk - topic1 - debug - topic2 - topic3, master and then run git checkout topic1; git svn dcommit to make sure only the commits in topic1 are commited.
Quoted 7 lines
All in all, this workflow is not perfect, but at least it sort of works.
Now back to my initial question:
Could your new "git work" command help me to adjust my workflow and ease the pain?Quoted 1 line
Peter
Hi Peter,
Yes, git work is good for this use case.
You would tend to manage you master branch as in your first diagram above.
Suppose you found a problem on topicX. So, you fix the issue inplace on the top of your master that includes all 5 dependencies. Call this commit m'.
You have decided that the fix really belongs on topic2. So what you do is:
git work update topic2 HEAD~1
This will move that commit onto the tip of topic2 (producing topic2'), merge that into m (producing m''), and reset master to m''.
One thing to note is that you never share master. It will be a merge hell. You only ever share topics when they become stable.
As the trunk gets updated you do:
git work merge remotes/trunk
It will merge remotes/trunk into the base of your unpublished work, then rebase your unpublished work onto that merge.
git work is also excellent for keeping your debug branch available in your working tree but isolated from your topics.
Things get little tricker when you have a commit that spans multiple topics. However, there is a straight forward methodology for managing such issues. There are also techniques for dealing with conflicts with any dependency, especially remotes/trunk which I can explain in another note if there is interest.
Jon.
BTW anyone interested in trying git work can fetch the tag containing this series from my github fork
Web link here:
https://github.com/jonseymour/git/tree/work-20110423
git://github.com/jonseymour/git, tag work-20110423
jon.
Also, anyone interested in browsing the HTML documentation for these commands can read:
https://s3.amazonaws.com/jonseymour/git-work.html
https://s3.amazonaws.com/jonseymour/git-base.html
https://s3.amazonaws.com/jonseymour/git-atomic.html
https://s3.amazonaws.com/jonseymour/git-test.html
jon.
Quoted 11 lines · Jon Seymour
BTW anyone interested in trying git work can fetch the tag containing this series from my github fork
Web link here:
https://github.com/jonseymour/git/tree/work-20110423
git://github.com/jonseymour/git, tag work-20110423jon.
Re: [PATCH 01/23] Introduce git-test.sh and git-test-lib.sh
In reply to Jon SeymourQuoted 7 lines · Jon Seymour
This command is intended provide a uniform command line interface to a suite of assertions that can be made about the state of the working tree, index and repository.
This commit introduces the core assert infrastructure. Subsequent commits will introduce check functions that extend the infrastructure in a modular way with additional tests.
.....
Quoted 8 lines
+'test_condition' [--<condition> [ arg ... ]] ...
+'require_condition_libs'Documentation/git-test.txt new file +6
-0+ + +DESCRIPTION +----------- +`git test` provides a uniform, extensible API for evaluating various conditions that +pertain to the state of a git working tree, index and repository.
Documentation/git-test.txt line 38
Quoted 10 lines
Documentation/git-test.txt new file +10
-0+ +Specified conditions are evaluated from left to right. If any condition evaluates to false, +the command conditionally prints a diagnostic message to stderr and sets a +non-zero status code. Otherwise, sets a status code of zero. + +The message used to report a assertion failure may be overidden by specifying the --message option. + +Diagnostic output resulting from an assertion failure may be suppressed with the -q option. +Note that the -q option does not suppress diagnostic output that results from the failure to +successfully parse the arguments that configure the test API.
.....
Is this supposed to be a porcelain or plumbing?
The name could probably be better to avoid confusion with the "unit testing" code in t/.
Additionally, I'd like to know why this shouldn't be implemented as some sort of
'git status --assert="XXXX"'
call...
Signature · 4 lines
-Drew Northup ________________________________________________ "As opposed to vegetable or mineral error?" -John Pescatore, SANS NewsBites Vol. 12 Num. 59