Skip to content

Commit d25430c

Browse files
committed
Merge branch 'maint'
* maint: scripts: do not get confused with HEAD in work tree Improve description of git-branch -d and -D in man page.
2 parents b3a4f85 + 38762c4 commit d25430c

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

Documentation/git-branch.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,22 @@ to happen.
4545

4646
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
4747
specify more than one branch for deletion. If the branch currently
48-
has a reflog then the reflog will also be deleted. Use -r together with -d
49-
to delete remote-tracking branches.
48+
has a reflog then the reflog will also be deleted.
49+
50+
Use -r together with -d to delete remote-tracking branches. Note, that it
51+
only makes sense to delete remote-tracking branches if they no longer exist
52+
in remote repository or if gitlink:git-fetch[1] was configured not to fetch
53+
them again. See also 'prune' subcommand of gitlink:git-remote[1] for way to
54+
clean up all obsolete remote-tracking branches.
5055

5156

5257
OPTIONS
5358
-------
5459
-d::
55-
Delete a branch. The branch must be fully merged.
60+
Delete a branch. The branch must be fully merged in HEAD.
5661

5762
-D::
58-
Delete a branch irrespective of its index status.
63+
Delete a branch irrespective of its merged status.
5964

6065
-l::
6166
Create the branch's reflog. This activates recording of
@@ -153,9 +158,11 @@ $ git branch -d -r origin/todo origin/html origin/man <1>
153158
$ git branch -D test <2>
154159
------------
155160
+
156-
<1> Delete remote-tracking branches "todo", "html", "man"
157-
<2> Delete "test" branch even if the "master" branch does not have all
158-
commits from test branch.
161+
<1> Delete remote-tracking branches "todo", "html", "man". Next 'fetch' or
162+
'pull' will create them again unless you configure them not to. See
163+
gitlink:git-fetch[1].
164+
<2> Delete "test" branch even if the "master" branch (or whichever branch is
165+
currently checked out) does not have all commits from test branch.
159166

160167

161168
Notes

contrib/examples/git-merge-ours.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
# because the current index is what we will be committing as the
1010
# merge result.
1111

12-
git diff-index --quiet --cached HEAD || exit 2
12+
git diff-index --quiet --cached HEAD -- || exit 2
1313

1414
exit 0

git-am.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fi
218218

219219
case "$resolved" in
220220
'')
221-
files=$(git diff-index --cached --name-only HEAD) || exit
221+
files=$(git diff-index --cached --name-only HEAD --) || exit
222222
if [ "$files" ]; then
223223
echo "Dirty index: cannot apply patches (dirty: $files)" >&2
224224
exit 1
@@ -352,7 +352,7 @@ do
352352
case "$resolved$interactive" in
353353
tt)
354354
# This is used only for interactive view option.
355-
git diff-index -p --cached HEAD >"$dotest/patch"
355+
git diff-index -p --cached HEAD -- >"$dotest/patch"
356356
;;
357357
esac
358358
esac
@@ -411,7 +411,7 @@ do
411411
# trust what the user has in the index file and the
412412
# working tree.
413413
resolved=
414-
git diff-index --quiet --cached HEAD && {
414+
git diff-index --quiet --cached HEAD -- && {
415415
echo "No changes - did you forget to use 'git add'?"
416416
stop_here_user_resolve $this
417417
}
@@ -433,7 +433,7 @@ do
433433
then
434434
# Applying the patch to an earlier tree and merging the
435435
# result may have produced the same tree as ours.
436-
git diff-index --quiet --cached HEAD && {
436+
git diff-index --quiet --cached HEAD -- && {
437437
echo No changes -- Patch already applied.
438438
go_next
439439
continue

git-filter-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ OPTIONS_SPEC=
9898
. git-sh-setup
9999

100100
git diff-files --quiet &&
101-
git diff-index --cached --quiet HEAD ||
101+
git diff-index --cached --quiet HEAD -- ||
102102
die "Cannot rewrite branch(es) with a dirty working directory."
103103

104104
tempdir=.git-rewrite

git-rebase--interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ require_clean_work_tree () {
5353
git rev-parse --verify HEAD > /dev/null &&
5454
git update-index --refresh &&
5555
git diff-files --quiet &&
56-
git diff-index --cached --quiet HEAD ||
56+
git diff-index --cached --quiet HEAD -- ||
5757
die "Working tree is dirty"
5858
}
5959

@@ -356,7 +356,7 @@ do
356356
git rev-parse --verify HEAD > /dev/null &&
357357
git update-index --refresh &&
358358
git diff-files --quiet &&
359-
! git diff-index --cached --quiet HEAD &&
359+
! git diff-index --cached --quiet HEAD -- &&
360360
. "$DOTEST"/author-script && {
361361
test ! -f "$DOTEST"/amend || git reset --soft HEAD^
362362
} &&

git-rebase.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ continue_merge () {
6161
fi
6262

6363
cmt=`cat "$dotest/current"`
64-
if ! git diff-index --quiet HEAD
64+
if ! git diff-index --quiet HEAD --
6565
then
6666
if ! git-commit -C "$cmt"
6767
then
@@ -285,7 +285,7 @@ fi
285285

286286
# The tree must be really really clean.
287287
git update-index --refresh || exit
288-
diff=$(git diff-index --cached --name-status -r HEAD)
288+
diff=$(git diff-index --cached --name-status -r HEAD --)
289289
case "$diff" in
290290
?*) echo "cannot rebase: your index is not up-to-date"
291291
echo "$diff"

git-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trap 'rm -f "$TMP-*"' 0
1515
ref_stash=refs/stash
1616

1717
no_changes () {
18-
git diff-index --quiet --cached HEAD &&
18+
git diff-index --quiet --cached HEAD -- &&
1919
git diff-files --quiet
2020
}
2121

0 commit comments

Comments
 (0)