Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
jjuran committed Aug 7, 2012
2 parents 3236ca6 + 6320526 commit 8d012b3
Show file tree
Hide file tree
Showing 27 changed files with 320 additions and 65 deletions.
32 changes: 32 additions & 0 deletions Documentation/RelNotes/1.7.6.4.txt
@@ -0,0 +1,32 @@
Git v1.7.6.4 Release Notes
==========================

Fixes since v1.7.6.3
--------------------

* The error reporting logic of "git am" when the command is fed a file
whose mail-storage format is unknown was fixed.

* "git branch --set-upstream @{-1} foo" did not expand @{-1} correctly.

* "git check-ref-format --print" used to parrot a candidate string that
began with a slash (e.g. /refs/heads/master) without stripping it, to make
the result a suitably normalized string the caller can append to "$GIT_DIR/".

* "git clone" failed to clone locally from a ".git" file that itself
is not a directory but is a pointer to one.

* "git clone" from a local repository that borrows from another
object store using a relative path in its objects/info/alternates
file did not adjust the alternates in the resulting repository.

* "git describe --dirty" did not refresh the index before checking the
state of the working tree files.

* "git ls-files ../$path" that is run from a subdirectory reported errors
incorrectly when there is no such path that matches the given pathspec.

* "git mergetool" could loop forever prompting when nothing can be read
from the standard input.

Also contains minor fixes and documentation updates.
3 changes: 2 additions & 1 deletion Documentation/git.txt
Expand Up @@ -44,9 +44,10 @@ unreleased) version of git, that is available from 'master'
branch of the `git.git` repository.
Documentation for older releases are available here:

* link:v1.7.6.3/git.html[documentation for release 1.7.6.3]
* link:v1.7.6.4/git.html[documentation for release 1.7.6.4]

* release notes for
link:RelNotes/1.7.6.4.txt[1.7.6.4],
link:RelNotes/1.7.6.3.txt[1.7.6.3],
link:RelNotes/1.7.6.2.txt[1.7.6.2],
link:RelNotes/1.7.6.1.txt[1.7.6.1],
Expand Down
2 changes: 1 addition & 1 deletion GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh

GVF=GIT-VERSION-FILE
DEF_VER=v1.7.6.3
DEF_VER=v1.7.6.4

LF='
'
Expand Down
2 changes: 1 addition & 1 deletion RelNotes
2 changes: 1 addition & 1 deletion branch.c
Expand Up @@ -210,7 +210,7 @@ void create_branch(const char *head,
start_name);

if (real_ref && track)
setup_tracking(name, real_ref, track);
setup_tracking(ref.buf+11, real_ref, track);

if (!dont_change_ref)
if (write_ref_sha1(lock, sha1, msg) < 0)
Expand Down
6 changes: 3 additions & 3 deletions builtin/check-ref-format.c
Expand Up @@ -12,16 +12,16 @@ static const char builtin_check_ref_format_usage[] =
" or: git check-ref-format --branch <branchname-shorthand>";

/*
* Replace each run of adjacent slashes in src with a single slash,
* and write the result to dst.
* Remove leading slashes and replace each run of adjacent slashes in
* src with a single slash, and write the result to dst.
*
* This function is similar to normalize_path_copy(), but stripped down
* to meet check_ref_format's simpler needs.
*/
static void collapse_slashes(char *dst, const char *src)
{
char ch;
char prev = '\0';
char prev = '/';

while ((ch = *src++) != '\0') {
if (prev == '/' && ch == prev)
Expand Down
6 changes: 3 additions & 3 deletions builtin/checkout.c
Expand Up @@ -201,7 +201,7 @@ static int checkout_merged(int pos, struct checkout *state)
}

static int checkout_paths(struct tree *source_tree, const char **pathspec,
struct checkout_opts *opts)
const char *prefix, struct checkout_opts *opts)
{
int pos;
struct checkout state;
Expand Down Expand Up @@ -231,7 +231,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, ps_matched);
}

if (report_path_error(ps_matched, pathspec, 0))
if (report_path_error(ps_matched, pathspec, prefix))
return 1;

/* "checkout -m path" to recreate conflicted state */
Expand Down Expand Up @@ -1072,7 +1072,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge)
die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index."));

return checkout_paths(source_tree, pathspec, &opts);
return checkout_paths(source_tree, pathspec, prefix, &opts);
}

if (patch_mode)
Expand Down
138 changes: 108 additions & 30 deletions builtin/clone.c
Expand Up @@ -39,13 +39,23 @@ static const char * const builtin_clone_usage[] = {

static int option_no_checkout, option_bare, option_mirror;
static int option_local, option_no_hardlinks, option_shared, option_recursive;
static char *option_template, *option_reference, *option_depth;
static char *option_template, *option_depth;
static char *option_origin = NULL;
static char *option_branch = NULL;
static const char *real_git_dir;
static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress;
static struct string_list option_reference;

static int opt_parse_reference(const struct option *opt, const char *arg, int unset)
{
struct string_list *option_reference = opt->value;
if (!arg)
return -1;
string_list_append(option_reference, arg);
return 0;
}

static struct option builtin_clone_options[] = {
OPT__VERBOSITY(&option_verbosity),
Expand All @@ -71,8 +81,8 @@ static struct option builtin_clone_options[] = {
"initialize submodules in the clone"),
OPT_STRING(0, "template", &option_template, "template-directory",
"directory from which templates will be used"),
OPT_STRING(0, "reference", &option_reference, "repo",
"reference repository"),
OPT_CALLBACK(0 , "reference", &option_reference, "repo",
"reference repository", &opt_parse_reference),
OPT_STRING('o', "origin", &option_origin, "branch",
"use <branch> instead of 'origin' to track upstream"),
OPT_STRING('b', "branch", &option_branch, "branch",
Expand Down Expand Up @@ -101,9 +111,26 @@ static char *get_repo_path(const char *repo, int *is_bundle)
for (i = 0; i < ARRAY_SIZE(suffix); i++) {
const char *path;
path = mkpath("%s%s", repo, suffix[i]);
if (is_directory(path)) {
if (stat(path, &st))
continue;
if (S_ISDIR(st.st_mode)) {
*is_bundle = 0;
return xstrdup(absolute_path(path));
} else if (S_ISREG(st.st_mode) && st.st_size > 8) {
/* Is it a "gitfile"? */
char signature[8];
int len, fd = open(path, O_RDONLY);
if (fd < 0)
continue;
len = read_in_full(fd, signature, 8);
close(fd);
if (len != 8 || strncmp(signature, "gitdir: ", 8))
continue;
path = read_gitfile(path);
if (path) {
*is_bundle = 0;
return xstrdup(absolute_path(path));
}
}
}

Expand Down Expand Up @@ -197,39 +224,80 @@ static void strip_trailing_slashes(char *dir)
*end = '\0';
}

static void setup_reference(const char *repo)
static int add_one_reference(struct string_list_item *item, void *cb_data)
{
const char *ref_git;
char *ref_git_copy;

char *ref_git;
struct strbuf alternate = STRBUF_INIT;
struct remote *remote;
struct transport *transport;
const struct ref *extra;

ref_git = real_path(option_reference);

if (is_directory(mkpath("%s/.git/objects", ref_git)))
ref_git = mkpath("%s/.git", ref_git);
else if (!is_directory(mkpath("%s/objects", ref_git)))
/* Beware: real_path() and mkpath() return static buffer */
ref_git = xstrdup(real_path(item->string));
if (is_directory(mkpath("%s/.git/objects", ref_git))) {
char *ref_git_git = xstrdup(mkpath("%s/.git", ref_git));
free(ref_git);
ref_git = ref_git_git;
} else if (!is_directory(mkpath("%s/objects", ref_git)))
die(_("reference repository '%s' is not a local directory."),
option_reference);
item->string);

ref_git_copy = xstrdup(ref_git);
strbuf_addf(&alternate, "%s/objects", ref_git);
add_to_alternates_file(alternate.buf);
strbuf_release(&alternate);

add_to_alternates_file(ref_git_copy);

remote = remote_get(ref_git_copy);
transport = transport_get(remote, ref_git_copy);
remote = remote_get(ref_git);
transport = transport_get(remote, ref_git);
for (extra = transport_get_remote_refs(transport); extra;
extra = extra->next)
add_extra_ref(extra->name, extra->old_sha1, 0);

transport_disconnect(transport);
free(ref_git);
return 0;
}

free(ref_git_copy);
static void setup_reference(void)
{
for_each_string_list(&option_reference, add_one_reference, NULL);
}

static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
static void copy_alternates(struct strbuf *src, struct strbuf *dst,
const char *src_repo)
{
/*
* Read from the source objects/info/alternates file
* and copy the entries to corresponding file in the
* destination repository with add_to_alternates_file().
* Both src and dst have "$path/objects/info/alternates".
*
* Instead of copying bit-for-bit from the original,
* we need to append to existing one so that the already
* created entry via "clone -s" is not lost, and also
* to turn entries with paths relative to the original
* absolute, so that they can be used in the new repository.
*/
FILE *in = fopen(src->buf, "r");
struct strbuf line = STRBUF_INIT;

while (strbuf_getline(&line, in, '\n') != EOF) {
char *abs_path, abs_buf[PATH_MAX];
if (!line.len || line.buf[0] == '#')
continue;
if (is_absolute_path(line.buf)) {
add_to_alternates_file(line.buf);
continue;
}
abs_path = mkpath("%s/objects/%s", src_repo, line.buf);
normalize_path_copy(abs_buf, abs_path);
add_to_alternates_file(abs_buf);
}
strbuf_release(&line);
fclose(in);
}

static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
const char *src_repo, int src_baselen)
{
struct dirent *de;
struct stat buf;
Expand Down Expand Up @@ -265,7 +333,14 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
}
if (S_ISDIR(buf.st_mode)) {
if (de->d_name[0] != '.')
copy_or_link_directory(src, dest);
copy_or_link_directory(src, dest,
src_repo, src_baselen);
continue;
}

/* Files that cannot be copied bit-for-bit... */
if (!strcmp(src->buf + src_baselen, "/info/alternates")) {
copy_alternates(src, dest, src_repo);
continue;
}

Expand All @@ -288,17 +363,20 @@ static const struct ref *clone_local(const char *src_repo,
const char *dest_repo)
{
const struct ref *ret;
struct strbuf src = STRBUF_INIT;
struct strbuf dest = STRBUF_INIT;
struct remote *remote;
struct transport *transport;

if (option_shared)
add_to_alternates_file(src_repo);
else {
if (option_shared) {
struct strbuf alt = STRBUF_INIT;
strbuf_addf(&alt, "%s/objects", src_repo);
add_to_alternates_file(alt.buf);
strbuf_release(&alt);
} else {
struct strbuf src = STRBUF_INIT;
struct strbuf dest = STRBUF_INIT;
strbuf_addf(&src, "%s/objects", src_repo);
strbuf_addf(&dest, "%s/objects", dest_repo);
copy_or_link_directory(&src, &dest);
copy_or_link_directory(&src, &dest, src_repo, src.len);
strbuf_release(&src);
strbuf_release(&dest);
}
Expand Down Expand Up @@ -521,8 +599,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_config_set(key.buf, repo);
strbuf_reset(&key);

if (option_reference)
setup_reference(git_dir);
if (option_reference.nr)
setup_reference();

fetch_pattern = value.buf;
refspec = parse_fetch_refspec(1, &fetch_pattern);
Expand Down
2 changes: 1 addition & 1 deletion builtin/commit.c
Expand Up @@ -272,7 +272,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
item->util = item; /* better a valid pointer than a fake one */
}

return report_path_error(m, pattern, prefix ? strlen(prefix) : 0);
return report_path_error(m, pattern, prefix);
}

static void add_remove_files(struct string_list *list)
Expand Down
17 changes: 15 additions & 2 deletions builtin/describe.c
Expand Up @@ -471,8 +471,21 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
die(_("No names found, cannot describe anything."));

if (argc == 0) {
if (dirty && !cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args, prefix))
dirty = NULL;
if (dirty) {
static struct lock_file index_lock;
int fd;

read_cache_preload(NULL);
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
NULL, NULL, NULL);
fd = hold_locked_index(&index_lock, 0);
if (0 <= fd)
update_index_if_able(&the_index, &index_lock);

if (!cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1,
diff_index_args, prefix))
dirty = NULL;
}
describe("HEAD", 1);
} else if (dirty) {
die(_("--dirty is incompatible with committishes"));
Expand Down
2 changes: 1 addition & 1 deletion builtin/init-db.c
Expand Up @@ -347,7 +347,7 @@ static void separate_git_dir(const char *git_dir)
const char *src;

if (S_ISREG(st.st_mode))
src = read_gitfile_gently(git_link);
src = read_gitfile(git_link);
else if (S_ISDIR(st.st_mode))
src = git_link;
else
Expand Down

0 comments on commit 8d012b3

Please sign in to comment.