Skip to content

Commit a17b1d2

Browse files
committed
Merge branch 'maint'
* maint: git-bisect: make "start", "good" and "skip" succeed or fail atomically git-am: cope better with an empty Subject: line Ignore leading empty lines while summarizing merges bisect: squelch "fatal: ref HEAD not a symref" misleading message builtin-apply: Show a more descriptive error on failure when opening a patch Clarify documentation of git-cvsserver, particularly in relation to git-shell
2 parents 189d6b8 + 464509f commit a17b1d2

File tree

6 files changed

+54
-33
lines changed

6 files changed

+54
-33
lines changed

Documentation/git-cvsserver.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ cvs -d ":ext;CVS_SERVER=git-cvsserver:user@server/path/repo.git" co <HEAD_name>
110110
------
111111
This has the advantage that it will be saved in your 'CVS/Root' files and
112112
you don't need to worry about always setting the correct environment
113-
variable.
113+
variable. SSH users restricted to git-shell don't need to override the default
114+
with CVS_SERVER (and shouldn't) as git-shell understands `cvs` to mean
115+
git-cvsserver and pretends that the other end runs the real cvs better.
114116
--
115117
2. For each repo that you want accessible from CVS you need to edit config in
116118
the repo and add the following section.
@@ -141,25 +143,29 @@ allowing access over SSH.
141143
enabled=1
142144
------
143145
--
144-
3. On the client machine you need to set the following variables.
145-
CVSROOT should be set as per normal, but the directory should point at the
146-
appropriate git repo. For example:
146+
3. If you didn't specify the CVSROOT/CVS_SERVER directly in the checkout command,
147+
automatically saving it in your 'CVS/Root' files, then you need to set them
148+
explicitly in your environment. CVSROOT should be set as per normal, but the
149+
directory should point at the appropriate git repo. As above, for SSH clients
150+
_not_ restricted to git-shell, CVS_SERVER should be set to git-cvsserver.
147151
+
148152
--
149-
For SSH access, CVS_SERVER should be set to git-cvsserver
150-
151-
Example:
152-
153153
------
154154
export CVSROOT=:ext:user@server:/var/git/project.git
155155
export CVS_SERVER=git-cvsserver
156156
------
157157
--
158-
4. For SSH clients that will make commits, make sure their .bashrc file
159-
sets the GIT_AUTHOR and GIT_COMMITTER variables.
158+
4. For SSH clients that will make commits, make sure their server-side
159+
.ssh/environment files (or .bashrc, etc., according to their specific shell)
160+
export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL,
161+
GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL. For SSH clients whose login
162+
shell is bash, .bashrc may be a reasonable alternative.
160163

161164
5. Clients should now be able to check out the project. Use the CVS 'module'
162-
name to indicate what GIT 'head' you want to check out. Example:
165+
name to indicate what GIT 'head' you want to check out. This also sets the
166+
name of your newly checked-out directory, unless you tell it otherwise with
167+
`-d <dir_name>`. For example, this checks out 'master' branch to the
168+
`project-master` directory:
163169
+
164170
------
165171
cvs co -d project-master master

builtin-apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
31173117

31183118
fd = open(arg, O_RDONLY);
31193119
if (fd < 0)
3120-
usage(apply_usage);
3120+
die("can't open patch '%s': %s", arg, strerror(errno));
31213121
read_stdin = 0;
31223122
set_default_whitespace_mode(whitespace_option);
31233123
errs |= apply_patch(fd, arg, inaccurate_eof);

builtin-fmt-merge-msg.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,22 @@ static void shortlog(const char *name, unsigned char *sha1,
201201
continue;
202202

203203
bol = strstr(commit->buffer, "\n\n");
204+
if (bol) {
205+
unsigned char c;
206+
do {
207+
c = *++bol;
208+
} while (isspace(c));
209+
if (!c)
210+
bol = NULL;
211+
}
212+
204213
if (!bol) {
205214
append_to_list(&subjects, xstrdup(sha1_to_hex(
206215
commit->object.sha1)),
207216
NULL);
208217
continue;
209218
}
210219

211-
bol += 2;
212220
eol = strchr(bol, '\n');
213221
if (eol) {
214222
oneline = xmemdupz(bol, eol - bol);

git-am.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ It does not apply to blobs recorded in its index."
107107
# patch did not touch, so recursive ends up canceling them,
108108
# saying that we reverted all those changes.
109109

110-
eval GITHEAD_$his_tree='"$SUBJECT"'
110+
eval GITHEAD_$his_tree='"$FIRSTLINE"'
111111
export GITHEAD_$his_tree
112112
git-merge-recursive $orig_tree -- HEAD $his_tree || {
113113
git rerere
@@ -117,10 +117,6 @@ It does not apply to blobs recorded in its index."
117117
unset GITHEAD_$his_tree
118118
}
119119

120-
reread_subject () {
121-
git stripspace <"$1" | sed -e 1q
122-
}
123-
124120
prec=4
125121
dotest=".dotest"
126122
sign= utf8=t keep= skip= interactive= resolved= binary= rebasing=
@@ -331,7 +327,11 @@ do
331327
echo "Patch is empty. Was it split wrong?"
332328
stop_here $this
333329
}
334-
git stripspace < "$dotest/msg" > "$dotest/msg-clean"
330+
SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
331+
case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
332+
333+
(echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
334+
git stripspace > "$dotest/msg-clean"
335335
;;
336336
esac
337337

@@ -347,9 +347,6 @@ do
347347

348348
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
349349

350-
SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
351-
case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
352-
353350
case "$resume" in
354351
'')
355352
if test '' != "$SIGNOFF"
@@ -368,10 +365,8 @@ do
368365
ADD_SIGNOFF=
369366
fi
370367
{
371-
printf '%s\n' "$SUBJECT"
372368
if test -s "$dotest/msg-clean"
373369
then
374-
echo
375370
cat "$dotest/msg-clean"
376371
fi
377372
if test '' != "$ADD_SIGNOFF"
@@ -388,6 +383,7 @@ do
388383
;;
389384
esac
390385
esac
386+
FIRSTLINE=$(head -1 "$dotest/final-commit")
391387

392388
resume=
393389
if test "$interactive" = t
@@ -408,7 +404,7 @@ do
408404
[aA]*) action=yes interactive= ;;
409405
[nN]*) action=skip ;;
410406
[eE]*) git_editor "$dotest/final-commit"
411-
SUBJECT=$(reread_subject "$dotest/final-commit")
407+
FIRSTLINE=$(head -1 "$dotest/final-commit")
412408
action=again ;;
413409
[vV]*) action=again
414410
LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -431,7 +427,7 @@ do
431427
stop_here $this
432428
fi
433429

434-
printf 'Applying %s\n' "$SUBJECT"
430+
printf 'Applying %s\n' "$FIRSTLINE"
435431

436432
case "$resolved" in
437433
'')
@@ -489,7 +485,7 @@ do
489485
tree=$(git write-tree) &&
490486
parent=$(git rev-parse --verify HEAD) &&
491487
commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
492-
git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
488+
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
493489
stop_here $this
494490

495491
if test -x "$GIT_DIR"/hooks/post-applypatch

git-bisect.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ bisect_start() {
6666
# Verify HEAD. If we were bisecting before this, reset to the
6767
# top-of-line master first!
6868
#
69-
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
69+
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
7070
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
7171
die "Bad HEAD - I need a HEAD"
72+
start_head=''
7273
case "$head" in
7374
refs/heads/bisect)
7475
if [ -s "$GIT_DIR/BISECT_START" ]; then
@@ -82,7 +83,7 @@ bisect_start() {
8283
# This error message should only be triggered by cogito usage,
8384
# and cogito users should understand it relates to cg-seek.
8485
[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
85-
echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
86+
start_head="${head#refs/heads/}"
8687
;;
8788
*)
8889
die "Bad HEAD - strange symbolic ref"
@@ -103,6 +104,7 @@ bisect_start() {
103104
done
104105
orig_args=$(sq "$@")
105106
bad_seen=0
107+
eval=''
106108
while [ $# -gt 0 ]; do
107109
arg="$1"
108110
case "$arg" in
@@ -120,13 +122,15 @@ bisect_start() {
120122
0) state='bad' ; bad_seen=1 ;;
121123
*) state='good' ;;
122124
esac
123-
bisect_write "$state" "$rev" 'nolog'
125+
eval="$eval bisect_write '$state' '$rev' 'nolog'; "
124126
shift
125127
;;
126128
esac
127129
done
128130

129131
sq "$@" >"$GIT_DIR/BISECT_NAMES"
132+
test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
133+
eval "$eval"
130134
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
131135
bisect_auto_next
132136
}
@@ -157,12 +161,14 @@ bisect_state() {
157161
bisect_write "$state" "$rev" ;;
158162
2,bad|*,good|*,skip)
159163
shift
164+
eval=''
160165
for rev in "$@"
161166
do
162167
sha=$(git rev-parse --verify "$rev^{commit}") ||
163168
die "Bad rev input: $rev"
164-
bisect_write "$state" "$sha"
165-
done ;;
169+
eval="$eval bisect_write '$state' '$sha'; "
170+
done
171+
eval "$eval" ;;
166172
*,bad)
167173
die "'git bisect bad' can take only one argument." ;;
168174
*)

t/t6030-bisect-porcelain.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,20 @@ test_expect_success 'bisect start with one bad and good' '
7171
git bisect next
7272
'
7373

74-
test_expect_success 'bisect good and bad fails if not given only revs' '
74+
test_expect_success 'bisect fails if given any junk instead of revs' '
7575
git bisect reset &&
76+
test_must_fail git bisect start foo $HASH1 -- &&
77+
test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
78+
test -z "$(git for-each-ref "refs/bisect/*")" &&
79+
test_must_fail ls .git/BISECT_* &&
7680
git bisect start &&
7781
test_must_fail git bisect good foo $HASH1 &&
7882
test_must_fail git bisect good $HASH1 bar &&
7983
test_must_fail git bisect bad frotz &&
8084
test_must_fail git bisect bad $HASH3 $HASH4 &&
8185
test_must_fail git bisect skip bar $HASH3 &&
8286
test_must_fail git bisect skip $HASH1 foo &&
87+
test -z "$(git for-each-ref "refs/bisect/*")" &&
8388
git bisect good $HASH1 &&
8489
git bisect bad $HASH4
8590
'

0 commit comments

Comments
 (0)