author | Junio C Hamano <gitster@pobox.com> | |
Thu, 29 Nov 2007 01:06:57 +0000 (17:06 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 29 Nov 2007 01:06:57 +0000 (17:06 -0800) |
* maint:
scripts: do not get confused with HEAD in work tree
Improve description of git-branch -d and -D in man page.
scripts: do not get confused with HEAD in work tree
Improve description of git-branch -d and -D in man page.
index 5ce905de862253aa2bd2ed619819306165e978f0..f87b6968b4808ebc7f831c814ca7e62924a19642 100644 (file)
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
specify more than one branch for deletion. If the branch currently
-has a reflog then the reflog will also be deleted. Use -r together with -d
-to delete remote-tracking branches.
+has a reflog then the reflog will also be deleted.
+
+Use -r together with -d to delete remote-tracking branches. Note, that it
+only makes sense to delete remote-tracking branches if they no longer exist
+in remote repository or if gitlink:git-fetch[1] was configured not to fetch
+them again. See also 'prune' subcommand of gitlink:git-remote[1] for way to
+clean up all obsolete remote-tracking branches.
OPTIONS
-------
-d::
- Delete a branch. The branch must be fully merged.
+ Delete a branch. The branch must be fully merged in HEAD.
-D::
- Delete a branch irrespective of its index status.
+ Delete a branch irrespective of its merged status.
-l::
Create the branch's reflog. This activates recording of
$ git branch -D test <2>
------------
+
-<1> Delete remote-tracking branches "todo", "html", "man"
-<2> Delete "test" branch even if the "master" branch does not have all
-commits from test branch.
+<1> Delete remote-tracking branches "todo", "html", "man". Next 'fetch' or
+'pull' will create them again unless you configure them not to. See
+gitlink:git-fetch[1].
+<2> Delete "test" branch even if the "master" branch (or whichever branch is
+currently checked out) does not have all commits from test branch.
Notes
index c81a790aa60ea08144dd0899d1aee2ec334a1825..29dba4ba3a57c15bd430bd23c1cebe78e6dc03be 100755 (executable)
# because the current index is what we will be committing as the
# merge result.
-git diff-index --quiet --cached HEAD || exit 2
+git diff-index --quiet --cached HEAD -- || exit 2
exit 0
diff --git a/git-am.sh b/git-am.sh
index 4126f0e857bad273d6f44cabe34565de860bd119..76c1c844a95d8af19f64a3278706daf907dace01 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
case "$resolved" in
'')
- files=$(git diff-index --cached --name-only HEAD) || exit
+ files=$(git diff-index --cached --name-only HEAD --) || exit
if [ "$files" ]; then
echo "Dirty index: cannot apply patches (dirty: $files)" >&2
exit 1
case "$resolved$interactive" in
tt)
# This is used only for interactive view option.
- git diff-index -p --cached HEAD >"$dotest/patch"
+ git diff-index -p --cached HEAD -- >"$dotest/patch"
;;
esac
esac
# trust what the user has in the index file and the
# working tree.
resolved=
- git diff-index --quiet --cached HEAD && {
+ git diff-index --quiet --cached HEAD -- && {
echo "No changes - did you forget to use 'git add'?"
stop_here_user_resolve $this
}
then
# Applying the patch to an earlier tree and merging the
# result may have produced the same tree as ours.
- git diff-index --quiet --cached HEAD && {
+ git diff-index --quiet --cached HEAD -- && {
echo No changes -- Patch already applied.
go_next
continue
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 19cab5a9a8b7ebbdf740158ba4f651457e3d53e5..674a25d27e50b421e516e8ca6e1190d04e323e9c 100755 (executable)
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
. git-sh-setup
git diff-files --quiet &&
- git diff-index --cached --quiet HEAD ||
+ git diff-index --cached --quiet HEAD -- ||
die "Cannot rewrite branch(es) with a dirty working directory."
tempdir=.git-rewrite
index bf44b6af58574273df9e7f549136a735f6e549fe..e9cd6fd999695daa1c5ba49835f53041d4131f3a 100755 (executable)
git rev-parse --verify HEAD > /dev/null &&
git update-index --refresh &&
git diff-files --quiet &&
- git diff-index --cached --quiet HEAD ||
+ git diff-index --cached --quiet HEAD -- ||
die "Working tree is dirty"
}
git rev-parse --verify HEAD > /dev/null &&
git update-index --refresh &&
git diff-files --quiet &&
- ! git diff-index --cached --quiet HEAD &&
+ ! git diff-index --cached --quiet HEAD -- &&
. "$DOTEST"/author-script && {
test ! -f "$DOTEST"/amend || git reset --soft HEAD^
} &&
diff --git a/git-rebase.sh b/git-rebase.sh
index 461ca8d93f4ab5c43792b4658d53b2e39ad18af1..bdcea0ed703057e08fd4204245f4f0c8a308f8d0 100755 (executable)
--- a/git-rebase.sh
+++ b/git-rebase.sh
fi
cmt=`cat "$dotest/current"`
- if ! git diff-index --quiet HEAD
+ if ! git diff-index --quiet HEAD --
then
if ! git-commit -C "$cmt"
then
# The tree must be really really clean.
git update-index --refresh || exit
-diff=$(git diff-index --cached --name-status -r HEAD)
+diff=$(git diff-index --cached --name-status -r HEAD --)
case "$diff" in
?*) echo "cannot rebase: your index is not up-to-date"
echo "$diff"
diff --git a/git-stash.sh b/git-stash.sh
index dd155568d96771b2dcd62ecae0cc2c050169bf52..b1529e28b1c4eb8b236bd497c83690c20621d369 100755 (executable)
--- a/git-stash.sh
+++ b/git-stash.sh
ref_stash=refs/stash
no_changes () {
- git diff-index --quiet --cached HEAD &&
+ git diff-index --quiet --cached HEAD -- &&
git diff-files --quiet
}