Merge branch 'master' into next

* master:
  git-svn: print and flush authentication prompts to STDERR
  Solaris 5.8 returns ENOTDIR for inappropriate renames.
  Replace "echo -n" with printf in shell scripts.
  Set _ALL_SOURCE for AIX, but avoid its struct list.
  Start all test scripts with /bin/sh.
  git-pull: disallow implicit merging to detached HEAD
  Fix git-fetch while on detached HEAD not to give needlessly alarming errors
  git reflog expire: document --stale-fix option.
  Use nice names in conflict markers during cherry-pick/revert.
  [PATCH] Make gitk work when launched in a subdirectory
  [PATCH] gitk: add current directory to main window title
This commit is contained in:
Junio C Hamano
2007-01-16 02:32:31 -08:00
20 changed files with 108 additions and 39 deletions

View File

@@ -9,7 +9,7 @@ git-reflog - Manage reflog information
SYNOPSIS
--------
[verse]
'git-reflog' expire [--dry-run]
'git-reflog' expire [--dry-run] [--stale-fix]
[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...

View File

@@ -7,7 +7,7 @@ git-symbolic-ref - read and modify symbolic refs
SYNOPSIS
--------
'git-symbolic-ref' <name> [<ref>]
'git-symbolic-ref' [-q] <name> [<ref>]
DESCRIPTION
-----------
@@ -23,6 +23,14 @@ A symbolic ref is a regular file that stores a string that
begins with `ref: refs/`. For example, your `.git/HEAD` is
a regular file whose contents is `ref: refs/heads/master`.
OPTIONS
-------
-q::
Do not issue an error message if the <name> is not a
symbolic ref but a detached HEAD; instead exit with
non-zero status silently.
NOTES
-----
In the past, `.git/HEAD` was a symbolic link pointing at
@@ -36,6 +44,10 @@ cumbersome. On some platforms, `ln -sf` does not even work as
advertised (horrors). Therefore symbolic links are now deprecated
and symbolic refs are used by default.
git-symbolic-ref will exit with status 0 if the contents of the
symbolic ref were printed correctly, with status 1 if the requested
name is not a symbolic ref, or 128 if another error occurs.
Author
------
Written by Junio C Hamano <junkio@cox.net>

View File

@@ -13,7 +13,7 @@
*/
static const char reflog_expire_usage[] =
"git-reflog expire [--verbose] [--dry-run] [--fix-stale] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
"git-reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
static unsigned long default_reflog_expire;
static unsigned long default_reflog_expire_unreachable;

View File

@@ -3,9 +3,9 @@
#include "refs.h"
static const char git_symbolic_ref_usage[] =
"git-symbolic-ref name [ref]";
"git-symbolic-ref [-q] name [ref]";
static void check_symref(const char *HEAD)
static void check_symref(const char *HEAD, int quiet)
{
unsigned char sha1[20];
int flag;
@@ -13,17 +13,41 @@ static void check_symref(const char *HEAD)
if (!refs_heads_master)
die("No such ref: %s", HEAD);
else if (!(flag & REF_ISSYMREF))
die("ref %s is not a symbolic ref", HEAD);
else if (!(flag & REF_ISSYMREF)) {
if (!quiet)
die("ref %s is not a symbolic ref", HEAD);
else
exit(1);
}
puts(refs_heads_master);
}
int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
{
int quiet = 0;
git_config(git_default_config);
while (1 < argc) {
const char *arg = argv[1];
if (arg[0] != '-')
break;
else if (!strcmp("-q", arg))
quiet = 1;
else if (!strcmp("--", arg)) {
argc--;
argv++;
break;
}
else
die("unknown option %s", arg);
argc--;
argv++;
}
switch (argc) {
case 2:
check_symref(argv[1]);
check_symref(argv[1], quiet);
break;
case 3:
create_symref(argv[1], argv[2]);

View File

@@ -11,7 +11,7 @@ if [ -d "$GIT_DIR"/remotes ]; then
{
cd "$GIT_DIR"/remotes
ls | while read f; do
name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".")
name=$(printf "$f" | tr -c "A-Za-z0-9" ".")
sed -n \
-e "s/^URL: \(.*\)$/remote.$name.url \1 ./p" \
-e "s/^Pull: \(.*\)$/remote.$name.fetch \1 ^$ /p" \

View File

@@ -15,8 +15,9 @@
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#endif
#define _GNU_SOURCE
#define _BSD_SOURCE
#define _ALL_SOURCE 1
#define _GNU_SOURCE 1
#define _BSD_SOURCE 1
#include <unistd.h>
#include <stdio.h>
@@ -45,7 +46,9 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <pwd.h>
#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
#include <grp.h>
#define _ALL_SOURCE 1
#ifndef NO_ICONV
#include <iconv.h>

View File

@@ -49,7 +49,7 @@ get_remote_url () {
}
get_default_remote () {
curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
curr_branch=$(git-symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
origin=$(git-repo-config --get "branch.$curr_branch.remote")
echo ${origin:-origin}
}
@@ -137,7 +137,7 @@ canon_refs_list_for_fetch () {
shift
if test "$remote" = "$(get_default_remote)"
then
curr_branch=$(git-symbolic-ref HEAD | \
curr_branch=$(git-symbolic-ref -q HEAD | \
sed -e 's|^refs/heads/||')
merge_branches=$(git-repo-config \
--get-all "branch.${curr_branch}.merge")

View File

@@ -83,8 +83,17 @@ merge_head=$(sed -e '/ not-for-merge /d' \
case "$merge_head" in
'')
curr_branch=$(git-symbolic-ref HEAD | \
sed -e 's|^refs/heads/||')
curr_branch=$(git-symbolic-ref -q HEAD)
case $? in
0) ;;
1) echo >&2 "You are not currently on a branch; you must explicitly"
echo >&2 "specify which branch you wish to merge:"
echo >&2 " git pull <remote> <branch>"
exit 1;;
*) exit $?;;
esac
curr_branch=${curr_branch#refs/heads/}
echo >&2 "Warning: No merge candidate found because value of config option
\"branch.${curr_branch}.merge\" does not match any remote branch fetched."
echo >&2 "No changes."

View File

@@ -89,7 +89,7 @@ for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
echo "No author found in $patch_name" >&2;
echo "---"
cat $tmp_msg
echo -n "Author: ";
printf "Author: ";
read patch_author
echo "$patch_author"

View File

@@ -87,7 +87,7 @@ update_ref_status=$?
case "$reset_type" in
--hard )
test $update_ref_status = 0 && {
echo -n "HEAD is now at "
printf "HEAD is now at "
GIT_PAGER= git log --max-count=1 --pretty=oneline \
--abbrev-commit HEAD
}

View File

@@ -146,6 +146,12 @@ cherry-pick)
esac >.msg
eval GITHEAD_$head=HEAD
eval GITHEAD_$next='`git show -s \
--pretty=oneline --encoding="$encoding" "$commit" |
sed -e "s/^[^ ]* //"`'
export GITHEAD_$head GITHEAD_$next
# This three way merge is an interesting one. We are at
# $head, and would want to apply the change between $commit
# and $prev on top of us (when reverting), or the change between

View File

@@ -1918,7 +1918,8 @@ sub _simple_prompt {
$default_username = $_username if defined $_username;
if (defined $default_username && length $default_username) {
if (defined $realm && length $realm) {
print "Authentication realm: $realm\n";
print STDERR "Authentication realm: $realm\n";
STDERR->flush;
}
$cred->username($default_username);
} else {
@@ -1933,36 +1934,38 @@ sub _simple_prompt {
sub _ssl_server_trust_prompt {
my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
print "Error validating server certificate for '$realm':\n";
print STDERR "Error validating server certificate for '$realm':\n";
if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
print " - The certificate is not issued by a trusted ",
print STDERR " - The certificate is not issued by a trusted ",
"authority. Use the\n",
" fingerprint to validate the certificate manually!\n";
}
if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
print " - The certificate hostname does not match.\n";
print STDERR " - The certificate hostname does not match.\n";
}
if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
print " - The certificate is not yet valid.\n";
print STDERR " - The certificate is not yet valid.\n";
}
if ($failures & $SVN::Auth::SSL::EXPIRED) {
print " - The certificate has expired.\n";
print STDERR " - The certificate has expired.\n";
}
if ($failures & $SVN::Auth::SSL::OTHER) {
print " - The certificate has an unknown error.\n";
print STDERR " - The certificate has an unknown error.\n";
}
printf( "Certificate information:\n".
printf STDERR
"Certificate information:\n".
" - Hostname: %s\n".
" - Valid: from %s until %s\n".
" - Issuer: %s\n".
" - Fingerprint: %s\n",
map $cert_info->$_, qw(hostname valid_from valid_until
issuer_dname fingerprint) );
issuer_dname fingerprint);
my $choice;
prompt:
print $may_save ?
print STDERR $may_save ?
"(R)eject, accept (t)emporarily or accept (p)ermanently? " :
"(R)eject or accept (t)emporarily? ";
STDERR->flush;
$choice = lc(substr(<STDIN> || 'R', 0, 1));
if ($choice =~ /^t$/i) {
$cred->may_save(undef);
@@ -1980,7 +1983,8 @@ prompt:
sub _ssl_client_cert_prompt {
my ($cred, $realm, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
print "Client certificate filename: ";
print STDERR "Client certificate filename: ";
STDERR->flush;
chomp(my $filename = <STDIN>);
$cred->cert_file($filename);
$cred->may_save($may_save);
@@ -1999,13 +2003,14 @@ sub _username_prompt {
my ($cred, $realm, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
if (defined $realm && length $realm) {
print "Authentication realm: $realm\n";
print STDERR "Authentication realm: $realm\n";
}
my $username;
if (defined $_username) {
$username = $_username;
} else {
print "Username: ";
print STDERR "Username: ";
STDERR->flush;
chomp($username = <STDIN>);
}
$cred->username($username);
@@ -2015,7 +2020,8 @@ sub _username_prompt {
sub _read_password {
my ($prompt, $realm) = @_;
print $prompt;
print STDERR $prompt;
STDERR->flush;
require Term::ReadKey;
Term::ReadKey::ReadMode('noecho');
my $password = '';
@@ -2024,7 +2030,8 @@ sub _read_password {
$password .= $key;
}
Term::ReadKey::ReadMode('restore');
print "\n";
print STDERR "\n";
STDERR->flush;
$password;
}

3
gitk
View File

@@ -12,7 +12,7 @@ proc gitdir {} {
if {[info exists env(GIT_DIR)]} {
return $env(GIT_DIR)
} else {
return ".git"
return [exec git rev-parse --git-dir]
}
}
@@ -6293,6 +6293,7 @@ set stuffsaved 0
set patchnum 0
setcoords
makewindow
wm title . "[file tail $argv0]: [file tail [pwd]]"
readrefs
if {$cmdline_files ne {} || $revtreeargs ne {}} {

7
refs.c
View File

@@ -837,7 +837,12 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
retry:
if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
if (errno==EISDIR) {
if (errno==EISDIR || errno==ENOTDIR) {
/*
* rename(a, b) when b is an existing
* directory ought to result in ISDIR, but
* Solaris 5.8 gives ENOTDIR. Sheesh.
*/
if (remove_empty_directories(git_path("logs/%s", newref))) {
error("Directory not empty: logs/%s", newref);
goto rollback;

View File

@@ -88,7 +88,7 @@ check_verify_failure '"type" line label check'
# 5. type line eol check
echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
cat >expect.pat <<EOF
^error: char48: .*"[\]n"$

View File

@@ -23,7 +23,7 @@ test_expect_success setup '
cat >victim/.git/hooks/update <<'EOF'
#!/bin/sh
echo "$@" >$GIT_DIR/update.args
read x; echo -n "$x" >$GIT_DIR/update.stdin
read x; printf "$x" >$GIT_DIR/update.stdin
echo STDOUT update
echo STDERR update >&2
EOF
@@ -32,7 +32,7 @@ chmod u+x victim/.git/hooks/update
cat >victim/.git/hooks/post-update <<'EOF'
#!/bin/sh
echo "$@" >$GIT_DIR/post-update.args
read x; echo -n "$x" >$GIT_DIR/post-update.stdin
read x; printf "$x" >$GIT_DIR/post-update.stdin
echo STDOUT post-update
echo STDERR post-update >&2
EOF

View File

@@ -52,7 +52,7 @@ super aquam refectionis educavit me;
animam meam convertit,
deduxit me super semitas jusitiae,
EOF
echo -n "propter nomen suum." >> new4.txt
printf "propter nomen suum." >> new4.txt
cp new1.txt test.txt
test_expect_success "merge without conflict" \

View File

@@ -1,3 +1,4 @@
#!/bin/sh
test_description='git-svn rmdir'
. ./lib-git-svn.sh

View File

@@ -1,3 +1,4 @@
#!/bin/sh
test_description='git-svn graft-branches'
. ./lib-git-svn.sh

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Robin Rosenberg
#