Anonymous committed 464509f Merge

Merge branch 'maint-1.5.4' into maint

* maint-1.5.4:
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

  • Participants
  • Parent commits 2b6f0b0, d3e54c8

Comments (0)

Files changed (6)


 This has the advantage that it will be saved in your 'CVS/Root' files and
 you don't need to worry about always setting the correct environment
+variable.  SSH users restricted to git-shell don't need to override the default
+with CVS_SERVER (and shouldn't) as git-shell understands `cvs` to mean
+git-cvsserver and pretends that the other end runs the real cvs better.
 2. For each repo that you want accessible from CVS you need to edit config in
    the repo and add the following section.
-3. On the client machine you need to set the following variables.
-   CVSROOT should be set as per normal, but the directory should point at the
-   appropriate git repo. For example:
+3. If you didn't specify the CVSROOT/CVS_SERVER directly in the checkout command,
+   automatically saving it in your 'CVS/Root' files, then you need to set them
+   explicitly in your environment.  CVSROOT should be set as per normal, but the
+   directory should point at the appropriate git repo.  As above, for SSH clients
+   _not_ restricted to git-shell, CVS_SERVER should be set to git-cvsserver.
-For SSH access, CVS_SERVER should be set to git-cvsserver
      export CVSROOT=:ext:user@server:/var/git/project.git
      export CVS_SERVER=git-cvsserver
-4. For SSH clients that will make commits, make sure their .bashrc file
-   sets the GIT_AUTHOR and GIT_COMMITTER variables.
+4. For SSH clients that will make commits, make sure their server-side
+   .ssh/environment files (or .bashrc, etc., according to their specific shell)
+   export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL,
+   GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL.  For SSH clients whose login
+   shell is bash, .bashrc may be a reasonable alternative.
 5. Clients should now be able to check out the project. Use the CVS 'module'
-   name to indicate what GIT 'head' you want to check out. Example:
+   name to indicate what GIT 'head' you want to check out.  This also sets the
+   name of your newly checked-out directory, unless you tell it otherwise with
+   `-d <dir_name>`.  For example, this checks out 'master' branch to the
+   `project-master` directory:
      cvs co -d project-master master
 		fd = open(arg, O_RDONLY);
 		if (fd < 0)
-			usage(apply_usage);
+			die("can't open patch '%s': %s", arg, strerror(errno));
 		read_stdin = 0;
 		errs |= apply_patch(fd, arg, inaccurate_eof);


 		bol = strstr(commit->buffer, "\n\n");
+		if (bol) {
+			unsigned char c;
+			do {
+				c = *++bol;
+			} while (isspace(c));
+			if (!c)
+				bol = NULL;
+		}
 		if (!bol) {
 			append_to_list(&subjects, xstrdup(sha1_to_hex(
-		bol += 2;
 		eol = strchr(bol, '\n');
 		if (eol) {
 			oneline = xmemdupz(bol, eol - bol);
     # patch did not touch, so recursive ends up canceling them,
     # saying that we reverted all those changes.
-    eval GITHEAD_$his_tree='"$SUBJECT"'
+    eval GITHEAD_$his_tree='"$FIRSTLINE"'
     export GITHEAD_$his_tree
     git-merge-recursive $orig_tree -- HEAD $his_tree || {
 	    git rerere
     unset GITHEAD_$his_tree
-reread_subject () {
-	git stripspace <"$1" | sed -e 1q
 sign= utf8=t keep= skip= interactive= resolved= binary= rebasing=
 			echo "Patch is empty.  Was it split wrong?"
 			stop_here $this
-		git stripspace < "$dotest/msg" > "$dotest/msg-clean"
+		SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
+		case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
+		(echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
+			git stripspace > "$dotest/msg-clean"
-	SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
-	case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
 	case "$resume" in
 	    if test '' != "$SIGNOFF"
-		printf '%s\n' "$SUBJECT"
 		if test -s "$dotest/msg-clean"
-			echo
 			cat "$dotest/msg-clean"
 		if test '' != "$ADD_SIGNOFF"
+	FIRSTLINE=$(head -1 "$dotest/final-commit")
 	if test "$interactive" = t
 		[aA]*) action=yes interactive= ;;
 		[nN]*) action=skip ;;
 		[eE]*) git_editor "$dotest/final-commit"
-		       SUBJECT=$(reread_subject "$dotest/final-commit")
+		       FIRSTLINE=$(head -1 "$dotest/final-commit")
 		       action=again ;;
 		[vV]*) action=again
 		       LESS=-S ${PAGER:-less} "$dotest/patch" ;;
 		stop_here $this
-	printf 'Applying %s\n' "$SUBJECT"
+	printf 'Applying %s\n' "$FIRSTLINE"
 	case "$resolved" in
 	tree=$(git write-tree) &&
 	parent=$(git rev-parse --verify HEAD) &&
 	commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
-	git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
+	git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
 	stop_here $this
 	if test -x "$GIT_DIR"/hooks/post-applypatch
 	# Verify HEAD. If we were bisecting before this, reset to the
 	# top-of-line master first!
-	head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
+	head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
 	head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
 	die "Bad HEAD - I need a HEAD"
+	start_head=''
 	case "$head" in
 		if [ -s "$GIT_DIR/BISECT_START" ]; then
 		# This error message should only be triggered by cogito usage,
 		# and cogito users should understand it relates to cg-seek.
 		[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
-		echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
+		start_head="${head#refs/heads/}"
 		die "Bad HEAD - strange symbolic ref"
 	orig_args=$(sq "$@")
+	eval=''
 	while [ $# -gt 0 ]; do
 	    case "$arg" in
 		0) state='bad' ; bad_seen=1 ;;
 		*) state='good' ;;
-		bisect_write "$state" "$rev" 'nolog'
+		eval="$eval bisect_write '$state' '$rev' 'nolog'; "
 	sq "$@" >"$GIT_DIR/BISECT_NAMES"
+	test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
+	eval "$eval"
 	echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
 		bisect_write "$state" "$rev" ;;
+		eval=''
 		for rev in "$@"
 			sha=$(git rev-parse --verify "$rev^{commit}") ||
 				die "Bad rev input: $rev"
-			bisect_write "$state" "$sha"
-		done ;;
+			eval="$eval bisect_write '$state' '$sha'; "
+		done
+		eval "$eval" ;;
 		die "'git bisect bad' can take only one argument." ;;


 	git bisect next
-test_expect_success 'bisect good and bad fails if not given only revs' '
+test_expect_success 'bisect fails if given any junk instead of revs' '
 	git bisect reset &&
+	test_must_fail git bisect start foo $HASH1 -- &&
+	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
+	test -z "$(git for-each-ref "refs/bisect/*")" &&
+	test_must_fail ls .git/BISECT_* &&
 	git bisect start &&
 	test_must_fail git bisect good foo $HASH1 &&
 	test_must_fail git bisect good $HASH1 bar &&
 	test_must_fail git bisect bad $HASH3 $HASH4 &&
 	test_must_fail git bisect skip bar $HASH3 &&
 	test_must_fail git bisect skip $HASH1 foo &&
+	test -z "$(git for-each-ref "refs/bisect/*")" &&
 	git bisect good $HASH1 &&
 	git bisect bad $HASH4